Skip to main content
Participant
July 26, 2013
Question

How to add text to a pdf file using Access VBA??

  • July 26, 2013
  • 1 reply
  • 26131 views

I'm down on my hands and knees, begging.  I have 300 files that I want to put a variable string at the top of the first page (centered, or at the right hand side).  I am using Acrobat X and Microsoft Access 2010 and I do have the SDK and have spend over 10 hours so far searching it and the internet in general, for help and still am coming up empty handed. 

I can do the looping and passing variables with my eyes closed, but I cannot get the syntax for the actual opening of the pdf and inserting the string. 

I was trying to modify code I found yesterday that is supposed to add an annotation, but I don't want an annotation, I just want a string of text at the top of page 1. For now, all I want is to be successful at doing ONE file.  Can someone please give me a concrete example of the code I need to use?  Like I said, I'm in begging mode

Public Sub AddText()

    Dim pdDoc As Acrobat.AcroPDDoc
    Dim page As Acrobat.AcroPDPage
    Dim annot As Acrobat.AcroPDAnnot
    Dim jso As Object
    Dim strPath As String
    Dim intpoint(1) As Integer
    Dim intpopupRect(3) As Integer
    Dim props As Object

    Set pdDoc = CreateObject("AcroExch.PDDoc")
    pdDoc.Open ("c:\Test\Test.pdf")
    Set page = pdDoc.AcquirePage(0)
    'Set annot = page.AddAnnot(0)
    intpoint(0) = 0
    intpoint(1) = page.GetSize.y
    intpopupRect(0) = 0
    intpopupRect(1) = page.GetSize.y - 100
    intpopupRect(2) = 200
    intpopupRect(3) = page.GetSize.y
    annot.SetColor (vbRed)
    annot.SetContents "JCPC - 22 - 2011050000001"

    pdDoc.Save 1, "c:\Test\Test.pdf"
    pdDoc.Close
    Set pdDoc = Nothing
    MsgBox "Done"

End Sub

This topic has been closed for replies.

1 reply

lrosenth
Adobe Employee
Adobe Employee
July 26, 2013

You should look at the JSObject and how to call JavaScript methods from VB(A). Then look at the addWatermark method.

Participant
July 26, 2013

I've looked at that stuff until I'm blue in the face, and still don't get it. 

Legend
November 22, 2013

Karl,

Your previous posting is really helpful.  Could you help me to explain the 19 parameters.  I could not understand True and Flase parameters.

Regards,

Purna Pani


Which ones of the 19 parameters are not clear in the documentation?