Question about drawing text unto a pdf

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
EricF
Posts: 5
Joined: Thu Nov 04 2004
Location: Illinois,USA

Question about drawing text unto a pdf

Post by EricF »

Hello,

I am attempting to create a pdf that is composed of a standard form and user data. I am to create the standard form correctly but unable to place the user data on the standard form.

I am using an api call of DrawText and DrawTextEx as the functions to write out the user data. Are these the correct calls to write out the text?

When these functions ask for the device context, I give it the pdf printer.createDC value, is this correct?

Any suggestions would be appreciated.

Eric
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

Are you using the Amyuni PDF Creator to add text to your pdf document?

If you are doing so than you can use the CreateObject() method to create a text object and add it to your document, I am not sure why you are using DrawText.

For more information on using the PDF Creator from inside VB please check our Developers' manual "Common Driver Interface 210.pdf".

I will add here a snipet of code that adds a text to a pdf document.

Code: Select all

Dim CreatorRef As New ACPDFCREACTIVEX.PDFCreactiveX  ' CreactiveX object
Dim obj As New ACPDFCREACTIVEX.acObject       ' acObject object

Private Sub CreateNewFile_Click()

    On Error GoTo report_error
    
With CreatorRef
    
     'Open an existing pdf document
    .Open "C:\Temp\Test.pdf",""

    'SetLicenseKey should be called before using the Creator
    .SetLicenseKey Licensee, ActivationCode

    'Create a text object
    '====================
    
    .CreateObject acObjectTypeText, "text1"
    
    ' get a reference to the object that we just created
    Set obj = .GetObjectByName("text1")
    If obj Is Nothing Then
        MsgBox "Unable to find object"
        Exit Sub
    End If
    
    'Position the text
    With obj
        .Attribute("Left") = 200
        .Attribute("Top") = 600
        .Attribute("Right") = CreatorRef.PageWidth
        .Attribute("Bottom") = 800
        
        'Set the Text attributes (font, bold, italic, underlined)and HorzAlign attributes of text1
        .Attribute("Text") = "Verdana font is supposed to be fully embedded in this file"
        'Set the TextFont attributes (font name, size, bold, italic, underlined)and HorzAlign attributes of text1
        .Attribute("TextFont") = "Verdana,11,700,1,0"
        .Attribute("HorzAlign") = 2  'the text is centered
     
    End With
    
    'Fully Embed the Verdana Font used in object "text1"
    .EmbedFont "Verdana", 2

End If
    
    ' Set the document in Run mode
    .DoCommandTool acCommandToolRunDocument
   
    ' Save the generated file
    .Save "C:\Temp\TestFile.pdf", 0
 
End With
 
    Exit Sub
    
report_error:
    MsgBox Err.Description

End Sub
EricF
Posts: 5
Joined: Thu Nov 04 2004
Location: Illinois,USA

Post by EricF »

What I am doing is using the code available in my project that prints to a printer.

In this case I am using the Amyuni PDF Converter as the printer.
So with my printer has the PDF converter, I am using existing code to drawtext to it, textout to it, so forth. Hope this explains my situation.

Does my License for the Amyuni PDF Converter activate the document object also?

Thanks
Eric
EricF
Posts: 5
Joined: Thu Nov 04 2004
Location: Illinois,USA

Post by EricF »

I attempted another run of tests to see if the printer is working.
It does work slightly.

It does not seem to display the user data on the first page of the printed form. Also I am attempting to concatenate more than one file into a single file but so far it has been unsuccessful.

The Fileoptions that I have set are
'1 no prompt
'2 usefilename
'4 concatenate
'20 Broadcast Messages
'2000 append if existing
FileNameOptionsEx = 1 + 2 + 4 + 20 + 2000

Are these settings correct?

Thanks
Eric
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

I am not sure if you are still facing problems generating pdf documents.

If you do please try to convert the values below from Hexadecimal to Decimal and use them as Decimal in your call to FileNameOptions.

The PDF Creator and PDF Converter are two different products we have if you have a license for the PDF Converter, it can not activate the PDF Creator but it can activate the Document interface of the PDF Converter.

The first page of a document should print fine, as well as the other pages are being printed, we have no special issues related to the first page of a document being printed to the PDF Printer.

If you are still having problems please send an e-mail to support@amyuni.com
Post Reply