3 Replies Latest reply on Aug 16, 2013 6:48 AM by gkaiseril

    When I add page number pagination through Javascript to my PDF, the printed version produces squares

    oddish69

      Hello. I am applying a page number to a combined PDF in the format of: 1/42, 2/42, 3/42 and so on.

       

       

      I am doing this through a module in access and running a macro to run it. The code is below. Here is the problem: When that is applied, the PDF looks perfect in document view in acrobat. When I print the PDF out on [U]any[/U] printer, around 75% of the text/numbers are replaced by square characters and/or hieroglyphic type characters. (Mostly squares).

       

       

      Here's the catch, when I take the pagination out, and the PDF does not have any page numbers....it prints perfectly with no squares. I feel as though this script is defaulting the font to Helvetica, which is has custom encoding and is not embed within the document when the character pdf is produced. (If that makes sense?)

       

       

      Is there any problem with this script? I've used this script in the past. I've been told there was an update around a month ago (When this problem started occurring) on Adobe's end. Does anyone have any duplicate scripts that I could try out? I haven't found anything suitable yet online. Or does anyone have any additions or suggestions I could use to solve this problem.

       

       

      Also I forgot to mention, this must be done through Javascript. Not through Adobe's built in Page number adding feature.

       

       

      Sub PaginatePDF()

       

       

       

       

      If AVDoc.Open(finalDLAPFolder & "DLAP_today.pdf", "") Then

        '//write JS-Code on a variable

        Ex = "  // Set Footer PageNo centered  " & vbLf _

        & "  var Box2Width = 50  " & 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)) + 5  " & vbLf _

        & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,45,bEnd,15]);   " & vbLf _

        & "         fp.value = ""Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf _

        & "         fp.textSize=9;  fp.readonly = true;  " & vbLf _

        & "         fp.alignment=""center"";  " & vbLf _

        & "     } " & vbLf _

        & "   }  "

       

       

      '//Execute JS-Code

      AForm.Fields.ExecuteThisJavaScript Ex

       

       

      End If

       

       

      Set finalPDF = AVDoc.GetPDDoc

      finalPDF.Save PDSaveCollectGarbage, finalDLAPFolder & "DLAP_today.pdf"

      'finalPDF.Save PDSaveFull, finalDLAPFolder & "DLAP_today.pdf"

      AVDoc.Close 1

      finalPDF.Close

      ' copy out to the sharepoint site

      fso.CopyFile finalDLAPFolder & "DLAP_today.pdf", PublishedDLAPFolder & "DLAP_today.pdf"

      Set AVDoc = Nothing

      Set app = Nothing

      Set finalPDF = Nothing

      Set AForm = Nothing

       

       

      End Sub