Batch merging & bookmarking

This Forum is for the use of Clarion For Windows - Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software, Tracker - Clarion Support, John - Tracker Supp, Support Staff, moderators

Post Reply
marisoft
User
Posts: 57
Joined: Sat Nov 12, 2005 3:39 pm
Contact:

Batch merging & bookmarking

Post by marisoft » Sat Dec 30, 2006 10:28 am

Hi,

I would like to run a batch job converting a number of word-files to pdf, merging these and at the same time make bookmarks.
The bookmarls would be two level deep with the text provided by the database that holds the description and filenames of the word docs.

I have looked at using the Office Inside funtionality to do this convertion.

Is this possible ?

Any hints of how I would go about merging and bookmarking ?

Cheers and happy new year,
.::Poul Jensen::.

Clarion developer

Tracker - Clarion Support
Site Admin
Posts: 1412
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA
Contact:

Post by Tracker - Clarion Support » Sat Dec 30, 2006 12:56 pm

Hi Poul!

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

FinalBkMks PDFBookmarkClass
FinalPDF   PDFManagerClass
WorkPDF    PDFManagerClass
PageOffset LONG(0)
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 is written.

After processing all files, call:

Code: Select all

FinalBkMks.AddBookmarksToPDF(FinalPDF) !to add the bookmarks
FinalPDF.WriteDocument(PdfFileName)    ! to save the final PDF file
FinalPDF.Kill()
FinalBkMks.Kill()
At this point run a loop to delete the temporary PDF files and you're done!
Craig Ransom
Tracker Software - Clarion Support
http://www.tracker-software.com

marisoft
User
Posts: 57
Joined: Sat Nov 12, 2005 3:39 pm
Contact:

Post by marisoft » Sat Dec 30, 2006 3:54 pm

Thanks for your reply.

I will have a go at it.

Cheers,
/Poul
.::Poul Jensen::.

Clarion developer

Post Reply

Return to “PDF-XChange Drivers (only) API SDK - For Clarion For Windows Developers only Please”