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
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,
- Site Admin
- Posts: 1412
- Joined: Wed Jun 30, 2004 4:45 pm
- Location: Maryland, USA
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)
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()
Tracker Software - Clarion Support