|
I have a problem when I generate a document with a water mark in itext. The following code shows as I make it --------------------------------------------------------------------------------------- .... PdfReader reader = new PdfReader ("c:/"+doc.getId_doc()+ ".pdf"); FileOutputStream fo = new FileOutputStream ("c:/firmados/"doc.getId_doc() + ".pdf"); stp = PdfStamper.createSignature (reader, fo, '\0', null, true); Watermark water = new Watermark (Image.getInstance (rutaDestino), 0, 0); water.scalePercent (15); water.setRotationDegrees ( -45); PdfSignatureAppearance sap = stp.getSignatureAppearance (); int n = reader.getNumberOfPages (); PdfContentByte cb = null; water.setBackgroundColor (Image.getInstance (rutaDestino).backgroundColor ()); water.setTransparency (Image.getInstance (rutaDestino).getTransparency ()); int valor_porcentaje = 150; for (int i2 = 1; i2 <= n; i2++) { com.lowagie.text.Rectangle rect2 = reader.getCropBox (i2); if(rect2.width() > 2000 || rect2.height() > 2000) { water.scalePercent(20); valor_porcentaje = 250; } else { if(sello == 1){ water.scalePercent(15); valor_porcentaje = 150; } else water.scalePercent(15); valor_porcentaje = 170; } if (reader.getPageRotation (i2) == 90 || reader.getPageRotation (i2) == 270) { if(rect2.width() < rect2.height()) { water.setAbsolutePosition(rect2.height() - valor_porcentaje, rect2.width() - valor_porcentaje); } else { water.setAbsolutePosition(rect2.width() - valor_porcentaje, rect2.height() - valor_porcentaje); } } else { water.setAbsolutePosition (rect2.width () - valor_porcentaje, rect2.height () - valor_porcentaje); } cb = stp.getOverContent(i2); cb.addImage (water); } //System.out.println ("Marcando pagina " + i2 + "de " + n); sap.setCrypto (key, chain, null, PdfSignatureAppearance.WINCER_SIGNED); sap.setReason ("SELLANDO DOCUMENTO); sap.setLocation ("Madrid"); stp.close (); If I do not add to the water mark the document it opens to me correctly. If I add it it leaves the message to me which it does not find xobject denominated Xi0 To pardon my English Thanks to me for everything |
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
