Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Programming
 EXP Systems Forum : PDF reDirect : Programming
Topic: PDF Merge and renumber pages Post Reply Post New Topic
Author Message
JSPeta
Newbie
Newbie
Avatar

Joined: 23 Sep 11
Location: United States
Posts: 6
Quote JSPeta Replybullet Topic: PDF Merge and renumber pages
    Posted: 23 Sep 11 at 9:30PM
I am already merging PDF files in one PDF file with VBA code. Is there a way to re-number the pages in the new merged PDF file using VBA code.

Thanks
Jim [IMG]smileys/smiley1.gif" align="middle" />
IP IP Logged
Michel_K17
Moderator Group
Moderator Group
Avatar
Forum Administrator

Joined: 25 Jan 03
Posts: 1673
Quote Michel_K17 Replybullet Posted: 23 Sep 11 at 11:40PM
Hi,

    Probably your best bet for renumbering is to use the stamp feature, and place a new stamp on top of each page with the page number.

   Before playing with the VBA code, take a look at the stamp called "Page Number Footer.txt" which is what you are looking for. Finally, take a look at the sample code, and search for the word "Utility_Apply_Text_Stamp", and look for the sample code for applying a stamp to your new merged  PDF.

   Cheers!

Michel Korwin-Szymanowski
EXP Systems LLC
IP IP Logged
JSPeta
Newbie
Newbie
Avatar

Joined: 23 Sep 11
Location: United States
Posts: 6
Quote JSPeta Replybullet Posted: 25 Sep 11 at 2:38PM
Hi, I find this, but I don't see where I can apply it to my pdf in some path. I am not understanding something

thanks
Jim


   This setting is a reference to a pre-established stamp that you created ahead of time with PDF reDirect Pro in the Preferences >> Stamps screen. The stamps are either a PDF style stamp or a TEXT style stamp. Therefore, what you would need to provide is the name of the stamp file.

    If you want to add a text stamp (also known as a watermark) on your PDF "on-the-fly" through your code, you can use the following command:

    oPDF.Utility_Apply_Text_Stamp

    You can specify the text, color, location, and a URL link if you want. Here are more details:

        ' Sample Code that applies a text stamp to your new PDF
        '------------------------------------------------------
        ' Parameters are:
        ' - Pages: FIRST_PAGE or ALL_PAGES or LAST_PAGE or NEW_PAGE_IN_FRONT or
        '           NEW_PAGE_AT_BACK or SECOND_PAGE_ONWARD or FIRST_TO_SECOND_TO_LAST
        ' - Location: UPPER_LEFT or UPPER_CENTER or UPPER_RIGHTCENTER or
        '              CENTER_STRETCHED or LOWER_LEFT or LOWER_CENTER or LOWER_RIGHT
        ' - Layer: ONTOP or UNDERNEATH
        '           Warning: Powerpoint has an opaque bottommost layer so stamps will never appear unless ONTOP
        ' - WebLink: Hyperlink (http://, https://, ftp://, mailto:) associated with your text
        '             Examples: "http://www.exp-systems.com", or "mailto:test@yahoo.com"
        ' - JavaScript: for experts only. Insert Javascript to turn stamp into a button.
        ' - Text: The text you want to display
        ' - Standard Font: Here are the fonts you can use:
        '      - FONT_COURIER, or FONT_COURIER_BOLD, or FONT_COURIER_BOLD_OBLIQUE, or FONT_COURIER_OBLIQUE
        '      - FONT_HELVETICA, or FONT_HELVETICA_BOLD, or FONT_HELVETICA_BOLD_OBLIQUE, or FONT_HELVETICA_OBLIQUE
        '      - FONT_TIMES, or FONT_TIMES_BOLD, or FONT_TIMES_OBLIQUE, or FONT_TIMES_BOLD_OBLIQUE
        ' - Text Style: Select Style of Text such as Size, Color and/or Underline.
        '               I have created a few standard constants that you can use, or you
        '               can make your own. Colors are given in Red/Green/Blue
        '      - UNDERLINE = ""
        '      - SIZE10 = "[S=010]"               << S = "Text Size"
        '      - SIZE12 = "[S=012]"               << S = "Text Size"
        '      - SIZE14 = "[S=014]"               << S = "Text Size"
        '      - BLACKTEXT = "[T=000,000,000]"    << T = "Text Color"
        '      - YELLOWBACK = "[B=255,255,000]"   << B = "Back Color"
        '
        TempBool = oPDF.Utility_Apply_Text_Stamp(FIRST_PAGE, _
                                           LOWER_LEFT, _
                                           ONTOP, _
                                           "http://www.exp-systems.com", _
                                           "", _
                                           "Your Text Here", _
                                           FONT_HELVETICA, _
                                           UNDERLINE & SIZE12 & BLACKTEXT & YELLOWBACK)
IP IP Logged
JSPeta
Newbie
Newbie
Avatar

Joined: 23 Sep 11
Location: United States
Posts: 6
Quote JSPeta Replybullet Posted: 25 Sep 11 at 4:07PM
With a little school of hard knocks, reading, and being lucky, I have figured it out.

Jim


        TempBool = .Utility_Merge_PDF_Files(sJobKeyPath, Files_to_Merge)
        TempBool = .Utility_Open_PDF(sJobKeyPath, "")       
        TempBool = .Utility_Apply_Text_Stamp("1", "6", "true", "", "", "AIHA Participant 199873             Page <#> of <###>   AAMT Control # F101 Rev. 0 3/5/2010", "4", " [s=010][B=255-255-255]")
        TempBool = .Utility_Close_PDF(sJobKeyPath)
IP IP Logged
Michel_K17
Moderator Group
Moderator Group
Avatar
Forum Administrator

Joined: 25 Jan 03
Posts: 1673
Quote Michel_K17 Replybullet Posted: 28 Sep 11 at 8:30AM

Good job! I am glad that you were able to figure it out. Smile

Cheers!

Michel Korwin-Szymanowski
EXP Systems LLC
IP IP Logged
JSPeta
Newbie
Newbie
Avatar

Joined: 23 Sep 11
Location: United States
Posts: 6
Quote JSPeta Replybullet Posted: 03 Oct 11 at 8:09AM
This is my working VBA code with no liabilty on my part.
Jim
------------------------------------------

    Dim oPDF As New PDF_reDirect_v25002.Batch_RC_AXD
    Dim Files_to_Merge(50) As String
    Dim TempBool As Boolean
    Dim sJobKeyPath As String
    Dim dbs As DAO.Database
    Dim rs As DAO.Recordset
    Dim sSQL As Variant
    Dim nJobID As Variant
    Dim sNextFile As Variant
    Dim nFileCnt As Integer
    ' system folder definition
    Dim fso
    Dim fol As String
    Set fso = CreateObject("Scripting.FileSystemObject")
    ' process all lab report results into PFD's
    Call cmdRunAll_Click
    
    nJobID = [Forms]![frmCustomer]![frmJob]![JobID]
    Set dbs = CurrentDb
    sSQL = "SELECT tblJob.JobKey FROM tblJob WHERE tblJob.JobID =" & nJobID
    Set rs = dbs.OpenRecordset(sSQL)
     sJobKeyPath = rs.Fields(0)
    ' Files to Merge
    'sPath = "c:\CSLocal\PDFS"
    '-----------------------------
    ' count the PDF files in folder
    nFileCnt = 0
    
    sNextFile = Dir$("c:\CSLocal\PDFS\*.pdf*")
    Do While sNextFile <> ""
        nFileCnt = nFileCnt + 1
        sNextFile = Dir
       ' MsgBox sNextFile
    Loop
    '------------------------
    ' Fill the array with all pdf's in the folder
    Dim iCnt As Integer
    iCnt = 0
    sNextFile = Dir$("c:\CSLocal\PDFS\*.pdf*")
    For iCnt = 1 To nFileCnt
       Files_to_Merge(iCnt) = "c:\CSLocal\PDFS\" + sNextFile
       sNextFile = Dir
    Next iCnt
   ' Set file name for output
    sJobKeyPath = strFolderPath + sJobKeyPath + "\LabCust_Result.pdf"
    ' merge all pdfs into
    With oPDF
        '
        TempBool = .Utility_Merge_PDF_Files(sJobKeyPath, Files_to_Merge)
        If Not TempBool Then
            ' NOTES ON ERROR CODES for oPDF.ErrorLastDLL
            ' 401 - One of the Input File could not be opened
            ' 410 - One of the Input File could not be decrypted
            MsgBox "An Error Occured: " & .LastErrorDescription & vbCrLf & _
                     "Error Number =" & Str$(.LastErrorNumber) & vbCrLf & _
                     "DLL Error Number =" & Str$(.ErrorLastDLL), _
                    vbExclamation
        Else
            MsgBox "Merge Successful.", vbInformation
        End If
       
    End With
    'release the resultant pdf for more work below
    ' Add footer with page re-numbering
    With oPDF
    
        TempBool = .Utility_Open_PDF(sJobKeyPath, "")
        TempBool = .Utility_Apply_Text_Stamp("1", "6", "true", "", "", "AIHA Participant 199873             Page <#> of <###>   AAMT Control # F101 Rev. 0 3/5/2010", "4", " [s=010][B=255-255-255]")
        TempBool = .Utility_Close_PDF(sJobKeyPath)
    End With
    Set oPDF = Nothing
-------------------------------------------------------
IP IP Logged
Michel_K17
Moderator Group
Moderator Group
Avatar
Forum Administrator

Joined: 25 Jan 03
Posts: 1673
Quote Michel_K17 Replybullet Posted: 03 Oct 11 at 10:21AM
Thanks for posting the solution! 
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum