1. Marc James
  2. PowerBuilder
  3. Friday, 24 April 2020 14:44 PM UTC

I am saving a PDF from a DataWindow.

The DataWindow just views a JPG image from a string field path.

The image is A5 in size, and is roughly 165 KB, I am putting it into the top left of my A4 landscape DataWindow.

I then just do the following code

dw_pod.DataObject = 'd_pod_landscape'
dw_pod.SetTransObject(sqlca)
dw_pod.Modify("DataWindow.Print.Preview = Yes")
dw_pod.Retrieve(ll_ticket)
ls_filename = ls_savepathinv + '\' + string(ll_ticket) + '.pdf'
dw_pod.SaveAs(ls_filename, PDF!, FALSE)
FileCopy ( ls_filename , ls_savepathinv , TRUE )

This gives me a PDF, but instead of being of similar size (less than 200 KB) it saves it as 1,198 KB !!!!

Does anyone have any ideas of why it may be doing this?

I've attached the 2 files

Thanks

Attachments (2)
Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Friday, 24 April 2020 17:50 PM UTC
  2. PowerBuilder
  3. # Permalink

Greetings, Marc -

Some of the default Export.PDF.NativePDF settings are not optimal in some cases. In this case, if you do not override the default ImageFormat setting from '0' (BMP) to '1' (JPG), the JPG will be converted to a bitmap and (not surprisingly) the size of the PDF will explode.

Try:

dw_1.Object.DataWindow.Export.PDF.NativePDF.ImageFormat='1' 

or

dw_1.Modify("DataWindow.Export.PDF.NativePDF.ImageFormat='1')

I suggest all PB developers utilizing the NativePDF feature familiarize yourself with the available configuration settings and options. One place to look is in the PB Help under "Export.PDF.NativePDF".

Regards, John

Comment
  1. Marc James
  2. Sunday, 26 April 2020 10:24 AM UTC
That's perfect, just added the following and it's taken it to a similar size.



dw_pod.Modify("DataWindow.Export.PDF.NativePDF.ImageFormat = '1'")

dw_pod.SaveAs(ls_filename, PDF!, FALSE)



Have been and familiarised myself with all properties for Export.PDF.NativePDF now in the help too :-)
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.