Yes, I think that this is quite doable, but will involve some hand-coding to achieve.
For example, I have 3 files to be assembled: a.doc having 7 pages, b.doc having 10 pages, and c.doc having 5 pages. Within the final PDF, a.doc will occupy pages 1-7; b.doc pages 8-17; and c.doc pages 18-22. It's these PDF page numbers that your Bookmarks need to reference. If your intention is to have Bookmark point to the first page of each group, this is simple to achieve.
Bookmarks must be assigned by page number. We handle that using an object of the PDFBookmarkClass
. This should be set up using FinalBkMks.Init()
before the batch loop. Also create two objects of the PDFManagerClass
; one to be used hold the final document, and a second to process the individual temp PDFs. For example:
Code: Select all
Within your loop, you will generate a PDF file for each Word document using the PDF-XChange Driver OI
interface. PxcWOI.app shows how to do this. The critical thing here is to wait for the EVENT:PDF3DRV_DocSaved
which signals that the PDF-XChange Driver processing is complete.
Once you have the PDF file, call WorkPDF.Init()
and then WorkPDF.ReadDocument()
to open the saved PDF. Use FinalBkMks.AddBookmarkRecord(STRING pTitle, LONG pPageNo, LONG pLevel)
to add your Bookmarks based on your database information, adjusting any page numbers from the db to reflect the page position in the FinalPDF. pTitle
holds the text string for the Bookmark, and pLevel
contains the bookmark level starting with 1. Then use the WorkPDF.PagesNumber()
method to return the page count for that PDF, and add it to your PageOffset to adjust the page numbers of the next PDF. Finally use FinalPDF.Merge(WorkPDF)
. Called with only the WorkPDF
parameter, this will append all pages from WorkPDF
to the end of FinalPDF
. At this point you should call WorkPDF.Kill() to close the input PDF, but do NOT delete the temporary PDF file at this point! Save the names of these files in a list to be deleted after the FinalPDF
After processing all files, call:
Code: Select all
FinalBkMks.AddBookmarksToPDF(FinalPDF) !to add the bookmarks
FinalPDF.WriteDocument(PdfFileName) ! to save the final PDF file
At this point run a loop to delete the temporary PDF files and you're done!