0 Replies Latest reply on Aug 28, 2015 1:44 AM by Andrew3358945

    Using Excel VBA writing JS to add watermark

    Andrew3358945 Level 1



      I'm new to JS totally but managed to use Excel VBA to do a watermark base PDF to add watermark to PDFs. most of the PDFs are ok but there are some that created problem.


      1. when it is with PDF/A type of PDF, the watermark will show on display and print preview but not printout

      2. certain watermarked PDFs are not showing watermark on display but show on print preview and printout.


      I'm using Acrobat DC Standard


      below is the VBA code that i do for watermarking, will that be anyway that i can fix it via js code?


      Dim base_PDF As String, Watermark_PDF As String, printThis As String

      Dim delfile, myw As String

      Dim j, k As Long

      Dim kk As Variant

      Dim cell As Range, i As Integer


      myw = Sheets("Listing").Range("B2").Value2

      delfile = Range("I1").Value2 & "JN" & myw & ".pdf"

      kk = "C:\Temp\AMD" & myw & ".pdf"

      j = 7

      k = Range("A6").End(xlDown).Row

      For j = 7 To k

          If Dir(delfile) <> "" Then

            SetAttr delfile, vbNormal

            Kill delfile

          End If

          If (Range("H" & j) <> "") Then

              base_PDF = Range("J" & j)

              Sheets("PDF").Cells.ClearContents ' Make a watermakePDF

              Sheets("PDF").Range("K1").Value2 = Sheets("Listing").Range("B" & j).Value2

              Sheets("PDF").ExportAsFixedFormat xlTypePDF, kk, xlQualityStandard, True, False, , , False

              Dim pdfDoc1 As AcroPDDoc

              Dim jsObj As Object

              Set pdfDoc1 = CreateObject("AcroExch.PDDoc")

              If pdfDoc1.Open(base_PDF) Then

                  Set jsObj = pdfDoc1.GetJSObject

                  jsObj.addWatermarkFromFile kk, 0, 0, 0, True, True, True, 50, -1, 0, 0, False, 1, True, 0, 1

              End If

              pdfDoc1.Save 1, base_PDF


              Set jsObj = Nothing

              Set pdfDoc1 = Nothing

          End If