Problem with PaperSize

edited 8:58PM in FastReport VCL 5
I use the following code to create a report with a blank page using DMPAPER_LETTER size.
var
  frxReport: TfrxReport;
  frxReportPage: TfrxReportPage;
begin
    frxReport := TfrxReport.Create(nil);
    frxReportPage := TfrxReportPage.Create(frxReport);
    frxReportPage.CreateUniqueName;
    frxReportPage.PaperSize := DMPAPER_LETTER;
    //frxReportPage.SetSizeAndDimensions(DMPAPER_LETTER,216,279); // I tried this and it gives me the same result as the line above
    frxReport.SaveToFile('C:\Test.fr3');
    frxReport.Free;
end;

When I execute this code, it generate a .FR3 file that contain the following line :
<TfrxReportPage Name="Page1" PaperWidth="216" PaperHeight="279" PaperSize="1" ...

The file seems to be good, but when I open it with the designer and go to "File" -> "Page Settings...", the size is set to "Custom" with a width of 21.59 (instead of 21.60) and a height of 27.94 (instead of 27,90).

If I select the size "Letter" manually and save the report, the .FR3 file now contain the following line :
<TfrxReportPage Name="Page1" PaperWidth="216" PaperHeight="279" PaperSize="119" ...

The only difference is the PaperSize is set to 119 instead of 1. When looking in Windows.pas, "DMPAPER_LAST = 118" so 119 should be an invalid PaperSize.

TL;DR : To assign Letter as the PaperSize for a page, we need to specify the value 119 instead of 1 (DMPAPER_LETTER).

Comments

  • gpigpi
    edited 8:58PM
    Use
    uses frxPrinter;
    TfrxReportPage(frxReport1.FindObject('Page1')).PaperSize := frxPrinters.Printer.PaperNameToNumber('A5');
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.