FUNCTION AddPageNumberPDF() AS LONG
'http://www.quickpdf.org/forum/add-page-numbers-to-existing-pdf_topic2096.htm
LOCAL myid AS LONG, i AS LONG
LOCAL ph,pw AS DOUBLE
dplLoadFromFile( gLibInstance1&,"sample1_bates.pdf","")
myid = dplAddStandardFont( glibinstance1&,4)
FOR i = 1 TO dplpagecount(gLibInstance1&)
'https://www.debenu.com/docs/pdf_library_reference/SelectedPage.php
dplSelectPage( gLibInstance1&,i)
'https://www.debenu.com/docs/pdf_library_reference/NormalizePage.php
dplNormalizePage( gLibInstance1&,0)
'https://www.debenu.com/docs/pdf_library_reference/SetOrigin.php
dplSetOrigin(gLibInstance1&,1) 'Specifies which page corner to use for the origin: 0 = Bottom left (default), 1 = Top left, 2 = Top right, 3 = Bottom right, Anything else = Bottom left
'https://www.debenu.com/docs/pdf_library_reference/Fonts.php
'https://www.debenu.com/docs/pdf_library_reference/Text.php
'DPLFontType(int InstanceID) 'https://www.debenu.com/docs/pdf_library_reference/FontType.php
'selectfont: Select one of the fonts which have been added to the selected document. The FontID must be a valid ID as returned by one of the Add*Font functions or returned by GetFontID .
dplSelectFont(gLibInstance1&,myid)
'https://www.debenu.com/docs/pdf_library_reference/SetTextSize.php
dplSetTextSize(gLibInstance1&,12) 'Set the size of the text to use for any subsequently drawn text. The text size is always measured in points, even if the measurement units have been changed with SetMeasurementUnits.
dplSetTextColor(gLibInstance1&,1,0,0) 'sets text color to red. NOTE : Each color component has a range of 0.0 to 1.0 and not 0 to 255 like many other libraries.
ph = dplPageWidth(gLibInstance1&)
pw = dplPageHeight(gLibInstance1&)
'for some reason I had to use 70% of pw to get correct width and + 150 to get correct vertical location on bottom of page (else was too high or too far to right to be visible)
dplDrawText( gLibInstance1&,pw *.70 ,ph + 150,"pg1 " & FORMAT$(i)) 'pw - 30, ph - 20, "Page" + format$(i))
NEXT i
dplSaveToFile( gLibInstance1&,"newfile.pdf")
END FUNCTION