Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > General Discussion
  New Posts New Posts RSS Feed - DrawCapturedPage to create PDF w/combined content
  FAQ FAQ  Forum Search   Register Register  Login Login

DrawCapturedPage to create PDF w/combined content

 Post Reply Post Reply
Author
Message
cowboy View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Jun 21
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote cowboy Quote  Post ReplyReply Direct Link To This Post Topic: DrawCapturedPage to create PDF w/combined content
    Posted: 07 Jun 21 at 10:35PM
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()
  • Generate page 1
  • 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"




Edited by cowboy - 08 Jun 21 at 12:05AM
Back to Top
cowboy View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Jun 21
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote cowboy Quote  Post ReplyReply Direct Link To This Post Posted: 07 Jun 21 at 10:47PM
Addendum: I have used the documentCount() function and just verified that the document count increments when file is sent to loadFromFile()

Then I wrote little test piece to get the ID of each by index, select by ID and get each filename and that seems to work fine.

This seems to confirm that I can have more than document in memory.


Addendum 2: I have also swapped the files to eliminate the possibility of a defective PDF file and it is only the last file that processes correctly.


Edited by cowboy - 07 Jun 21 at 11:03PM
Back to Top
cowboy View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Jun 21
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote cowboy Quote  Post ReplyReply Direct Link To This Post Posted: 08 Jun 21 at 8:11PM
Addendum: I was finally able to purchase the upgrade to 18.11 and have the program compiling but I don't see any difference in the includes but the HTMLheight has not given me any problems, so that's progress.

I'm exploring how complicated it would be to generate each page of the PDF as a separate file and try assembling them at the end. I don't know how well that will work in the end but it's something to try.




Back to Top
cowboy View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Jun 21
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote cowboy Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jun 21 at 9:37PM
Well, I mostly have this working, but it is cumbersome.

Basically, I'm generating content on blocks and saving each as a temp file. If there is have original content to create from blank pages, I'll save it as a file. If there are files that need to be imported, I'll load them, draw on it as needed and save each as their own temp files. The process continues until all of the blocks are created then I merge them in order.

On the plus side, bookmarks seem to be retained, so that is good.

Speed really hasn't proven to be an issue. The only disadvantage to all of these files is that is tough keeping track of when new pages must be added because the library creates a blank page on its own and thus I end up with extra pages. Had I written for this from the beginning, it might have been less of a problem.

Anyhow, I submit that as one possible solution in case someone else is running into a similar issue.


Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jun 21 at 9:37PM
Hi Cowboy ;-)

If DrawCapturedPage returns with a 0 then the CapturedID is wrong.
As a hint: After each function call you can insert a LastErrorCode to get a more detailed error code from the call before.
Here a thread that could be helpful for you i hope...
http://www.quickpdf.org/forum/capturepage-then-use-on-newdocument_topic2099.html

Cheers and welcome here,
Ingo

Cheers,
Ingo

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store