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!
![]() |
template |
Post Reply
|
| Author | |
eborger
Team Player
Joined: 29 Apr 09 Location: Brazil Status: Offline Points: 35 |
Post Options
Thanks(0)
Quote Reply
Topic: templatePosted: 19 Jan 11 at 8:50PM |
|
Hi,
I want to use a previously created pdf as a "template", but I don't know the number of pages the final pdf is going to be, I have an empty invoice that I want to use as template, so I want to create a new document, add a page, fill it with the template, and then add data, and do this for as many pages as I want. Is there an easy way of doing it ? I am trying with capturepage/drawcapturedpage, but it is not working, any hints ? this is basicaly what I am doing : "SaveToFile", "tmpfile.pdf" "LoadFromFile", "template.pdf" "CombineLayers" "NewPage" capt := "CapturePage", 1 "LoadFromFile", "tmpfile.pdf" "NewPage" "DrawCapturedPage", capt thank you, Edgar
|
|
![]() |
|
darkv
Team Player
Joined: 17 Jan 11 Status: Offline Points: 38 |
Post Options
Thanks(0)
Quote Reply
Posted: 19 Jan 11 at 10:56PM |
|
Edgar,
I've done the same with a blank template file (where after treatment i add page numbering) 1) what i've done is : loadfile blank template fill in with data until page is full, When page is full call new page and fill it again once no more data to write, i use an internal page counter to add page numbering and then Savetofile it works perfectly to generate a logfile report for roughly 3000 lines 2) Other way should be to previously calculate the number of pages you will need, use clonepages and fill in Hope this helps, if you need i can post part of my code (vb.net) Rgds Eric |
|
![]() |
|
Dimitry
Team Player
Joined: 18 Feb 10 Status: Offline Points: 37 |
Post Options
Thanks(0)
Quote Reply
Posted: 21 Jan 11 at 10:59PM |
|
Hi Edgar,
Let me share several helping functions that allow to manage such a template documents.
function CreateDocumentTemplate(QPL: TQuickPDF;
PageRangeList: AnsiString): AnsiString; var tempdoc, olddoc: Integer; begin with QPL do begin olddoc := SelectedDocument; tempdoc := NewDocument; CopyPageRanges(olddoc, PageRangeList); DeletePages(1, 1); Result := SaveToString; RemoveDocument(tempdoc); SelectDocument(olddoc); end; end; procedure MergeDocumentTemplate(QPL: TQuickPDF;
DocumentTemplate: AnsiString); var tempdoc, olddoc: Integer; begin with QPL do begin olddoc := SelectedDocument; LoadFromString(DocumentTemplate); tempdoc := SelectedDocument; SelectDocument(olddoc); MergeDocument(tempdoc); end; end; procedure SaveDocumentTemplate(DocumentTemplate: AnsiString;
FileName: AnsiString); begin with TQuickPDF.Create do try LoadFromString(DocumentTemplate); SaveToFile(FileName); finally Free; end; end; function LoadDocumentTemplate(FileName: AnsiString): AnsiString;
begin with TQuickPDF.Create do try LoadFromFile(FileName); Result := SaveToString; finally Free; end; end; // Some samples of how to use this helping functions
// . . . var
PDFLibrary: TQuickPDF; doctemplate: AnsiString;
// . . . // Create PDFLibrary instance and load some PDF
// . . . // Lets make some template from pages defined in PageRangeListEdit: TEdit;
doctemplate := CreateDocumentTemplate(PDFLibrary, PageRangeListEdit.Text);
// . . .
// Here template is merged to the currently selected document of PDFLibrary
MergeDocumentTemplate(PDFLibrary, doctemplate);
// . . .
// Save template as PDF file
with TSaveDialog.Create(nil) do
try if not Execute then Exit; DefaultExt := '.pdf'; SaveDocumentTemplate(doctemplate, FileName); finally Free; end; // . . .
// Load template from some PDF file
with TOpenDialog.Create(nil) do
try if not Execute then Exit; DefaultExt := '.pdf'; doctemplate := LoadDocumentTemplate(FileName); finally Free; end; |
|
|
Regards,
Dmitry |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store