Hi,
this is the code:
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.png");
watermark_image.setAbsolutePosition(200, 400);
PdfContentByte add_watermark;
while (i < number_of_pages) {
i++;
add_watermark = stamp.getUnderContent(i);
add_watermark.addImage(watermark_image);
}
Read_PDF_To_Watermark.close();
stamp.close();
}
catch (Exception i1) {
i1.printStackTrace();
}
}
I have attached the PDF/A and the watermark:
SampleA.pdf
<http://itext-general.2136553.n4.nabble.com/file/n4659796/SampleA.pdf>
watermark.PNG
<http://itext-general.2136553.n4.nabble.com/file/n4659796/watermark.PNG>
when run this code
stamp.close();
there is this Exception:
java.io.IOException: RandomAccessSource not opened
at
com.itextpdf.text.io.MappedChannelRandomAccessSource.get(MappedChannelRandomAccessSource.java:141)
at
com.itextpdf.text.io.FileChannelRandomAccessSource.get(FileChannelRandomAccessSource.java:97)
at
com.itextpdf.text.io.GetBufferedRandomAccessSource.get(GetBufferedRandomAccessSource.java:91)
at
com.itextpdf.text.io.IndependentRandomAccessSource.get(IndependentRandomAccessSource.java:77)
at
com.itextpdf.text.pdf.RandomAccessFileOrArray.read(RandomAccessFileOrArray.java:225)
at
com.itextpdf.text.pdf.RandomAccessFileOrArray.readFully(RandomAccessFileOrArray.java:247)
at
com.itextpdf.text.pdf.RandomAccessFileOrArray.readFully(RandomAccessFileOrArray.java:241)
at
com.itextpdf.text.pdf.PdfReader.getStreamBytesRaw(PdfReader.java:2469)
at
com.itextpdf.text.pdf.PdfReader.getStreamBytesRaw(PdfReader.java:2506)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:313)
at com.itextpdf.text.pdf.PdfStamper.close(PdfStamper.java:207)
at it.equitaliaservizi.fascicolo.watermark.Test.main(Test.java:50)
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/iText-create-PDF-A-Problem-tp4659694p4659796.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&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