Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
3

Add barcode to PDF document using VBA

New Here ,
Jun 27, 2020 Jun 27, 2020

Hi All,

 

I need to add a Barcode to pdf file using VBA in MS Word.

I have written below code but it doen't work. It shows "Barcode render error"

 

Private Function AddBarcode() As String
    Dim oAVDoc As New Acrobat.AcroAVDoc, oPDFDoc As Acrobat.AcroPDDoc
    Dim oAcro As New Acrobat.AcroApp
    Dim oJSO As Object
    Dim pdfPath as String
    Dim x as Double, y as Double
    Dim oAdd1 As Object
    
    pdfPath = ThisDocument.Path & "\Sample Form.pdf"
    If oAVDoc.Open(pdfPath, "") = True Then
        'Set the PDDoc object.
        Set oPDFDoc = oAVDoc.GetPDDoc

        'Set the JS Object - Java Script Object.
        Set oJSO = oPDFDoc.GetJSObject

        oJSO.GetField("FirstName").value = "Tejas"
        oJSO.GetField("LastName").value = "Tanna"
    
        y = 200
        x = 600
        
        Set oAdd1 = oJSO.AddField("Barcode", "barcode", oPDFDoc.GetNumPages - 1, Array(y, x, y + 195, x - 32))

        Dim outputPath$
        outputPath = ThisDocument.Path & "\Output_With_Barcode.pdf"
        
        oPDFDoc.Save 1, outputPath

        'Close the Acrobat application.
        oAVDoc.Close True
        oAcro.Exit

        'Release the objects.
        Set oJSO = Nothing
        Set oPDFDoc = Nothing
        Set oAVDoc = Nothing
        Set oAcro = Nothing
    End If
End Function

image.pngexpand image

TOPICS
PDF forms
482
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation