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 > I need help - I can help
  New Posts New Posts RSS Feed - template
  FAQ FAQ  Forum Search   Register Register  Login Login

template

 Post Reply Post Reply
Author
Message
eborger View Drop Down
Team Player
Team Player


Joined: 29 Apr 09
Location: Brazil
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote eborger Quote  Post ReplyReply Direct Link To This Post Topic: template
    Posted: 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
Back to Top
darkv View Drop Down
Team Player
Team Player
Avatar

Joined: 17 Jan 11
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote darkv Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Dimitry View Drop Down
Team Player
Team Player


Joined: 18 Feb 10
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dimitry Quote  Post ReplyReply Direct Link To This Post 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
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