|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
iText PDF signature
Hello, I am working with iText that comes with CF8 and I don?t see these methods in com.lowagie.text.pdf.PdfSignatureAppearanceChad Gray 03/11/10 05:13 P On 3/12/2010 5:12 AM, Chad Gray wrote:Paul Hastings 03/11/10 08:39 P We're using iText-2.0.7.jar + javaLoader + CF 7 Std with success. PleaseMarco Antonio C. Santos 03/12/10 06:17 A Thanks for the suggestions Paul.Chad Gray 03/12/10 10:45 A Hello, I am working with iText that comes with CF8 and I don?t see these methods in com.lowagie.text.pdf.PdfSignatureAppearance setRenderMode setSignatureGraphic I want to create a signature in a PDF that has an image like this example code is doing: http://itextpdf.com/examples/index.php?page=example&id=221 Anyone figured out how to get an image and description into a PDF signature? If I use the method setImage that is in the CF8 class the image is laid on top of the description and you cannot read it. Thanks, Cha On 3/12/2010 5:12 AM, Chad Gray wrote: > I want to create a signature in a PDF that has an image like this example code is doing: > http://itextpdf.com/examples/index.php?page=example&id=221 that's for the latest version of iText not the one shipped with cf. you can drop the new version into cfs class path or use mark's javaLoader & away you go (but make sure you read the new licensing first). on the plus side is that the new version's class, etc names have changed so no classpath hell w/existing cf version. ---or--- if you want to use the existing version maybe this will help: setRenderingMode ===> setRender "Sets the rendering mode for this signature" setSignatureGraphic ===> setSignatureGraphic (still there), it's looking for a "com.lowagie.text.Image" We're using iText-2.0.7.jar + javaLoader + CF 7 Std with success. Please take a look this code to insert an image and a description in your PDF signed: <cffunction name="signPDF"> <cfargument name="pathPDF" required="yes"> <cfargument name="pathPDFSigned" required="yes"> <cfargument name="pathArqPFX" required="yes"> <cfset var local = StructNew()> <cfset local.pathPDF = arguments.pathPDF> <cfset local.pathPDFSigned = arguments.pathPDFSigned> <cfset local.pathArqPFX = arguments.pathArqPFX> <cfif NOT CompareNoCase(local.pathPDF,local.pathPDFSigned)> <cfreturn false> </cfif> <cfscript> setReason='ACME Corporation'; setPassword='yourPFXPassword'; setLocation='Your City-State'; fullPathToPFXFile = local.pathArqPFX; fullPathToOriginalFile = local.pathPDF; fullPathToSignedFile = local.pathPDFSigned; string = createObject("java","java.lang.String"); passwordSign = string.init(setPassword); keyStore = createObject("java","java.security.KeyStore").getInstance("pkcs12"); privateKey = createObject("java","java.security.PrivateKey"); inputStream = createObject("java","java.io.FileInputStream").init(fullPathToPFXFile); keyStore.load(inputStream, passwordSign.toCharArray()); keyStoreAlias = keyStore.aliases().nextElement(); privateKey = keyStore.getKey(keyStoreAlias, passwordSign.toCharArray()); chainArray = keyStore.getCertificateChain(keyStoreAlias); pdfReader = server[application.javaLoaderInit].create("com.lowagie.text.pdf.PdfReader").init(fullPathToOriginalFile); outStream = createObject("java","java.io.FileOutputStream").init(fullPathToSignedFile); pdfStamper = server[application.javaLoaderInit].create("com.lowagie.text.pdf.PdfStamper"); pdfVersion = string.init(URLDecode('%00')).charAt(0); stamper = pdfStamper.createSignature(pdfReader, outStream, pdfVersion); signatureAppearance = stamper.getSignatureAppearance(); PdfSignatureAppearance = server[application.javaLoaderInit].create("com.lowagie.text.pdf.PdfSignatureAppearance"); signatureAppearance.setCrypto( privateKey, chainArray, javacast("null", 0),PdfSignatureAppearance.WINCER_SIGNED); signatureAppearance.setReason(setReason); signatureAppearance.setLocation(setLocation); rectangle = server[application.javaLoaderInit].create("com.lowagie.text.Rectangle").init( javacast("float", 100), javacast("float", 100), javacast("float", 200), javacast("float", 200) ); signatureAppearance.setVisibleSignature( rectangle, javacast("int", 1), javacast("null", "") ); signatureAppearance.setCertificationLevel(signatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED); stamper.close(); inputStream.close(); pdfReader.close(); outStream.close(); return true; </cfscript> </cffunction> Cheers Marco Antonio On Thu, Mar 11, 2010 at 7:12 PM, Chad Gray <cgray@careyweb.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- Thanks for the suggestions Paul. I don?t see any setRender or setSignatureGraphic method. Are you on CF9? Maybe that is the difference. All I have is setImage and setImageScale. These lay an image behind the text in the signature. I did find that I can do setLayer2Text to blank and it will clear the type on top of the image. So maybe that is the route I will go. I really don?t feel like monkey'ing around with replacing iText in CF8. Thanks again, Chad On 3/12/2010 5:12 AM, Chad Gray wrote: > I want to create a signature in a PDF that has an image like this example code is doing: > http://itextpdf.com/examples/index.php?page=example&id=221 that's for the latest version of iText not the one shipped with cf. you can drop the new version into cfs class path or use mark's javaLoader & away you go (but make sure you read the new licensing first). on the plus side is that the new version's class, etc names have changed so no classpath hell w/existing cf version. ---or--- if you want to use the existing version maybe this will help: setRenderingMode ===> setRender "Sets the rendering mode for this signature" setSignatureGraphic ===> setSignatureGraphic (still there), it's looking for a "com.lowagie.text.Image"
|
July 31, 2010
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||