Stamp not working on some pdfs

Discussions about PDF management.
Locked
rclendenon
Posts: 18
Joined: Tue Mar 20, 2012 4:36 pm

Stamp not working on some pdfs

Post by rclendenon » Wed Jun 06, 2012 3:20 pm

I am using GdPicture.Net 8.5 to date stamp pdfs as they are logged into our software. It works fine on most pdfs, however, lately I have come across some pdfs that do not get stamped. The pdfs that don't work are PDF Version 1.3 (Acrobat 4.x). The ones that do work are PDF Version 1.4 and greater. Is this software not compatible with older versions? Below is the code I am using. I will be glad to provide copies of the pdfs if needed.

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

Any help would be greatly appreciated.

Thanks,
Russell

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Stamp not working on some pdfs

Post by Loïc » Thu Jun 07, 2012 10:51 pm

Hello Russel,
I will be glad to provide copies of the pdfs if needed.
Definitively we need them to investigate.

I suspect a page rotation, a crop box or an graphic state not correctly restored in the document.

Regards,

Loïc

rclendenon
Posts: 18
Joined: Tue Mar 20, 2012 4:36 pm

Re: Stamp not working on some pdfs

Post by rclendenon » Fri Jun 08, 2012 1:19 pm

Loic,

Attached are a copy of a file that will not stamp and one that will.

Thanks for the help,
Russell
Attachments
PDF Files.zip
(1.49 MiB) Downloaded 334 times

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Stamp not working on some pdfs

Post by Loïc » Wed Jun 13, 2012 3:04 pm


Locked

Who is online

Users browsing this forum: No registered users and 1 guest