1. Roy Bungert
  2. PowerBuilder
  3. Wednesday, 3 July 2024 11:02 AM UTC

Hello,

I want to attach an existing XML-file to an existing PDF.

At the moment I do the following and it works:

//////////////////////////////////////////
PDFdocument lpdf_doc
PDFattachment lpdf_attach

lpdf_doc = CREATE PDFdocument
lpdf_attach = CREATE PDFattachment

li_rc = lpdf_doc.importpdf( ls_pdffile )                  // Import existing PDF

li_rc = lpdf_attach.addfile( ls_xmlfile )                  // Read XML

lpdf_doc.attachment = lpdf_attach

li_rc = lpdf_doc.save( ls_pdffile + "tmp" )            // Save as tmp-file


li_rc = FileCopy( ls_pdffile + "tmp", ls_pdffile , TRUE ) // Copy tmp-file-> Originalname
lb = FileDelete( ls_pdffile + "tmp" )                    // Delete tmp-file

DESTROY lpdf_attach
DESTROY lpdf_doc

//////////////////////////////////////////

Bit is there another, 'nicer', way to get this job done? I don't like this FileCopy() and FileDelete(). 

Maybe there's a total other approach?

 

Regards

Roy

 

 

 

Roy Bungert Accepted Answer Pending Moderation
  1. Thursday, 4 July 2024 06:15 AM UTC
  2. PowerBuilder
  3. # 1

Sorry, but I think I already use this classes: li_rc = lpdf_attach.addfile( ls_xmlfile )  But perhaps I use them in wrong way. 

What bothers me is the issue with copying and renaming of the PDF file. For me it seems that I can attach a file to an existing PDF. If I try to save it  I will get an error message. If I save it with another filename it's ok.

 

 

 

 

 

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 3 July 2024 17:23 PM UTC
  2. PowerBuilder
  3. # 2

In PB 2022 R3, there are new PDF classes that can accomplish attaching files to a PDF with basically 1 line of code: https://docs.appeon.com/pb2022r3/objects_and_controls/PDFAttachment_object.html

Comment
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.