Greetings!
Background, I'm using an older version of QuickPDF 8.12 with PowerBasic and have been trying to upgrade since Christmas but had difficulties. I am presently in contact with FoxIt and hope to be able to upgrade before too long, if for no other reason than fixing a problem where the HTML commands hang. (I held out as long as I could just because it is a pain to recreate the PowerBasic include files!)
Onward, here what I trying to accomplish in the form of an example:
Page 1 - Original content created by QuickPDF (text, graphics, etc.) - No problems here. Page 2 and 3 - Embed / capture an external PDF and add my footers to both pages
Page 4+ - Original content continues
Now I've used QuickPDF on a few little projects and have been able to create content without major problems. I respectably fluent in the GDI and GDI+ and have written to the screen / graphics and printers for years. (Well, decades but don't tell anyone!)
The embedding is the problem. The technique that I've been trying has been to using this psudo-code. Assume no errors returned unless otherwise stated: - newDocumentID = selectedDocument()
- loadFromFile("new1.pdf") // No error. Per docs, the loaded file is selected
- pages = pageCount() // correctly returns 2 pages
- create a newPage() // per docs: "document must have at least one page at all times...add new blank page before existing page can be captured"
- importDocumentID = selectedDocument()
- selectDocument ( importDocumentID ) // yes, redundant for page one
- capturedID = capturePage ( pageNumber = 1 ) // capture page 1 of 3, returns non-zero value
- selectDocument ( newDocumentID) // go back to the original document being created
- newPage() // create a blank page for page 1 of new.pdf to be drawn
- drawCapturedPage ( capturedID ) // result = 0 and nothing is drawn
- Repeat loop for the second page where pageNumber = 2 and pageNumber = 3
- new() // create the next page and resume generating content
This technique doesn't work because I just get a 0 for the result of drawCapturedPage () every time.This seems, to me, to be the cleanest most direct method, to process one file at a time as it comes up, especially since there will end up being more than one pdf to "include", such as new2.pdf, new3.pdf and so forth.
I also think that this is the correct method because I have made drawCapturedPage work when I preload a documents to import before generating any content. Here's what I do at the beginning:
- establish arrays to hold documentID( file ) and capturedPages( file, page )
- loadFromFile ( file1 )
- newPage ()
- documentID ( 1 ) = selectedDocument ()
- capturedPages ( 1, 1 ) = capturePage ( 1 )
- capturedPages ( 1, 2 ) = capturePage ( 2 )
- loadFromFile ( file2 )
- newPage ()
- documentID ( 2 ) = selectedDocument ()
- capturedPages ( 2, 1 ) = capturePage ( 1 )
- capturedPages ( 2, 2 ) = capturePage ( 2 )
I can confirm the array management is correct. The following is an excerpt from my log file:
Preload 1:[.\GROUT2.pdf] = 1476395010 ::: Pg 1> 1476395011 Preload 2:[.\GROUP3.pdf] = 1476395012 ::: Pg 1> 1476395013 Start new file Embed fonts Process row heights Generating output Draw 1:[.\GROUT2.pdf] = 1476395010 ::: Pg 1> 1476395011/0 Draw 2:[.\GROUP3.pdf] = 1476395012 ::: Pg 1> 1476395013/1
1476395010 is documentID(1) and 1476395011 is capturedPages ( 1, 1 ) /0 means drawCapturedPage failed
1476395012 is documentID(2) and 1476395013 is capturedPages ( 2, 1 ) /1 means drawCapturedPage worked
And the results mirror the result code. Document 1 will not drawCapturePaged() while Document 2 is draws exactly as expected and I'm able to overlay text on top. Works perfectly!
So, one fundamental question. Can more than one PDF be loaded at a time? It would seem that it is possible since the getDocumentID () function has an index which would suggest this.
I have not found a way to validate whether the handle for a document is valid but since I have not called removeDocument(), I would assume it is still valid.
Also, I realize that I have not taken into consideration the typefaces uses in the PDFs that I am bringing in. I see the findFonts() function is where I need to start but I've got to figure out what to do next with that.
Anyhow, I am sorry for this being long but my goal is to be thorough. Any input, thoughts or experience would be greatly appreciated!
Cowboy
Edited: corrected "/0" to "/1 means drawCapturedPage worked"
|