Create PDF using Template (ActiveX)

The PDF Creator enables you to create secure PDF documents and to view, print and process existing PDF documents.
If you have any questions about the installation and usage of the PDF Creator please post them here.
Post Reply
Bistra
Posts: 4
Joined: Tue May 12 2009

Create PDF using Template (ActiveX)

Post by Bistra »

Hallo,

I am using PDF Creator for ActiveX in Progress. I want to generate a pdf file that uses Template of two pages. Is it possible when repeating the Template after the second page, to choose which page of the Template to repeat? For my case I want only the second template page to be repeated. Or is it possible to load two different Templates in one file?

I encountered a problem when I used Template file. On each page the pdf Template resets the my initial page settings ( page margins and fond name), of my forground file, so I have to initialaze them on each page. How to solve this problem?

Regards,
Bistra
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Re: Create PDF using Template (ActiveX)

Post by Joan »

Hello,

After creating the template pdf file, you can treat it as any other pdf file.
You can duplicate any page you want from the pdf file any number of times.
You can append two or more templates to form 1 large PDF by example you can have 1 pdf file containing the two pages and another pdf file containing the second page only and append the second pdf to the first one.

You should be able to initialize the settings for all the document, if you are using an old version of the PDF Creator please user our latest version 3.03e or our newest release 4.0
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Bistra
Posts: 4
Joined: Tue May 12 2009

Re: Create PDF using Template (ActiveX)

Post by Bistra »

Hallo,

Thank you for your response.
I am using the latest vertion of PDF Creator - 4.0.
Could you give me an example how to duplicate page of file, how to append new file and while the file are open to write some text on it ?
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Re: Create PDF using Template (ActiveX)

Post by Joan »

Hello,

To duplicate a page you need to use acCommandToolDuplicatePage. This duplicates the current page of the document.

Code: Select all

This VB 6 sample duplicates the first page of the opened document and store it at the end of the document
PDFCreactiveX1 is the PDF Creator oject added to the VB form.

With PDFCreactiveX1
     .SetLicenseKey Licensee, ActivationCode
     .OpenEx DocumentName, ""
     .DoCommandTool acCommandToolDuplicatePage
     .Refresh     
End With
To Append two pdf files you can use the Append or AppendEx functions

Code: Select all

VB 6 sapmle that use the PDF Craetor added to VB form to append two pdf files

With PDFCreactiveX1
    .OpenEx App.Path & "\source files\" & "View.pdf", ""
    .Append App.Path & "\source files\" & "Picture.pdf", ""
    .Refresh
    .Save App.Path & "\Append.pdf", 0
End With
Here is a VB sample that opens an existing pdf file and text and picture to it

Code: Select all

Dim CreatorRef As New ACPDFCREACTIVEX.PDFCreactiveX   ' CreactiveX object 

With CreatorRef

    'Open a 2 pages pdf file 
    .Open App.Path & "\TestFile.pdf", ""
    ' Set report state to design mode
    ' NEVER CHANGE THE MODE USING .ReportState = acReportStateRun
    .DoCommandTool acCommandToolDesignMode
           
    'Create a Text on the second page
    .CreateObject acObjectTypeText, "Page2"
    
    ' get a reference to the object that we just created
    Set obj = .GetObjectByName("Page2")
    If obj Is Nothing Then
        MsgBox "Unable to find object"
        Exit Sub
    End If
    
    'Position the text
    With obj
        .Attribute("Left") = 400
        .Attribute("Top") = 1500
        .Attribute("Right") = 800
        .Attribute("Bottom") = 1500
        .Attribute("Text") = "Page 2"
    End With
     
    'Add a third page to the document
    .AddPage (3)
    
    'Create a Text on third page
    .CreateObject acObjectTypeText, "Page3"
    
    ' get a reference to the object that we just created
    Set obj = .GetObjectByName("Page3")
    If obj Is Nothing Then
        MsgBox "Unable to find object"
        Exit Sub
    End If
    
    'Position the text
    With obj
        .Attribute("Left") = 400
        .Attribute("Top") = 1500
        .Attribute("Right") = 800
        .Attribute("Bottom") = 1500
        .Attribute("Text") = "Page 3"
        
    End With
  
    ' compile the document and switch to Run mode
    .DoCommandTool acCommandToolRunDocument
 
   .Save App.Path & "\EditedDocument.pdf", 0
End With
Please note that to make these samples run you need to have the PDF Creator control added to your application an initialized.

For more sample applications and more information on installing and using the PDF Creator please feel free to check our Developers' manual "PDF Creator Developer Manual.pdf" that you received with the product.
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Bistra
Posts: 4
Joined: Tue May 12 2009

Re: Create PDF using Template (ActiveX)

Post by Bistra »

Hello again.

I tried everything i could find or think about, but i did not succeed in using a simple template on multiple pages.

Again i'll explain the scenario.

I have 1 template PDF document which contains 1 page.

I create now a new pdf document and i want to do:
1) import the template pdf as a background
2) create texts on that page
3) create page 2
4) import again the same template document as background (for page 2)
5) Create tests on page 2
6) ...[repeat this unlimited times]

I have read about the attribute TemplateRepeat and i would expect that every time i create a new empty page, that the template would be loaded autom. as background. However this option does nothing.

Below i'll give the very small example that i created. The language is PROGRESS, however it is very similar to VB.

The result of this program is that on page 1 i have the template document as a background, but on page 2 not.

DEF VAR chPdf AS COM-HANDLE NO-UNDO.

DEFINE VARIABLE vLicense AS CHARACTER NO-UNDO.
DEFINE VARIABLE vActivationCode AS CHARACTER NO-UNDO.
DEFINE VARIABLE vId AS INTEGER NO-UNDO.


ASSIGN vLicense = "xxx"
vActivationCode = "xxx".

RELEASE OBJECT chPdf NO-ERROR.
ASSIGN chPdf = ?.

CREATE "PDFCreactiveX.PDFCreactiveX" chPdf NO-ERROR.
IF ERROR-STATUS:ERROR
THEN DO:
MESSAGE "The 'PDFCreActiveX.dll' is not installed"
VIEW-AS ALERT-BOX INFO BUTTON OK.
RETURN "".
END.

chPdf:SetLicenseKey(vLicense,vActivationCode).

chPdf:InitBlank.


chPdf:OPEN("C:\Templates\VIES.pdf","").
chPdf:TemplateMode = 1.
chPdf:TemplateRepeat = 1.

chPdf:CreateObject(5, vId).
chPdf:ObjectAttribute(vId, "Left") = 50.
chPdf:ObjectAttribute(vId, "Right") = 400.
chPdf:ObjectAttribute(vId, "Top") = 200.
chPdf:ObjectAttribute(vId, "Text") = "This is my text".


chPdf:AddPage(chPdf:PageCount + 1).

chPdf:CreateObject(5, vId).
chPdf:ObjectAttribute(vId, "Left") = 50.
chPdf:ObjectAttribute(vId, "Right") = 400.
chPdf:ObjectAttribute(vId, "Top") = 200.
chPdf:ObjectAttribute(vId, "Text") = "This is my text on page 2".


chPdf:Save ("c:\temp\test.pdf", 0 /* acFileSaveAll */ ).
Bistra
Posts: 4
Joined: Tue May 12 2009

Re: Create PDF using Template (ActiveX)

Post by Bistra »

Can someone from Amyuni give an answer, please?
Post Reply