1. Jhonns Salas
  2. PowerBuilder
  3. Wednesday, 21 April 2021 18:19 PM UTC

Hello,

I am having a problem when creating multiple PDF reports,

I have to print a lot of reports using a composite datawindow,

then i decided use the function save as , using a system produced filename,

when i use this file name the saveas function returns error (-1).

but if i use the user selected the saveas function is working correctly.

Do you know how correct this problem?

Example:

This code below is working:

String ls_edi_pathname, ls_edi_filename

Integer li_rslt

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

dw_print.Object.DataWindow.Export.PDF.Method = NativePDF!

dw_print.Object.DataWindow.Export.PDF.NativePDF.PDFStandard = '1'   //PDF/A-1a

dw_print.Object.DataWindow.Print.Orientation = '0'

dw_print.Object.DataWindow.Print.Paper.Size = '1'

 

ls_edi_filename = is_def_filename

li_rsLt = GetFileSaveName("Export as PDF file" , ls_edi_pathname, ls_edi_filename, "PDF" ,  "PDF Files (*.PDF),*.PDF", "", 8194)

IF li_rsLt = 1 THEN

 IF dw_print.SaveAs(ls_edi_pathname, PDF!, False) = -1 THEN

    MessageBox("Attention", "Saving as PDF was cancelled")

  END IF

END IF

This code below is Not working:

ls_edi_pathname = "C:\reports\EDIdocument.PDF"

dw_print.SaveAs(ls_edi_pathname, PDF!, False) =

 

Thanks,

 

Yiannis Papadomichelakis Accepted Answer Pending Moderation
  1. Tuesday, 11 May 2021 12:48 PM UTC
  2. PowerBuilder
  3. # 1

Why not using SaveNativePDFToBlob() to obtain the PBF in a blob variable and then use FileOpen() / FileWrite()  funtions?

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Thursday, 22 April 2021 15:05 PM UTC
  2. PowerBuilder
  3. # 2

Work-around:  If the SAVEAS works under Ghostscript and not using NativePDF, then perhaps you need to return to using Ghostscript until this NativePDF! issue can be resolved.


Olan

 

Comment
There are no comments made yet.
Kai Zhao @Appeon Accepted Answer Pending Moderation
  1. Thursday, 22 April 2021 06:11 AM UTC
  2. PowerBuilder
  3. # 3

Hi Jhoons,

Is the following code that does not work complete code?
ls_edi_pathname = "C:\reports\EDIdocument.PDF"

dw_print.SaveAs(ls_edi_pathname, PDF!, False)

If this is already the complete code, then you need to add the following code to make sure this Datawindow uses NativePDF to export PDF files.
dw_print.Object.DataWindow.Export.PDF.Method = NativePDF!


BTW, in PB 2019 R2 and later versions, newly added Datawindows use the NativePDF! (using PDFLib) method by default when you use the SaveAs method with PDF! as the file type.

But for existing DataWindows which are kept the same as before to use the Distill!, if you don’t have the GhostScript printer installed on your machine, they will fail to be exported. You can find more detailed information on this in the link below:
https://docs.appeon.com/pb2019r2/whats_new/ch01s09.html

You can also refer to this link below to set your application to Always use the NativePDF! method for PDF export.
https://docs.appeon.com/pb2019r3/pbug/ch06s02.html#Saving_as_PDF_using_PDFlib

Regards,
ZhaoKai

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 21 April 2021 20:19 PM UTC
  2. PowerBuilder
  3. # 4

Perhaps the DW's are not set to use the NativePDF export method by default?

Try setting the Export.PDF.Method = NativePDF! in the "not working" script, along with any other NativePDF settings you want to ensure are set correctly before generating the PDF output.

Comment
  1. Olan Knight
  2. Wednesday, 21 April 2021 21:57 PM UTC
Also, there a NativePDF setting in the application object that you need to set.

Click on the ADDITIONAL PROPERTIES and check out the last tabpage "PDF Export".

  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.