How to sinchronize page properties with PageLayout dlg

  • No information found in the pdf manual and the forum, so here is my question.
    I use the following code to setup the page properties of the viewed document.

    Code
    WPRichText1.PaperDefs.Init(true); // Needed for page setup dialog!
      WPRichText1.ReadPrinterProperties;
      WPRichText1.Header.Landscape := False;
      WPRichText1.Header.PageSize := wp_DinA4;
      WPRichText1.Header.UsedUnit := UnitCm;



    My actual printer supports those parameters, but when I click on the File->Setup Page menu item, the paper size and units are not the same, so how can I sinchronize my page setup with the dialog.

  • I do not understand your response, if I initialize the Header with the code explained before, and you say that the page dialog reads from the header, why the page dialog parameters shown does not correspond to what I setup in the Header.

    • Offizieller Beitrag

    I tested it like this:

    Code
    WPRichText1.PaperDefs.Init(true);   WPRichText1.ReadPrinterProperties;
      WPRichText1.Header.Landscape := False;
      WPRichText1.Header.PageSize := wp_DinA5;
      WPRichText1.Header.UsedUnit := UnitCm;
      WPPagePropDlg1.EditBox := WPRichText1;
      WPPagePropDlg1.Execute;

    I see "A5" in the dialog, as expected.

    Maybe your dialog is connected to a different editor ?

  • There is some differences if you call the PageSetup dialog by code or use the menu File -> Page Settings, but in all cases, some parameters are not set. I will explain:

    Using your code, and executing the PageSetup dialog by code, here is how I connect the components:

    Code
    mWPDefaultActions := TWPDefAct.Create(Self);
    WPRichText1.PaperDefs.Init(true);
    WPRichText1.ReadPrinterProperties;
    WPRichText1.Header.Landscape := False;
    WPRichText1.Header.PageSize := wp_DinA5;
    WPRichText1.Header.UsedUnit := UnitCm;
    mWPDefaultActions.WPPagePropDlg1.EditBox := WPRichText1;
    mWPDefaultActions.WPPagePropDlg1.Execute;

    Using this code, I can see the PageSize changed in the PageSetup dialog, but not the UsedUnit, that continues to be inches.

    If in Form_Load I setup all the code above, except WPPagePropDlg1.Execute and I call File -> Page Settings menu, then PageSize nor UsedUnit are changed in the PAgeSetup dialog.

    • Offizieller Beitrag

    UsedUnit will not change the display in the page setup dialog. The "valueEdit" in this dialog is using the global unit GlobalValueUnit,

    you can initialize it in Form.OnCreate
    GlobalValueUnit := euCm

    (requires unit WPUtils)

    -

    I don't know which code is executed in
    "menu File -> Page Settings".

    If you have problems with dialogs or the toolbar does not show the current attributes please make sure the wprichtext got the focus - in Form.OnShow a WPRichText1.SetFocus is sufficient.