Hi, I want put the watermark into the pdf, but I receive this error message:
java.lang.NullPointerException
at
com.itextpdf.text.pdf.internal.PdfA1Checker.checkPdfObject(PdfA1Checker.java:304)
at
com.itextpdf.text.pdf.internal.PdfAChecker.checkPdfAConformance(PdfAChecker.java:201)
at
com.itextpdf.text.pdf.internal.PdfAConformanceImp.checkPdfIsoConformance(PdfAConformanceImp.java:70)
at
com.itextpdf.text.pdf.PdfWriter.checkPdfIsoConformance(PdfWriter.java:3380)
at
com.itextpdf.text.pdf.PdfWriter.checkPdfIsoConformance(PdfWriter.java:3376)
at com.itextpdf.text.pdf.PdfDictionary.toPdf(PdfDictionary.java:136)
at
com.itextpdf.text.pdf.PdfIndirectObject.writeTo(PdfIndirectObject.java:157)
at com.itextpdf.text.pdf.PdfWriter$PdfBody.write(PdfWriter.java:424)
at com.itextpdf.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java:402)
at com.itextpdf.text.pdf.PdfWriter.addToBody(PdfWriter.java:886)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:398)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:372)
at com.itextpdf.text.pdf.PdfStamper.close(PdfStamper.java:207)
at WatermarkPDF.main(WatermarkPDF.java:44)
public static void main(String[] args) {
try {
PdfReader Read_PDF_To_Watermark = new PdfReader("C:/SampleA.pdf");
int number_of_pages = Read_PDF_To_Watermark.getNumberOfPages();
PdfAStamper stamp = new PdfAStamper(Read_PDF_To_Watermark, new
FileOutputStream("C:/SampleAWM.pdf"),PdfAConformanceLevel.PDF_A_1A);
int i = 0;
Image watermark_image = Image.getInstance("C:/watermark.jpg");
watermark_image.setAbsolutePosition(200, 400);
PdfContentByte add_watermark;
while (i < number_of_pages) {
i++;
add_watermark = stamp.getUnderContent(i);
add_watermark.addImage(watermark_image);
}
stamp.close();
}
catch (Exception i1) {
i1.printStackTrace();
}
}
AlmavivA Spa (www.almavivaitalia.it<http://www.almavivaitalia.it>)
Divisione IT - Area Pubblica Amministrazione Centrale e Locale
Via di Casal Boccone, 188/190
00137 - Roma
Tel.: 06.39.93.34.79
e-mail: [email protected]<mailto:[email protected]>
[cid:[email protected]]
<<inline: image001.gif>>
------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
