It should work. Does it work if you don't remove the break?

Paulo

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Nathan & Joy
> Sent: Wednesday, September 03, 2008 4:55 PM
> To: itext-questions@lists.sourceforge.net
> Subject: [iText-questions] Acrobat 8 Pro Error: Could not find XObject
>
> Hello,
>
> I'm investigating using this library to strip images out of PDFs and
> replace with different images that also link to a webpage (explaining
> why the images have been replaced).
>
> I have successfully compiled some sample code used to strip images
> from a PDF. However, when I open the PDF in Acrobat Pro, I get the
> following two errors:
> 1) When the first page that had an image replaced is scrolled into
> view: "Could not find XObject named 'Im0'";
> 2) When the next page that had an image replaced is scrolled into
> view: "An error exists on this page. Acrobat may not display the page
> correctly. Please contact the person who created the PDF document to
> correct the problem."
>
> The version of Acrobat I am using is:
> Adobe Acrobat 8 Professional (8.1.2)
>
> My code is:
> import java.io.*;
> import java.util.*;
> import com.lowagie.text.*;
> import com.lowagie.text.pdf.*;
>
> public class itexttest{
>
>         public static void main(String[] args){
>                 try{
>                         PdfReader pdf = new PdfReader(args[0]);
>                         PdfStamper stp = new PdfStamper(pdf,
> new FileOutputStream(args[1]));
>                         PdfWriter writer = stp.getWriter();
>
>                         Image img = Image.getInstance("image.png");
>                         for(int i = 1, l =
> pdf.getNumberOfPages(); i <= l; i++){
>                                 PdfDictionary pg = pdf.getPageN(i);
>                                 if(pg == null){
>
> System.out.println("PDFD null");
>                                         continue;
>                                 }
>
>                                 PdfDictionary res =
> (PdfDictionary)PdfReader.getPdfObject(pg.get(PdfName.RESOURCES));
>                                 PdfDictionary xobj =
> (PdfDictionary)PdfReader.getPdfObject(res.get(PdfName.XOBJECT));
>                                 if (xobj != null) {
>                                         for (Iterator it =
> xobj.getKeys().iterator(); it.hasNext(); ) {
>                                         PdfObject obj =
> xobj.get((PdfName)it.next());
>                                         if (obj.isIndirect()) {
>                                                 PdfDictionary tg =
> (PdfDictionary)PdfReader.getPdfObject(obj);
>                                                 PdfName type =
> (PdfName)PdfReader.getPdfObject(tg.get(PdfName.SUBTYPE));
>
> if(PdfName.IMAGE.equals(type)) {
>
>   PdfReader.killIndirect(obj);
>
>   Image maskImage = img.getImageMask();
>
>   if (maskImage != null)
>
>           writer.addDirectImageSimple(maskImage);
>
> writer.addDirectImageSimple(img,
> (PRIndirectReference)obj);
>                                                         //break;
>                                                       }
>                                            }
>                                         }
>                                 }
>                         }
>                         stp.close();
>                 }catch(Exception e){
>                 System.out.println("Error: " + e.toString());
>                 }
>         }
>
> }
>
>
> If it helps, the lines:
> if (maskImage != null)
>         writer.addDirectImageSimple(maskImage);
> are useless, because for some reason maskImage is always null.
>
> Can anyone help me with my task here?
>
> Thanks!


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to