Bruno Lowagie (iText <bruno <at> lowagie.com> writes:

> 
> jerry wrote:
> 
> > i need to iterate over a PDF document
> 
> You probably mean you want to iterate over the pages of a PDF document.
> 
> > and set the writer to particular pages which contains images.
> 
> I have not idea what you mean when you say you have to 'set the writer'.
> br,
> Bruno
> 
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> 


Hi,


    Yes i want to iterate over the pages of a PDF document.

<set the writer to particular pages which contains images>

i have used the below given code to embed the images into the pdf file.

so first i have to find the pages in the PDF Document which has images

and attach the corresponding image files into that pages.so as to attach 

the image files i have to set the writer to particular pages which contains 

images

code: 
PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(pdfFileName));
                                        // adding some metadata
                                        HashMap moreInfo = new HashMap();
                                                // adding content to each page
                        // int i = Integer.parseInt((String)
JOptionPane.showInputDialog(null,"Please enter the Page No:"));
                                        int i=1;int j=0;
            // while (i < n) {
                ///i++;
                  
                           PdfContentByte cb = stamp.getWriter
().getDirectContent();
                           cb.rectangle(250/*left*/, 250/*top*/,250/*right*/, 
250/*bottom*/);
                           cb.stroke();
                
                           Rectangle rect = new Rectangle(Integer.parseInt
((String)JOptionPane.showInputDialog(null,"Please enter the 
Width")),Integer.parseInt((String)JOptionPane.showInputDialog(null,"Please 
enter the Height")));
                           JFileChooser jff=new JFileChooser();
                           jff.showOpenDialog(null);
                           String images=jff.getSelectedFile().getPath();
                 
                           PdfFileSpecification pf = 
PdfFileSpecification.fileEmbedded(stamp.getWriter(),images, images, null);
                           PdfAnnotation annot = 
PdfAnnotation.createFileAttachment(stamp.getWriter(), rect,"Double-click to 
view image at full size in an external viewer." , pf);
                
                
                           PdfAppearance ap = cb.createAppearance(300, 300);
                           ap.setBoundingBox(rect);
                           ap.setLineWidth(1);
                           annot.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, 
ap);
                           annot.setAppearance(PdfAnnotation.APPEARANCE_DOWN, 
ap);
                           annot.setPage();
                           stamp.addAnnotation(annot, i);
                           //}
                           stamp.close();




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to