how to save objects in PDF so they can be read by VB?

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
urbanfox
Posts: 5
Joined: Wed Nov 17 2004

how to save objects in PDF so they can be read by VB?

Post by urbanfox »

This is a real newbie question but I'm really stuck and would appreciate some help!

I'm having a problem reading in objects which were created using PDF Creator. I tried creating a sample of every kind of object and saving the PDF, then reading it in using VB. I'm using the demo version of PDFCreator.

This is the code snippet to read it in:

Code: Select all

    
    Set objamyuni = CreateObject("PDFCreactiveX.PDFCreactiveX")
    ' Open Amyuni template for writing
    With objamyuni
        .SetLicenseKey LicenseTo, ActivationCode
        .ReportState = acReportStateDesign
        .Open "c:\docmaker\templates\AST-GLCert-AST.pdf", ""
    End With

    ' Read all objects and output their name
    Dim objArray As Variant
    Dim obj As Variant

    objArray = objamyuni.ObjectAttribute("Pages[1]", "Objects")
    For Each obj In objArray
        Call DebugTextBox("object in array")
    Next

It is not reading in any objects at all.
If I add this code snipped to create a new object on the same PDF "on the fly", it does read that one in.

Code: Select all

    ' Create a dummy text object
    With objamyuni
        .CreateObject acObjectTypeText, "Frame 1"
        .ObjectAttribute("Frame 1", "Left") = 200
        .ObjectAttribute("Frame 1", "Top") = 200
        .ObjectAttribute("Frame 1", "Right") = 600
        .ObjectAttribute("Frame 1", "Bottom") = 400
    End With
If I go on to save that PDF including the dummy object I just created, it appears on the saved PDF along with the objects that were originally there.

How should I be creating/saving the objects on the PDF in order for them to be visible to VB? Or should I be reading them in some different way?
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

I noticed that you are using in your code:

Code: Select all

.ReportState = acReportStateDesign 
You need to use instead:

Code: Select all

.DoCommandTool acCommandToolDesignMode   ' Set the document in Design mode
or
.DoCommandTool acCommandToolRunDocument   'Set the document in Run mode
Because in version 1.5 ReportState is a read only attribute of the Document object. Please note that in version 2 of the Creator ReportState will be a Read/Write attribute and you can use it to set the Document state.

When creating objects in a pdf document you need to save the document in View and Design mode so when opening the document again you can get the objects and still you can see the pdf document properly in Acrobat Reader.

If you are still facing problems please send us the document you are trying to open and get the objects from to support@amyuni.com so we can check it closely.

Hope this helps
Post Reply