1. Daniel Kervabon
  2. PowerBuilder
  3. Thursday, 3 March 2022 18:05 PM UTC

I've recently migrated one of my company's applications from PowerBuilder 2017 R3 to PowerBuilder 2021 (Professional Edition) and we want to eliminate the need for having Ghostscript installed to export PDF files. On the PDF Export tab of the Application objects Additional Properties dialog I checked "Always use NativePDF! method for PDF Export" but the PDF files are save in 8.25" x 11.7" (approx.) instead of 8.5" x 11". The DataWindows are all defined as "Letter 8 1/2 in x 11 in" so I don't know why this is happening. I've looked in the Community for an answer but didn't find anything helpful.

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 3 March 2022 18:47 PM UTC
  2. PowerBuilder
  3. # Permalink

Armeen is correct. The default paper size for the NativePDF driver is A4.


https://docs.appeon.com/pb2021/datawindow_reference/XREF_36021_Alphabetical_list.html#XREF_19761_Export_PDF_NativePDF_CustomSize

You might want to consider using the UsePrintSpec option:


https://docs.appeon.com/pb2021/datawindow_reference/XREF_36021_Alphabetical_list.html#XREF_19761_Export_PDF_NativePDF_UsePrintSpec

When we switched our commercial application to use NativePDF instead of GhostScript, we made some changes to our ancestor DW control to properly configure the various Export.Data.NativePDF.xxxx options automatically. Something you might wish to consider.

Regards, John

Comment
There are no comments made yet.
Daniel Kervabon Accepted Answer Pending Moderation
  1. Thursday, 3 March 2022 23:22 PM UTC
  2. PowerBuilder
  3. # 1

Thanks to all of you for your help. It works now by setting dw_1.Object.DataWindow.Print.Paper.Size = 1

I don't need to do something for every report as we have a report viewer window.

There is also other valuable information found in the links provided by John Fauss.

Comment
There are no comments made yet.
Daniel Kervabon Accepted Answer Pending Moderation
  1. Thursday, 3 March 2022 18:36 PM UTC
  2. PowerBuilder
  3. # 2

Hello Armeen, thanks for the quick response.

In the DataWindows we have the Paper Size set as shown here. Do we need to do more than that?

We have over a hundred reports in one of our applications and I would hate to have add code for each one.

Daniel

 

Comment
  1. Armeen Mazda @Appeon
  2. Thursday, 3 March 2022 18:56 PM UTC
I believe you need to explicitly set the NativePDF size and these settings apply when printing to real printer (and GhostScript because it emulates a printer). NativePDF is natively generating PDF not using printer approach that GhostScript does.
  1. Helpful 1
  1. Ronnie Po
  2. Thursday, 3 March 2022 18:58 PM UTC
You'll also need to set

dw_control.Object.DataWindow.Export.PDF.NativePDF.UsePrintSpec='Yes'

If the value = 'Yes', then the export process will use the values specified in the DW painter. (I don't know why the two sets of paper sizes weren't integrated behind the scenes to keep things seamless to the developer).



If 'No', then the export process will use the value of the property

dw_control.Object.DataWindow.Export.PDF.NativePDF.CustomSize



The values for CustomSize are different from the traditional values in the DW painter. The default paper size is also different.

  1. Helpful 3
  1. Chris Pollach @Appeon
  2. Thursday, 3 March 2022 19:55 PM UTC
Hi Ronnie;

Yes, that's the key one IMHO ...

dw_control.Object.DataWindow.Export.PDF.NativePDF.UsePrintSpec='Yes'

Regards ... Chris
  1. Helpful 1
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Thursday, 3 March 2022 18:11 PM UTC
  2. PowerBuilder
  3. # 3

Did you set the paper size for the PDF: dw_1.Object.DataWindow.Print.Paper.Size = 1 

Here is the relevant documentation: https://docs.appeon.com/pb2021/pbug/ug16818.html#Saving_as_PDF_using_PDFlib

 

 

Comment
  1. Daniel Vivier
  2. Thursday, 3 March 2022 18:44 PM UTC
In our experience also setting dw.Object.DataWindow.Export.PDF.NativePDF.UsePrintSpec = 'Yes' was important to make this work, in addition to the Paper.Size setting Armeen gave. You would just set those in some common code for saving to PDF.
  1. Helpful 1
  1. Roland Smith
  2. Thursday, 3 March 2022 19:25 PM UTC
Does this also apply to SaveNativePDFToBlob?
  1. Helpful
  1. Roland Smith
  2. Thursday, 3 March 2022 19:27 PM UTC
If we use UsePrintSpec = 'Yes', what happens if the paper size in the datawindow is default? Should we get that value and change it to 1 if it is 0?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.