Print Page | Close Window

Create a new PDF from N templates

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: General Discussion
Forum Description: Discussion board for Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=235
Printed Date: 10 May 24 at 9:59AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Create a new PDF from N templates
Posted By: jabaltie
Subject: Create a new PDF from N templates
Date Posted: 02 Jan 06 at 12:16PM
I'd like to combine several PDF templates into a new output PDF file.
Each PDF template would ALWAYS contain a single page.

So, this is an algorithm of what's needed:

Create a new, blank , empty Document
For PageNo=1 to nPages
Create Page # PageNo
Add page from template # PageNo
Next
Save Final document, with nPages

How can I do it ? Is it conceptually OK to do it ?




Replies:
Posted By: Ingo
Date Posted: 02 Jan 06 at 4:15PM
Hi!
Why you don't want to merge the complete files?
Here's an easy example how to merge three files to a new one (delphi 5):
. . .
   QP := TiSEDQuickPDF.Create;
    try
       QP.UnlockKey('MyLicenseKey');
       QP.ClearFileList('mfl');
       QP.AddToFileList('mfl', file1);
       QP.AddToFileList('mfl', file2);
       QP.AddToFileList('mfl', file3);
    finally
       QP.MergeFileList('mfl', filenew);
       QP.Free;
       file1 := '';
       file2 := '';
       file3 := '';
       filenew := '';
    end;
. . .



-------------
Cheers,
Ingo



Posted By: jabaltie
Date Posted: 03 Jan 06 at 6:52AM

Tried this upon VBScript :

OPTION EXPLICIT

DIM objMyForm,status

Set objMyForm = WScript.CreateObject("ISED.QUICKPDF")

objMyForm.unlockkey("mykey")
status=objMyForm.ClearFileList("mfl")

But status will always return 0 whereas it should return 1.

Any hint ?



Posted By: Ingo
Date Posted: 03 Jan 06 at 7:00AM
Hi!
You just start and want to clear a filelist which doesn't exist at that moment. So ClearFileList returns with 0 'cause there isn't a filelist.


-------------
Cheers,
Ingo



Posted By: jabaltie
Date Posted: 03 Jan 06 at 7:09AM
Perfect !

Now it's working.

Once more, thank you so much !


Posted By: jabaltie
Date Posted: 03 Jan 06 at 8:12AM
Ops !

Not everything is working...

The problem is that after merging, the List of Fields seems to reflect only the first added PDF file and not all the fields from all of them.

How can I abstract the whole list of fields ?

Should I switch between pages ? I tried it but it didnt work.

The thing is that I need to "see" all of the fields so that I can to a FOR/NEXT replacing their contents by their corresponding values.






Posted By: Ingo
Date Posted: 03 Jan 06 at 9:04AM
Hi!
We had this already...
I think there fields in the several documents with same names... Each name must have a unique name.


-------------
Cheers,
Ingo



Posted By: jabaltie
Date Posted: 03 Jan 06 at 10:43AM
Yeah, I thought about that too.

It's not the case though.

All of the field names are absolute, that is, unique, amongst all of the files.

What if I open a new document, and then add page per page and substitute the fields page per page ?



Posted By: jabaltie
Date Posted: 03 Jan 06 at 11:53AM
Below is a script where I tried to add page per page and substitute field contents page per page. Also merge is done page per page.

Final result ? Blank PDF with N pages.

OPTION EXPLICIT

DIM objPDF,docPDF,docpage,lni

Set OBJPDF = WScript.CreateObject("ISED.QUICKPDF")

WScript.Echo "UnlockKey ",objPDF.unlockkey("mykey")

                          docPDF=OBJPDF.NewDocument()
WScript.Echo "doc id 1 ",docPDF

WScript.Echo "Load File ",OBJPDF.LoadFromFile("TEST.PDF")
                          docpage=objPDF.DocumentID(1)
WScript.Echo "doc id 2 ",docpage

WScript.Echo "field CNT ",objPDF.FormFieldCount

for lni=1 to objPDF.FormFieldCount
    WScript.Echo objPDF.GetFormFieldTitle(lni)
next

WScript.Echo "set form f", objPDF.SetFormFieldValueByTitle("TCOVERBO","X")

WScript.Echo "select doc",objPDF.SelectDocument(docPDF)

WScript.Echo "Merge     ",objPDF.MergeDocument(docpage)

WScript.Echo "save      ",objPDF.SaveToFile("C:\TEMP\TEST.PDF")



What could be wrong ?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk