Print Page | Close Window

Want to create single PDF from multiple PDFs

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3731
Printed Date: 27 Apr 24 at 11:36PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Want to create single PDF from multiple PDFs
Posted By: mbabcock
Subject: Want to create single PDF from multiple PDFs
Date Posted: 16 Aug 19 at 3:35PM
Source is MySource1.PDF (4 pages) and MySource2.pdf (6 pages).  
I want to create a new PDF using select pages from each of those source files.  When I look at ExtractFilePages, it gives me the impression that it will overwrite with each call (rather than append).  I'm going to test this but I was hoping somebody might steer me in the right direction before I get back to my testing.  

Thanks in advance,
--Mike

btw -- I'm using Visual FoxPro 9 SP2 for this and will be happy to share code to help others who might also be using VFP.



Replies:
Posted By: tfrost
Date Posted: 16 Aug 19 at 9:19PM
You can overlay a captured page from one of your two existing documents onto each new blank page you add to your new document.  There's an example you could adapt and convert to VFP in the sample scripts under Document Manipulation / Overlay...


Posted By: mbabcock
Date Posted: 19 Aug 19 at 8:57PM
Scenario of documents to select (and range within it):
File: MyFile1.PDF, Range: 1  Comment: Invoice
File: MyFile1.PDF, Range: 2-4  Comment: Bill of Lading
File: MyFile2.PDF, Range: 1-3  Comment: Fuel Receipts
File: MyFile2.PDF, Range: 4-5  Comment:  Invoice
File: MyFile3.PDF, Range: 1-2  Comment: Invoice
File: MyFile3.PDF, Range: 3-12  Comment: Bill of Lading

Goal:  collect all of the Invoices into a single PDF.  

I'm wondering if it wouldn't be easier/better to export the file pages into their own PDFs using ExtractFilePagesEx("MyFile1.PDF","","MyTemp1.PDF","1",3)
ExtractFilePagesEx("MyFile2.PDF","","MyTemp2.PDF","4-5",3)
ExtractFilePagesEx("MyFile3.PDF","","MyTemp3.PDF","1-2",3)

...and then use AddToFileList and MergeFileList to take these 3 into the final MyOutput.PDF.

This is all in theory; I haven't yet tried it.  Your thoughts on that approach?


Posted By: mbabcock
Date Posted: 20 Aug 19 at 3:07AM
THIS WORKED!!!!!  I highlighted the QuickPDF lines to show the keys to successfully getting this working:

_screen.oQuickPDF.ClearFileList("MyList")
lcPath = ADDBS(ALLTRIM(_screen.cRepository)) + "temp\"
IF NOT DIRECTORY(lcPath) THEN 
MKDIR (lcPath)
ENDIF 
SELECT tmpSelected
SCAN 
SCATTER NAME loFile 
lcFile = ADDBS(lcPath)+FORCEEXT("File_" + ALLTRIM(STR(tmpSelected.iFileLinkID)) + "_" + ALLTRIM(STR(tmpSelected.iDocLinkID)) + "_" + TTOC(DATETIME(),1) + SYS(2015),'PDF')
_screen.oQuickpdf.ExtractFilePagesEx(ADDBS(ALLTRIM(loFile.cPath))+ALLTRIM(loFile.cfilename),'',lcFile,ALLTRIM(loFile.cRange),3)
_screen.oQuickPDF.AddToFileList("MyList",lcFile)
ENDSCAN
* now put the page outputs from the temp files all into the final PDF
lcFile = lcPath + "MyOutput.pdf"
_screen.oQuickPDF.MergeFileListFast("MyList",lcFile)
LaunchFile(lcFile)
USE IN SELECT('tmpSelected')



Posted By: mbabcock
Date Posted: 20 Aug 19 at 3:13AM
@TFrost -- do you see any drawbacks with my approach instead of the way you described?


Posted By: tfrost
Date Posted: 20 Aug 19 at 5:35PM
If it works and you understand it and document it, those are good criteria for success!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk