Force output to a specific paper format

Hi All,


Is it possible to force a printer to a specific paper format like: A4 fanfold 210 mm x 11 2/3 in?

This paperformat is available in the printer driver. Current problem now is that after one print job, this paper format is reset to Letter.

Comments

  • Set TfrxReportPage.PaperSize to A4

  • Hi,

    I already tried this, unfortunately without any effect. A4 paper is defined in Delphi, but A4 fanfold isn't.

    I also used TFormInfo1 to get all available paper sizes and set the TfrxReportPage.PaperSize to the right integer, but also no effect.

  • Did you change paper size before preparing of report?

  • Unfortunately this doesn't help:

    frxReportPage.PaperSize  := DMPAPER_USER;

    frxReportPage.PaperHeight := 25.4; // in 0.1 mm

    frxReportPage.PaperWidth := 220; // in 0.1 mm

    frxReport_Label.PrepareReport();

    frxReport_Label.ShowReport;


    Back to the orriginal code:

    frxReport_Label.LoadFromFile(ReportFileName);

    frxReport_Label.ShowReport;


    The problem still is:

    Set in printer driver: papersize to A4 fanfold 210 mm x 11 2/3 in

    So the settings below are correct when I open the properties page when I want to print.

    But when I just did a print job and want to print again, the properties are

    The Letter size is not correct for this printer, so it fails.

    The paper size was never changed by me in code.

  • Can you set format what you need in the FR Designer? What result did you get when print this report?

  • I am not able to set the correct paper size in FR Designer. The needed format is not available.

    I tried below code to get all paper sizes and set frxReportPage.PaperSize to the right index, but without any success.


    // GetPaperInfo

    // ---------------------------------------------------------------------------------------------------------------------

    procedure TFMain_Settings.GetPaperInfo(PrinterName: PWideChar);

    var HPrinter: THandle;

       Forms: Array of TFormInfo1;

       Count, Needed, Returned: DWORD;

       Counter: Integer;

       ListItem: TListItem;

    begin

     ListView_Printers_Papers.Items.Clear;

     If OpenPrinter(PrinterName, HPrinter, Nil)

      Then Begin

            try

             If Not EnumForms(HPrinter, 1, Nil, 0, Needed, Returned)

              Then Begin

                    If GetLastError <> ERROR_INSUFFICIENT_BUFFER

                     Then RaiseLastOSError;

                    Count := (Needed div SizeOf(TFormInfo1)) +1;

                    SetLength(Forms, Count);

                    If EnumForms(HPrinter, 1, @Forms[0], SizeOf(TFormInfo1) * Count, Needed, Returned)

                     Then Begin

                           If Returned < Count

                            Then SetLength(Forms, Returned +1);

                           For Counter := 0 to Returned -1 do

                            Begin

                             ListItem := ListView_Printers_Papers.Items.Add;

                             ListItem.Caption := IntToStr(Counter);

                             ListItem.ImageIndex := -1;

                             ListItem.Checked := False;

                             ListItem.SubItems.Add(WideCharToString(Forms[Counter].pName));

                             ListItem.SubItems.Add(Format('%dmm x %dmm', [Forms[Counter]. Size.cx div 1000, Forms[Counter].Size.cy div 1000]));

                            End;

                          End

                     Else RaiseLastOSError;

                    SetLength(Forms, 0);

                   End;

            finally

              ClosePrinter(HPrinter);

            end;

           End

      Else

       RaiseLastOSError;

    end;

  • Did you set your printer in the report settings before set paper size?

  • It is already going wrong within the Preview screen.

    Procedure is:

    • Preview is on screen
    • Press the printer button
    • In Printer dialog press the Settings button
    • Properties of the printer are:
    • Click Ok button and print the page.
    • Again press the printer button in the Preview screen, the Preview was never closed.
    • In Printer dialog press the Settings button
    • Properties of the printer are

    What/Who changed the Paper Size?

    Now I have to manualy correct the paper size. This is not what I want to do.

  • Below the solution:

    frxReport.PrintOptions.PrintMode := pmScale;

    frxReport.PrintOptions.PrintOnSheet := 186 // right index of TFormInfo1 (in my case A4 fanfold 210 mm x 11 2/3 in)


    If frxReport.PrepareReport

     Then frxReport.ShowPreparedReport;

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.