Visual FoxPro 9.0
Code: Select all
*Set up contants
#DEFINE PdfOriginBottomLeft 0
#DEFINE PdfOriginTopLeft 1
#DEFINE PdfOriginTopRight 2
#DEFINE PdfOriginBottomRight 3
#DEFINE PdfTextModeFill 0
#DEFINE PdfTextModeStroke 1
#DEFINE PdfTextModeFillStroke 2
#DEFINE PdfTextModeInvisible 3
#DEFINE PdfTextModeFillPath 4
#DEFINE PdfTextModeOutlinePath 5
#DEFINE PdfTextModeFillStrokePath 6
#DEFINE PdfTextClipPath 7
#DEFINE PdfMeasurementUnitPoint 0
#DEFINE PdfMeasurementUnitMillitmeter 1
#DEFINE PdfMeasurementUnitCentimeter 2
#DEFINE PdfMeasurementUnitInch 3
*Create GdPicture Object
oGdPDF = CREATEOBJECT('GdPicture.GdPicturePDF')
*Apply GdPicture Licenses
oLicense = CREATEOBJECT('GdPicture.LicenseManager')
oLicense.RegisterKEY('XXXXXXXXXXXXXXXXXXXXXXXXX') &&GdPicture Plugin
oLicense.RegisterKEY('XXXXXXXXXXXXXXXXXXXXXXXXX') &&Manage PDF Plugin
*Load file
nResult = oGdPDF.LoadFromFile('c:\test.pdf',.T.) &&.T. loads into memory, allows saving to same name
IF nResult > 0
MESSAGEBOX('Error loading file.' + CHR(13)+'Error Code: ' + TRANSFORM(nResult),0+16,'Drawing Date Stamping')
RETURN .F.
ENDIF
*Set stamp properties
oGdPDF.SetOrigin(PdfOriginBottomRight) && X,Y origin
oGdPDF.SetTextMode(PdfTextModeFill)
oGdPDF.SetMeasurementUnit(PdfMeasurementUnitPoint)
cFont = oGdPDf.AddTrueTypeFont("Arial",.T.,.F.,.F.)
*Get page count
nPageCount = oGdPDF.GetPageCount
LOCAL i
*Cycle through pages
FOR i = 1 TO nPageCount
*Select Page
oGdPdf.SelectPage(i)
*Add Date Stamp
*Set Font Size
nFontSize = 13.5 &&Sets font size to approximately 3/16"
oGdPDF.SetTextSize(nFontSize)
*Set Font color
oGdPDF.SetFillColor_2(255,0,0) &&Sets text color to red
*Assign date to variable
cStamp = 'June 6, 2012'
*Add Date Stamp
oGdPDF.DrawRotatedText(cFont,9,36,cStamp,90)
ENDFOR
*Save File
nResult = oGdPDF.SaveToFile('c:\test_output.pdf')
IF nResult > 0
MESSAGEBOX('Error saving file.' + CHR(13)+'Error Code: ' + TRANSFORM(nResult),0+16,'Drawing Date Stamping')
*Close File
oGdPDF.CloseDocument()
RETURN .F.
ENDIF
*Close File
oGdPDF.CloseDocument()
*Release GdPicture Objects
RELEASE oGdPDF,oLicense
Thanks,
Russell