Solved

Editing an Acrobat .PDF file to add page footers from Access 2013

Posted on 2014-11-25
13
464 Views
Last Modified: 2014-11-26
I have this subroutine that is supposed to add a page footer on every page of a group of PDF files - it works fine except the footer only appears on the 1st page.

Hopefully its a simple fix to add the footer to every page

I'm using Access 2013 and Acrobat XI Professional

I'd appreciate any help I can get.

Thanks
 ----------------------------
Private Sub TestButton_Click()

    Dim TestFunction As String, PathNm As String, FileNm As String, DestPathNm As String, CountFiles As Integer, MaxCountFiles As Double, MaxPgsPerFile, PathTest As String
    Dim StrSql As String, dbs As Database, rst As Recordset, Rst1 As Recordset
    Dim DoYouWantToSendToPrinter As Integer
    Dim SourcePath As String, DestPath As String, NoFiles As Integer, NoPages As Integer, DoYouWantToInclPathInFtr As Integer
    Dim FontSize As Integer, FontColor As String
   
    MsgBox "Make Sure Printer is not 'OFF-Line'" & vbNewLine & vbNewLine & "Make a Process to add a leader or trailer page" & vbNewLine & vbNewLine & "Make it so it can print in XX (e.g. 50 pages) page batches to take advantage of the stapler" & vbNewLine & vbNewLine & "Put all these options in a table and have a drop down menu"
   
    STRUSERID = GetNetUserName()
   
    StrSql = "SELECT [0_UserSpecificData].UserId, [0_UserSpecificData].PrintPdfLastPathSource, [0_UserSpecificData].PrintPdfLastPathDest, "
    StrSql = StrSql & "[0_UserSpecificData].PrintPdfLastNoFiles, [0_UserSpecificData].PrintPdfLastNoPages FROM 0_UserSpecificData WHERE "
    StrSql = StrSql & "[0_UserSpecificData].UserId="
    StrSql = StrSql & """" & STRUSERID & """"
    StrSql = StrSql & ";"
   
    Set dbs = CurrentDb
   
    Set rst = dbs.OpenRecordset(StrSql)
   
    If Not rst.EOF Then
        If IsNull(rst![PrintPdfLastPathSource]) Then
            SourcePath = "c:\0\"
        Else
            SourcePath = rst![PrintPdfLastPathSource]
        End If
       
        If IsNull(rst![PrintPdfLastPathDest]) Then
            DestPath = "e:\0\"
        Else
            DestPath = rst![PrintPdfLastPathDest]
        End If
       
        If IsNull(rst![PrintPdfLastNoFiles]) Then
            NoFiles = 25
        Else
            NoFiles = rst![PrintPdfLastNoFiles]
        End If
       
        If IsNull(rst![PrintPdfLastNoPages]) Then
            NoPages = 20
        Else
            NoPages = rst![PrintPdfLastNoPages]
        End If
    Else
        SourcePath = "c:\0\"
        DestPath = "e:\0\"
        NoFiles = 25
        NoPages = 20
    End If
   
    DoYouWantToSendToPrinter = MsgBox("Do You Want to Print These Files (Yes) " & vbNewLine & "Or Just Add Footers and Save (No)", vbYesNoCancel)
   
    If DoYouWantToSendToPrinter = 2 Then Exit Sub
   
    PathNmChck = MsgBox("Path with Files to Process" & vbNewLine & SourcePath, vbYesNoCancel)
    If PathNmChck = 6 Then
        PathNm = SourcePath
    ElseIf PathNmChck = 2 Then
        Exit Sub
    Else
   
       Dim strMessage As String
       Dim startDirectory
       strMessage = "Select a directory"
       startDirectory = "My Computer" 'c:\program files"
       Dim objFF As Object
       Set objFF = CreateObject("Shell.Application").BrowseForFolder(0, strMessage, &H1, startDirectory)
       If Not objFF Is Nothing Then
        getdirectory = objFF.Items.Item.Path
           PathNm = objFF.Items.Item.Path
           MsgBox PathNm
       Else
        getdirectory = vbNullString
        MsgBox "No directory selected"
        Exit Sub
       End If
       Set objFF = Nothing
    End If
   
    If Right(PathNm, 1) = "\" Then
    Else
        PathNm = PathNm & "\"
    End If
   
    SourcePath = PathNm
   
    PathNmChck = MsgBox("Souce Path From " & SourcePath & vbneline & vbNewLine & "Destination Path Files Will be Process to" & vbNewLine & DestPath, vbYesNoCancel)
    If PathNmChck = 6 Then
        DestPathNm = DestPath
        PathTest = Dir(DestPath)
On Error Resume Next
        If Len(PathTest) = 0 Then MkDir DestPath
On Error GoTo 0
    ElseIf PathNmChck = 2 Then
        Exit Sub
    Else
   
       strMessage = "Select a directory"
       startDirectory = "My Computer" 'c:\program files"
       Set objFF = CreateObject("Shell.Application").BrowseForFolder(0, strMessage, &H1, startDirectory)
       If Not objFF Is Nothing Then
        getdirectory = objFF.Items.Item.Path
           DestPathNm = objFF.Items.Item.Path
           MsgBox DestPathNm
       Else
        getdirectory = vbNullString
        MsgBox "No directory selected"
        Exit Sub
       End If
       Set objFF = Nothing
    End If
   
    If Right(DestPathNm, 1) = "\" Then
    Else
        DestPathNm = DestPathNm & "\"
    End If
   
    CountFiles = 1
   
    MaxCountFiles = InputBox("How Many Files Do You Want to Print?", , NoFiles)
    MaxPgsPerFile = InputBox("How Many Pages Per File Do You Want to Print?", , NoPages)
    FontSize = InputBox("What Font Size Do You Want for the Footer?" & vbNewLine & vbNewLine & "Default is 8 Point", , 8) '11-11-2011
    FontColor = InputBox("What Font Color Do You Want for the Footer?" & vbNewLine & vbNewLine & "Default is Red", , "Red") '11-11-2011

    FileNm = Dir(PathNm & "*.pdf")
    While FileNm <> "" And CountFiles <= MaxCountFiles
        TestFunction = AddPageNumbers(PathNm, FileNm, DestPathNm, FileNm, 1, MaxPgsPerFile, CountFiles, DoYouWantToSendToPrinter, FontSize, FontColor) '07-25-2011, DoYouWantToInclPathInFtr)
       
        CountFiles = CountFiles + 1
        FileNm = Dir()
    Wend
   
    With rst
        .Edit
            ![PrintPdfLastPathSource] = PathNm
            ![PrintPdfLastPathDest] = DestPathNm
            ![PrintPdfLastNoFiles] = MaxCountFiles
            ![PrintPdfLastNoPages] = MaxPgsPerFile
        .Update
    End With
End Sub

Public Function AddPageNumbers(ByVal SourcePath As String, ByVal SourceFileName As String, ByVal DestPath As String, ByVal DestFileName As String, ByVal FrstPg As Double, ByVal MaxNoPgs As Double, ByVal FileNo As Double, ByVal DoYouWantToSendToPrinter As Integer, ByVal FontSize As Integer, ByVal FontColor As String) As String '07-25-2011, ByVal DoYouWantToInclPathInFtr As Integer) As String

    Dim ex1 As String
    Dim App As Object, AVDoc As Object, AcroPDDoc As Object, AForm As Object
    Dim Ret As Long
    Dim sString As String * 255
    Dim PdfPrint As String, numPages As Integer
       
    Dim sfile As String
    Dim sText As String
    Dim iFileNum As Integer
   
    Dim FileName As String '06-18-2011
   
    Set App = CreateObject("Acroexch.app")
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
   
    If Right(SourcePath, 1) <> "\" Then SourcePath = SourcePath & "\"
    If Right(DestPath, 1) <> "\" Then DestPath = SourcePath & "\"
   
    'FileName = SourcePath & SourceFileName '06-18-2011 - doesn't like symbols in the path either ":" or "\" - need to research
    FileName = SourceFileName '06-18-2011
    booleanresult = AVDoc.Open(SourcePath & SourceFileName, "")
   
    If booleanresult = True Then
        App.Show
        Set AcroPDDoc = AVDoc.GetPDDoc
       
            ex1 = "  // Set Footer PageNo centered  " & vbLf & "  var Box2Width = 500  " & vbLf & "  for (var p = 0; p < this.numPages; p++)   " & vbLf & "   {   " & vbLf & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf & "         fp.value = """
            ex1 = ex1 & FileName & " -- " & Month(Now) & "/" & Day(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now)
       
        ex1 = ex1 & " -- Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf & "         fp.textSize=" & FontSize & "; fp.textColor = " & FontColor & ";  fp.readonly = true;  " & vbLf & "         fp.alignment=""left"";  " & vbLf & "     }  " & vbLf & "   }  "

       
'this.addWatermarkFromText({
'cText: "Document content expires 7 days from " + util.printd("mmm dd, yyyy", new Date()),
'nTextAlign: app.constants.align.center,
'nHorizAlign: app.constants.align.center,
'nVertAlign: app.constants.align.center,
'nOpacity: 0.5
'});
''---The above script will display the print date and the expiry date is set for 7 days.
       
        AForm.Fields.ExecuteThisJavaScript ex1
    End If
   
   
    On Error Resume Next
   
    AcroPDDoc.Save 1, DestPath & DestFileName
   
    numPages = AcroPDDoc.GetNumPages()
   
'text file listing documents printed
        sfile = DestPath & "Files Printed " & Format$(Now, "YYMMDD") & ".txt"
        sText = IIf(FileNo < 10, "00", IIf(FileNo < 100, "0", "")) & FileNo & " --- " & "Printed " & MaxNoPgs & " of " & IIf(numPages < 10, "00", IIf(numPages < 100, "0", "")) & numPages & " --- " & SourcePath & SourceFileName & " --- " & DestPath & DestFileName
       
        If FileNo = 1 Then Kill DestPath & "Files Printed " & Format$(Now, "YYMMDD") & ".txt"
       
        iFileNum = FreeFile
        Open sfile For Append As iFileNum
        Write #iFileNum, sText
        Close #iFileNum
   
   
    If MaxNoPgs >= numPages Then
        MaxNoPgs = numPages
    End If
   
    If DoYouWantToSendToPrinter = 6 Then
        PdfPrint = PrintPdfFile(DestPath, DestFileName, FrstPg, MaxNoPgs)
        WaitForPrintingToFinish
    End If
   
    AcroPDDoc.Close
    AVDoc.Close (True)
    App.Exit
   
    Ret = FindWindowWild(0, "Adobe*")
    Call GetWindowText(Ret, sString, 255)
   
    Ret = FindWindow(vbNullString, sString)
   
    PostMessage Ret, WM_CLOSE, CLng(0), CLng(0)

    Set AcroPDDoc = Nothing
    Set AVDoc = Nothing
    Set App = Nothing
End Function


'03-01-2011 Superceded by Add Page Numbers     'AddFooterPgNo Sub AddPageNumbers02282011revised03012011()
'03-01-2011 Superceded by Add Page Numbers     'AddFooterPgNo.vbs
'03-01-2011 Superceded by Add Page Numbers     '-----------------------------------------------
'03-01-2011 Superceded by Add Page Numbers     Dim path As String, AcroAVDoc As Object, AcroPDDoc As Object, Path1 As String
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     path = "C:\1\test.pdf"
'03-01-2011 Superceded by Add Page Numbers     Path1 = "C:\1\test-edited.pdf"
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     Filename = "C:/1/This is a Test.pdf"
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     '~~> Establish an existing application object
'03-01-2011 Superceded by Add Page Numbers     On Error Resume Next
'03-01-2011 Superceded by Add Page Numbers     Set App = GetObject(, "Acroexch.app")
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     '~~> If not found then create new instance
'03-01-2011 Superceded by Add Page Numbers     If Err.Number <> 0 Then
'03-01-2011 Superceded by Add Page Numbers         MsgBox Err.Number
'03-01-2011 Superceded by Add Page Numbers         Set App = CreateObject("Acroexch.app")
'03-01-2011 Superceded by Add Page Numbers     End If
'03-01-2011 Superceded by Add Page Numbers     Err.Clear
'03-01-2011 Superceded by Add Page Numbers     On Error GoTo 0
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     App.Show
'03-01-2011 Superceded by Add Page Numbers     Set AVDoc = CreateObject("AcroExch.AVDoc")
'03-01-2011 Superceded by Add Page Numbers     Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     booleanresult = AVDoc.Open(path, "")
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     If booleanresult = True Then
'03-01-2011 Superceded by Add Page Numbers         Set AcroAVDoc = App.GetActiveDoc
'03-01-2011 Superceded by Add Page Numbers         Set AcroPDDoc = AcroAVDoc.GetPDDoc
'03-01-2011 Superceded by Add Page Numbers       ex1 = "  // Set Footer PageNo centered  " & vbLf & "  var Box2Width = 500  " & vbLf & "  for (var p = 0; p < this.numPages; p++)   " & vbLf & "   {   " & vbLf & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf & "         fp.value = """
'03-01-2011 Superceded by Add Page Numbers       ex1 = ex1 & Filename & " " & Month(Now) & "/" & Day(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now)
'03-01-2011 Superceded by Add Page Numbers       ex1 = ex1 & " -- Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf & "         fp.textSize=6; fp.textColor = color.red;  fp.readonly = true;  " & vbLf & "         fp.alignment=""left"";  " & vbLf & "     }  " & vbLf & "   }  "
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers       '//Execute JS-Code
'03-01-2011 Superceded by Add Page Numbers        AForm.Fields.ExecuteThisJavaScript ex1
'03-01-2011 Superceded by Add Page Numbers     End If
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     AcroPDDoc.Save 1, Path1
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     AcroPDDoc.Close
'03-01-2011 Superceded by Add Page Numbers     AcroAVDoc.Close (True)
'03-01-2011 Superceded by Add Page Numbers     AVDoc.Close (True)
'03-01-2011 Superceded by Add Page Numbers     App.Exit
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     Set AcroPDDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers     Set AcroAVDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers     Set AVDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers     Set App = Nothing
'03-01-2011 Superceded by Add Page Numbers End Sub
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers Sub AddPageNumbers1()
'03-01-2011 Superceded by Add Page Numbers     'AddFooterPgNo.vbs
'03-01-2011 Superceded by Add Page Numbers     '-----------------------------------------------
'03-01-2011 Superceded by Add Page Numbers     Dim path As String, AcroAVDoc As Object, AcroPDDoc As Object, Path1 As String
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     path = "C:\1\test.pdf"
'03-01-2011 Superceded by Add Page Numbers     Path1 = "C:\1\test-edited.pdf"
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     Dim Part1Document As Acrobat.CAcroPDDoc
'03-01-2011 Superceded by Add Page Numbers     Set Part1Document = CreateObject("AcroExch.PDDoc")
'03-01-2011 Superceded by Add Page Numbers     Part1Document.Open (PdfPathFile)
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers 'note - Java script doesn't like \ so need to work through the path string and replace \ with / before running java script
'03-01-2011 Superceded by Add Page Numbers     Filename = "C:/1/This is a Test.pdf"
'03-01-2011 Superceded by Add Page Numbers     Set App = CreateObject("Acroexch.app")
'03-01-2011 Superceded by Add Page Numbers     App.Show
'03-01-2011 Superceded by Add Page Numbers     Set AVDoc = CreateObject("AcroExch.AVDoc")
'03-01-2011 Superceded by Add Page Numbers     Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     booleanresult = AVDoc.Open(path, "")
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     If booleanresult = True Then
'03-01-2011 Superceded by Add Page Numbers         Set AcroAVDoc = App.GetActiveDoc
'03-01-2011 Superceded by Add Page Numbers '02-25-2011        Set AcroAVDoc = AcroApp.GetActiveDoc
'03-01-2011 Superceded by Add Page Numbers         Set AcroPDDoc = AcroAVDoc.GetPDDoc
'03-01-2011 Superceded by Add Page Numbers '02-22-2011    If avdoc.Open(path, "") Then
'03-01-2011 Superceded by Add Page Numbers       '//write JS-Code on a variable'
'03-01-2011 Superceded by Add Page Numbers 'note - Java script doesn't like \ so need to work through the path string and replace \ with / before running java script
'03-01-2011 Superceded by Add Page Numbers       ex1 = "  // Set Footer PageNo centered  " & vbLf & "  var Box2Width = 500  " & vbLf & "  for (var p = 0; p < this.numPages; p++)   " & vbLf & "   {   " & vbLf & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf & "         fp.value = """
'03-01-2011 Superceded by Add Page Numbers       ex1 = ex1 & Filename & " " & Month(Now) & "/" & Day(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now)
'03-01-2011 Superceded by Add Page Numbers '      ex1 = ex1 & FileName
'03-01-2011 Superceded by Add Page Numbers       ex1 = ex1 & " -- Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf & "         fp.textSize=6; fp.textColor = color.red;  fp.readonly = true;  " & vbLf & "         fp.alignment=""left"";  " & vbLf & "     }  " & vbLf & "   }  "
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers       ex = "  // Set Footer PageNo centered  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "  var Box2Width = 50  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "  for (var p = 0; p < this.numPages; p++)   " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "   {   " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         fp.value = ""Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         fp.textSize=6;  fp.readonly = true;  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         fp.alignment=""center"";  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "     }  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "   }  "
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers 'MsgBox ex & vbNewLine & vbNewLine & ex1
'03-01-2011 Superceded by Add Page Numbers       '//Execute JS-Code
'03-01-2011 Superceded by Add Page Numbers        AForm.Fields.ExecuteThisJavaScript ex1
'03-01-2011 Superceded by Add Page Numbers     End If
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers '    AcroPDDoc.Save 1, path
'03-01-2011 Superceded by Add Page Numbers '
'03-01-2011 Superceded by Add Page Numbers '    AcroPDDoc.Close
'03-01-2011 Superceded by Add Page Numbers '
'03-01-2011 Superceded by Add Page Numbers '    Set AcroPDDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers '    Set AcroAVDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers '    Set AVDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers '    Set App = Nothing
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     AcroPDDoc.Save 1, Path1
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     AcroPDDoc.Close
'03-01-2011 Superceded by Add Page Numbers     AcroAVDoc.Close (True)
'03-01-2011 Superceded by Add Page Numbers     AVDoc.Close (True)
'03-01-2011 Superceded by Add Page Numbers     App.Exit
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     Set AcroPDDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers     Set AcroAVDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers     Set AVDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers     Set App = Nothing
'03-01-2011 Superceded by Add Page Numbers End Sub
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers Sub AddPageNumbers02232011()
'03-01-2011 Superceded by Add Page Numbers     'AddFooterPgNo.vbs
'03-01-2011 Superceded by Add Page Numbers     '-----------------------------------------------
'03-01-2011 Superceded by Add Page Numbers     Dim path As String, PDDoc
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     path = "C:\1\test.pdf"
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     Set App = CreateObject("Acroexch.app")
'03-01-2011 Superceded by Add Page Numbers     App.Show
'03-01-2011 Superceded by Add Page Numbers     Set AVDoc = CreateObject("AcroExch.AVDoc")
'03-01-2011 Superceded by Add Page Numbers     Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     booleanresult = AVDoc.Open(path, "")
'03-01-2011 Superceded by Add Page Numbers     If booleanresult = True Then
'03-01-2011 Superceded by Add Page Numbers         PDDoc = AVDoc.GetPDDoc
'03-01-2011 Superceded by Add Page Numbers '02-22-2011    If avdoc.Open(path, "") Then
'03-01-2011 Superceded by Add Page Numbers       '//write JS-Code on a variable'
'03-01-2011 Superceded by Add Page Numbers       ex = "  // Set Footer PageNo centered  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "  var Box2Width = 50  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "  for (var p = 0; p < this.numPages; p++)   " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "   {   " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         fp.value = ""Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         fp.textSize=6;  fp.readonly = true;  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         fp.alignment=""center"";  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "     }  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "   }  "
'03-01-2011 Superceded by Add Page Numbers       '//Execute JS-Code
'03-01-2011 Superceded by Add Page Numbers        AForm.Fields.ExecuteThisJavaScript ex
'03-01-2011 Superceded by Add Page Numbers     End If
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     PDDoc.Save 1, path
'03-01-2011 Superceded by Add Page Numbers     PDDoc.Close
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers     Set PDDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers     Set AVDoc = Nothing
'03-01-2011 Superceded by Add Page Numbers     Set App = Nothing
'03-01-2011 Superceded by Add Page Numbers End Sub
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers Sub AddPageNumbersRogerTryingToFigureOut()
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers             Dim AcroApp As Acrobat.CAcroApp
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers             Dim Part1Document As Acrobat.CAcroPDDoc
'03-01-2011 Superceded by Add Page Numbers             Dim Part2Document As Acrobat.CAcroPDDoc
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers             Set AcroApp = CreateObject("AcroExch.App")
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers             Set Part1Document = CreateObject("AcroExch.PDDoc")
'03-01-2011 Superceded by Add Page Numbers             Set Part2Document = CreateObject("AcroExch.PDDoc")
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers             PdfPathFile = "C:\1\test.pdf"
'03-01-2011 Superceded by Add Page Numbers             Part1Document.Open (PdfPathFile)
'03-01-2011 Superceded by Add Page Numbers             Part1Document.OpenAVDoc (PdfPathFile)
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers 'MsgBox "Test - " & AcroApp.GetActiveDoc
'03-01-2011 Superceded by Add Page Numbers            Set currdoc = AcroApp.GetActiveDoc
'03-01-2011 Superceded by Add Page Numbers '            Set CurrDoc = Part1Document.OpenAVDoc(PdfPathFile)
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers       ex = "  // Set Footer PageNo centered  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "  var Box2Width = 50  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "  for (var p = 0; p < this.numPages; p++)   " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "   {   " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         fp.value = ""Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         fp.textSize=6;  fp.readonly = true;  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "         fp.alignment=""center"";  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "     }  " & vbLf _
'03-01-2011 Superceded by Add Page Numbers       & "   }  "
'03-01-2011 Superceded by Add Page Numbers       '//Execute JS-Code
'03-01-2011 Superceded by Add Page Numbers        AForm.Fields.ExecuteThisJavaScript ex
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers End Sub
'03-01-2011 Superceded by Add Page Numbers
'03-01-2011 Superceded by Add Page Numbers






 
Public Function PrintPdfFile(ByVal PdfPath As String, ByVal PdfFileNm As String, ByVal PdfFirstPageToPrint As Integer, ByVal PdfMaxPagesToPrint As Integer) As String
    Dim PdfPathAndFile As String
    Dim AVDoc As Acrobat.AcroAVDoc
    Dim retcd As Integer
   
    If Right(PdfPath, 1) = "\" Then
        PdfPathAndFile = PdfPath & PdfFileNm
    Else
        PdfPathAndFile = PdfPath & "\" & PdfFileNm
    End If
   
    Set AVDoc = CreateObject("AcroExch.AVDoc")
   
    retcd = AVDoc.Open(PdfPathAndFile, "Title")    ' pathname of pdf file to be opened
   
    If retcd <> -1 Then
'        MsgBox ("Failed to open PDF document " & PdfPathAndFile)
        Exit Function
    End If

    'AVDoc.PrintPages(firstPage, numPages, 2, true, true)
    If PdfMaxPagesToPrint >= 1 Then PdfMaxPagesToPrint = PdfMaxPagesToPrint - 1  'allows for the fact that the first page is page 0
    If PdfFirstPageToPrint >= 1 Then PdfFirstPageToPrint = PdfFirstPageToPrint - 1 'allows for the fact that the first page is page 0
   
    'PrintPagesSilent(nFirstPage As Long, nLastPage As Long, nPSLevel As Long, bBinaryOk As Long, bShrinkToFit As Long) As Boolean
        'Params 1 & 2 are: Print from page __ to page __
        'Param 3: Must be either 1 or 2. 1 generates Level 1 PostScript code. 2 generates Level 2 PostScript code. (You'll have to test in your own environment, but fortunately the list is quite short.)
        'Param 4: True, indicates the PostScript code may contain binary data. False, indicates binary data is encoded into an ASCII format.
        'Param 5: True, shrink (if necessary). False, print actual size; pages may appear clipped.

    retcd = AVDoc.PrintPagesSilent(PdfFirstPageToPrint, PdfMaxPagesToPrint, 0, 1, True)         ' this prints the number of pages specified by PdfMaxPagesToPrint (i.e. page 0)
    '11-23-2011 retcd = AVDoc.PrintPagesSilent(PdfFirstPageToPrint, PdfMaxPagesToPrint, 0, 1, 1)         ' this prints the number of pages specified by PdfMaxPagesToPrint (i.e. page 0)
    'retcd = AVDoc.PrintPages(PdfFirstPageToPrint, PdfMaxPagesToPrint, 0, 1, 1)         ' this prints the number of pages specified by PdfMaxPagesToPrint (i.e. page 0)
    'avDoc.PrintPagesSilent(0, (numPages - 1), PSLevel, BinaryOk, ShrinkToFit);


    AVDoc.Close (1)

End Function
0
Comment
Question by:rogerdjr
  • 8
  • 4
13 Comments
 
LVL 23

Expert Comment

by:NVIT
ID: 40467422
Can you reduce this? Do you have an idea of where the trouble might be?
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40467443
Woof!
Heavy evil.
You've certainly come a ways since we figured out how to get your images in the PDF to play nice.
I'd appreciate any help I can get.
Editing PDF's with the javascript monstrosities involved is not for the faint of heart :)
it works fine except the footer only appears on the 1st page.


I'm thinking we must have a looping logic error in there.
We're going to need
'pseudocode
'figure out the number of pages in the document
'for x = 1 to number of pages
'add the footer
next x

So, this must be the operative stuff
   If booleanresult = True Then
         App.Show
         Set AcroPDDoc = AVDoc.GetPDDoc
         
             ex1 = "  // Set Footer PageNo centered  " & vbLf & "  var Box2Width = 500  " & vbLf & "  for (var p = 0; p < this.numPages; p++)   " & vbLf & "   {   " & vbLf & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf & "         fp.value = """
             ex1 = ex1 & FileName & " -- " & Month(Now) & "/" & Day(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now)
         
         ex1 = ex1 & " -- Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf & "         fp.textSize=" & FontSize & "; fp.textColor = " & FontColor & ";  fp.readonly = true;  " & vbLf & "         fp.alignment=""left"";  " & vbLf & "     }  " & vbLf & "   }  "

         
 'this.addWatermarkFromText({
 'cText: "Document content expires 7 days from " + util.printd("mmm dd, yyyy", new Date()),
 'nTextAlign: app.constants.align.center,
 'nHorizAlign: app.constants.align.center,
 'nVertAlign: app.constants.align.center,
 'nOpacity: 0.5
 '});
 ''---The above script will display the print date and the expiry date is set for 7 days.
         
         AForm.Fields.ExecuteThisJavaScript ex1
     End If


Is it really that unreadable at the source or did it just paste very badly?
I am seeing the beginnings of the javascript loop
for (var p = 0; p < this.numPages; p++)

This'll be hard because we can't set breakpoints.
Can you clean this chunk of the code up to be more easily human-readable, without breaking it?
Once that is done, we'll try hardcoding for this.numPages on a document you've precalculated the number of pages.

If that works, then we'll know that this.numPages isn't calculating what we think -- it's returning 1 -- and that's why only the first page gets altered
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40467472
This is a little cleaner
    If booleanresult = True Then
         App.Show
         Set AcroPDDoc = AVDoc.GetPDDoc
         
             ex1 = "  // Set Footer PageNo centered  " & vbLf 
             ex1 = ex1 & "  var Box2Width = 500  " & vbLf 
	     ex1 = ex1 & "  for (var p = 0; p < this.numPages; p++)   " & vbLf 
	     ex1 = ex1 & "   {   " & vbLf & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf 
	     ex1 = ex1 & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf 
	     ex1 = ex1 & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf 
	     ex1 = ex1 & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf 
	     ex1 = ex1 & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf 
	     ex1 = ex1 & "         fp.value = """
             ex1 = ex1 & FileName & " -- " & Month(Now) & "/" & Day(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now)
         
             ex1 = ex1 & " -- Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf
             ex1 = ex1 & "         fp.textSize=" & FontSize & "; fp.textColor = " & FontColor & ";  fp.readonly = true;  " & vbLf 
             ex1 = ex1 & "         fp.alignment=""left"";  " & vbLf & "     }  " & vbLf & "   }  "

         
 'this.addWatermarkFromText({
 'cText: "Document content expires 7 days from " + util.printd("mmm dd, yyyy", new Date()),
 'nTextAlign: app.constants.align.center,
 'nHorizAlign: app.constants.align.center,
 'nVertAlign: app.constants.align.center,
 'nOpacity: 0.5
 '});
 ''---The above script will display the print date and the expiry date is set for 7 days.
         
         AForm.Fields.ExecuteThisJavaScript ex1
     End If

Open in new window


Try it and ensure I broke nothing.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40467497
Something else might be wrong, though.
Your footer on the first page, is it correct?
Or is the text actually (say on a 35 page PDF) Page:35/35

That would be a different logic error.
The text being created is right, but only page one gets altered because IT isn't being incremented
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40467515
Look here, near the bottom
https://acrobatusers.com/tutorials/watermarking-a-pdf-with-javascript
This looks immensely less complex that what you have.
In fact, you have something like it commented out below what is actually operating now.

Did it not work how you needed it to?
0
 

Author Comment

by:rogerdjr
ID: 40467616
I tried Nick67's 2014-11-26 at 10:39:39ID: 40467472 suggestion and it still only puts the footer on the first page - see attached "Before" and After Files
J--0-Before-After-Test-11-26-2014.zip
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:rogerdjr
ID: 40467627
I went to the webpage Nick67 Referred me to but I'm not really sure how to incorporate this into the process I agree it looks a lot simpler
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40467676
@rogerdjr
There was no fix in #40467472
I just reformatted the code to make it more human readable.
Thank you for the samples.
Clearly the text of the field is correct for the page that it is on.
That eliminates the conjecture from #40467497

Now, I've been looking at how this is meant to work
The idea is to add a field
var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);
to each page
That isn't happening
Instead, it only adds the field to the first page.
I am now think that the part that names the field String(""xftPage""+p+1) is wonky.
I suspect that creates just "xftPagep1" and not "xftPage1" , "xftPage2" , "xftPage3" ...

Let's try ""xftPage"" + String(p+1) instead.
This bit Page: "" + String(p+1)+ ""/"" + this.numPages; concatenates correctly, so it's worth a shot
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40467701
I am thinking this would work.
Font sizes and colors still might need to be messed with, but

    If booleanresult = True Then
         App.Show
         Set AcroPDDoc = AVDoc.GetPDDoc
	 ex1 = this.addWatermarkFromText({
	 ex1 = ex1 & "cText: " & FileName & " -- " & Month(Now) & "/" & Day(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now) 
	 ex1 = ex1 & " -- Page: "" + String(p+1)+ ""/"" + this.numPages;  ,"
	 ex1 = ex1 & "nTextAlign: app.constants.align.center,"
	 ex1 = ex1 & "nHorizAlign: app.constants.align.center,"
	 ex1 = ex1 & "nVertAlign: app.constants.align.center,"
	 ex1 = ex1 & "nOpacity: 0.5"
	 ex1 = ex1 & " '});"

	AForm.Fields.ExecuteThisJavaScript ex1

     End If

Open in new window


Might do it.
Just more javascript to get executing
0
 

Author Comment

by:rogerdjr
ID: 40467954
Well I went back to the basic code before I started to "tweak" functions and found that the effort to set the color for the text was hanging things up. I removed "; fp.textColor = " & FontColor & " and it runs fine.

All I need now is a way to figure out how to set the fond color - any Ideas?

Public Function AddPageNumbers(ByVal SourcePath As String, ByVal SourceFileName As String, ByVal DestPath As String, ByVal DestFileName As String, ByVal FrstPg As Double, ByVal MaxNoPgs As Double, ByVal FileNo As Double, ByVal DoYouWantToSendToPrinter As Integer, ByVal FontSize As Integer, ByVal FontColor As String) As String '07-25-2011, ByVal DoYouWantToInclPathInFtr As Integer) As String

    Dim ex1 As String
    Dim App As Object, AVDoc As Object, AcroPDDoc As Object, AForm As Object
    Dim Ret As Long
    Dim sString As String * 255
    Dim PdfPrint As String, numPages As Integer
       
    Dim sfile As String
    Dim sText As String
    Dim iFileNum As Integer
   
    Dim FileName As String '06-18-2011
   
    Set App = CreateObject("Acroexch.app")
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
   
    If Right(SourcePath, 1) <> "\" Then SourcePath = SourcePath & "\"
    If Right(DestPath, 1) <> "\" Then DestPath = SourcePath & "\"
   
    FileName = SourceFileName '06-18-2011
    booleanresult = AVDoc.Open(SourcePath & SourceFileName, "")
   
    If booleanresult = True Then
        App.Show
        Set AcroPDDoc = AVDoc.GetPDDoc
         'Found Code at this web page https://forums.adobe.com/thread/721676?start=0&tstart=0
            ex1 = "  // Set Footer PageNo centered  " & vbLf & "  var Box2Width = 500  " & vbLf & "  for (var p = 0; p < this.numPages; p++)   " & vbLf & "   {   " & vbLf & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf & "         fp.value = """
            ex1 = ex1 & FileName & " -- " & Month(Now) & "/" & Day(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now)
            ex1 = ex1 & " -- Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf & "         fp.textSize=" & FontSize & "; fp.readonly = true;  " & vbLf & "         fp.alignment=""left"";  " & vbLf & "     }  " & vbLf & "   }  "
             
            'removed "; fp.textColor = " & FontColor & "
             
            AForm.Fields.ExecuteThisJavaScript ex1
    End If
   
   
    On Error Resume Next
   
    AcroPDDoc.Save 1, DestPath & DestFileName
   
    numPages = AcroPDDoc.GetNumPages()
   
'text file listing documents printed
        sfile = DestPath & "Files Printed " & Format$(Now, "YYMMDD") & ".txt"
        sText = IIf(FileNo < 10, "00", IIf(FileNo < 100, "0", "")) & FileNo & " --- " & "Printed " & MaxNoPgs & " of " & IIf(numPages < 10, "00", IIf(numPages < 100, "0", "")) & numPages & " --- " & SourcePath & SourceFileName & " --- " & DestPath & DestFileName
       
        If FileNo = 1 Then Kill DestPath & "Files Printed " & Format$(Now, "YYMMDD") & ".txt"
       
        iFileNum = FreeFile
        Open sfile For Append As iFileNum
        Write #iFileNum, sText
        Close #iFileNum
   
    If MaxNoPgs >= numPages Then
        MaxNoPgs = numPages
    End If
    AcroPDDoc.Close
    AVDoc.Close (True)
    App.Exit
   
    Ret = FindWindowWild(0, "Adobe*")
    Call GetWindowText(Ret, sString, 255)
   
    Ret = FindWindow(vbNullString, sString)
   
    PostMessage Ret, WM_CLOSE, CLng(0), CLng(0)

    Set AcroPDDoc = Nothing
    Set AVDoc = Nothing
    Set App = Nothing
End Function
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 500 total points
ID: 40468009
The home of evil is here
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf
Page 444 talks about textColor -- which is what you are mucking with.

So far, so good
Values are defined the same as the fillColor. See “Color arrays” on page 193 for information on defining color arrays and how values are set and used with this property.

Ok

A color is represented in JavaScript as an array containing 1, 2, 4, or 5 elements corresponding to a Transparent, Gray, RGB, or CMYK color space, respectively. The first element in the array is a string denoting the color space type. The subsequent elements are numbers that range between zero and one inclusive. For example, the color red can be represented as ["RGB", 1, 0, 0].
Invalid strings or insufficient elements in a color array cause the color to be interpreted as the color black.


There are a few, and only a few, you can get away with as color.ACertainWord
Red does happen to be one
fp.textColor = "color.red" would be valid.
Letting the user specify by InputBox is asking for grief.
ACertainWord has only the following valid values
transparent, black, white, red, green, blue, cyan, magneta, yellow, light gray, gray and dark gray

You could build a combobox to feed in any array value you wanted.
I would be partial to fp.textColor = ["RGB", 5, 9, 255] with all the appropriate nonsense to get the quotes into javascript
["RGB", 5, 9, 255] is basically our company blue :)

That should do 'er
I'm glad that I was able to get you thinking on the right track.
The javascript has no output, so anything that would make it bomb would just end silently.
I was thinking that it was completing, just not properly.
Glad you found what was making it bomb.

Nick67
0
 

Author Closing Comment

by:rogerdjr
ID: 40468093
Great help - thanks as always
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40468183
:)
I'd appreciate any help I can get.

You didn't get a PDF/JavaScript expert, but you did get a logical mind to help you work through the swamp.
That tends to happen with questions I ask rather than answer, too.

Later,

Nick67
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
This article focuses on how to remove password security from multiple PDF files by Adobe Acrobat program. Sometimes it is essential to access the stored data items and to print, edit as well as copy content from Portable Document Format files in abs…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now