> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of aqeel saifi
> Sent: Thursday, November 02, 2006 1:10 PM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] Modifying the images in PDF
> 
> Apologies, It was a mistake at my part. I was replacing the 
> whole XObject.
> 
> Yes i can reuse the image to place else where in document, 
> But I would like to save the contained image as physical 
> image file, may be in JPEG.

Not possible with iText. Look for jpedal or pdfbox.

Paulo

> Is it achievable with iText? Please provide a code snippet, 
> if possible.
> 
> Thanks
> aqueeL
> 
> Paulo Soares <[EMAIL PROTECTED]> wrote:
> 
> 
> 
>       > -----Original Message-----
>       > From: [EMAIL PROTECTED] 
>       > [mailto:[EMAIL PROTECTED] On 
>       > Behalf Of aqeel saifi
>       > Sent: Thursday, November 02, 2006 11:54 AM
>       > To: Post all your questions about iText here
>       > Subject: Re: [iText-questions] Modifying the images in PDF
>       > 
>       > Hi,
>       > I tried it but just doing this didn't suffice, as in content 
>       > i am (still) refering to a non-existing XObject. To do this I 
>       > am removing the XObject from resource of page2 (say) and 
>       > putting the XObject to this resource.
>       
>       I don't see why it wouldn't work. Say you have the 
> following in the XObject resource:
>       
>       /x1 1 0 R
>       /x2 2 0 R
>       /x3 3 0 R
>       
>       Your objective is to have the /x1 image duplicated in 
> the other images. The end result would be:
>       
>       /x1 1 0 R
>       /x2 1 0 R
>       /x3 1 0 R
>       
>       This will also work across pages.
>       
>       > Also I am facing one more problem. Is there any I can create 
>       > image from the image data in pdf? I have searched archives 
>       > for related issues, and found quite a few but none of them 
>       > leads to solution.
>       > As below I am trying to get the data from PRStream but not 
>       > able to created image, even if stream is filtered. What 
>       > addition I need to do to get the image from this stream?
>       
>       You can reuse an image with 
> Image.getInstance(PRIndirectReference).
>       
>       Paulo
>       
>       > 
>       > 
>       > Thanks
>       > aqueel
>       > 
>       > Paulo Soares wrote:
>       > 
>       > Replace the reference in Resources/XObject to the other 
>       > images with your image, that is already present in the PDF.
>       > 
>       > Paulo
>       > 
>       > ________________________________
>       > 
>       > De: [EMAIL PROTECTED] em 
>       > nome de aqeel saifi
>       > Enviada: qua 01-Nov-06 06:27
>       > Para: Post all your questions about iText here
>       > Assunto: Re: [iText-questions] Modifying the images in PDF
>       > 
>       > 
>       > Thanks a lot Paulo.
>       > This worked fine for the pre-existing image file. I was 
>       > trying to get image data from pdf and replacing the others 
>       > with this image, but failed to do so. My code is as follows...
>       > 
>       > PdfDictionary pg = reader.getPageN(i + 1);
>       > PdfDictionary res = 
>       > 
> (PdfDictionary)PdfReader.getPdfObject(pg.get(PdfName.RESOURCES));
>       > PdfDictionary xobj = 
>       > 
> (PdfDictionary)PdfReader.getPdfObject(res.get(PdfName.XOBJECT));
>       > byte[] imageData = null;
>       > 
>       > 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)) {
>       > imageData = PdfReader.getStreamBytesRaw((PRStream) obj);
>       > }
>       > }
>       > }
>       > }
>       > 
>       > Image img = Image.getInstance(imageData ); // here it 
>       > the problem
>       > 
>       > .......
>       > Code to replace the image
>       > .......
>       > 
>       > The problem, i believe lies, in getting image data from 
>       > PdfReader. getStreamBytesRaw just returns raw data, not 
>       > neccecarily in format image is expecting.
>       > Is it possible to get image data from pdf to recreate 
>       > the image? 
>       > 
>       > Thanks
>       > aqueel
>       > 
>       > 
>       > 
>       > 
>       > 
>       > 
>       > ----- Original Message ----
>       > From: Paulo Soares 
>       > To: Post all your questions about iText here 
>       > Sent: Tuesday, 31 October, 2006 4:35:07 PM
>       > Subject: Re: [iText-questions] Modifying the images in PDF
>       > 
>       > 
>       > Here's the code to replace images in PDFs. It will replace 
>       > the first image in the first page.
>       > 
>       > PdfReader pdf = new PdfReader("in.pdf");
>       > PdfStamper stp = new PdfStamper(pdf, new
>       > FileOutputStream("c:\\out.pdf"));
>       > PdfWriter writer = stp.getWriter();
>       > Image img = Image.getInstance("image.png");
>       > PdfDictionary pg = pdf.getPageN(1);
>       > 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(); 
>       > 
>       > Paulo
>       > 
>       > > -----Original Message-----
>       > > From: [EMAIL PROTECTED] 
>       > > [mailto:[EMAIL PROTECTED] On 
>       > > Behalf Of aqeel saifi
>       > > Sent: Tuesday, October 31, 2006 7:44 AM
>       > > To: itext-questions@lists.sourceforge.net
>       > > Subject: [iText-questions] Modifying the images in PDF
>       > > 
>       > > Hi All,
>       > > As far as I have digged, we can not directly modify the 
>       > > images in pdf file with iText. Although we can get 
> the image 
>       > > data from the XObject. right?
>       > > Actually I intend to create a new pdf from an existing one 
>       > > with some of the contained images changed/repalced 
>       > with some other.
>       > > As we can't replace image directly with iText, I have two 
>       > > options in mind to achieve this.
>       > > a. Is it possible that I render the changed image 
> (different 
>       > > image) on the existing image position to give the 
> effect that 
>       > > image is actually changed.
>       > > b. Other could be, if possible, I create new pdf from the 
>       > > existing one and all the pdf objects to new one except the 
>       > > images to be modified. In place of these images I 
> can add my 
>       > > changed images to new pdf.
>       > > 
>       > > Please guide if any of this is feasible, please 
> share if you 
>       > > have any other option in mind.
>       > > 
>       > > Any help would be greatly appreciated.
>       > > 
>       > > Thanks
>       > > aqueel
>       > > 
>       > > ________________________________
>       > > 
>       > > Find out what India is talking about on - Yahoo! Answers 
>       > > India 
>       > > 
>       > > hoo.com/> 
>       > > Send FREE SMS to your friend's mobile from Yahoo! Messenger 
>       > > Version 8. Get it NOW 
>       > > 
>       > > ssenger.yahoo.com> 
>       > > 
>       > 
>       > 
>       > 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.
>       > 
>       > 
>       > 
>       > 
>       > --------------------------------------------------------------
>       > -----------
>       > 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
>       > iText-questions@lists.sourceforge.net
>       > https://lists.sourceforge.net/lists/listinfo/itext-questions
>       > 
>       > 
>       > 
>       > ________________________________
>       > 
>       > Find out what India is talking about on - Yahoo! 
> Answers India 
>       > Send FREE SMS to your friend's mobile from Yahoo! 
>       > Messenger Version 8. Get it NOW 
>       > 
>       > 
>       > 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.
>       > 
>       > 
>       > --------------------------------------------------------------
>       > -----------
>       > 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
>       > iText-questions@lists.sourceforge.net
>       > https://lists.sourceforge.net/lists/listinfo/itext-questions
>       > 
>       > 
>       > 
>       > ________________________________
>       > 
>       > Find out what India is talking about on - Yahoo! Answers 
>       > India 
>       > 
>       > hoo.com/> 
>       > Send FREE SMS to your friend's mobile from Yahoo! Messenger 
>       > Version 8. Get it NOW 
>       > 
>       > ssenger.yahoo.com> 
>       > 
>       
>       
>       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.
>       
>       
> --------------------------------------------------------------
> -----------
>       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
>       iText-questions@lists.sourceforge.net
>       https://lists.sourceforge.net/lists/listinfo/itext-questions
>       
> 
> 
> ________________________________
> 
> Find out what India is talking about on - Yahoo! Answers 
> India 
> <http://us.rd.yahoo.com/mail/in/yanswers/*http://in.answers.ya
> hoo.com/>  
> Send FREE SMS to your friend's mobile from Yahoo! Messenger 
> Version 8. Get it NOW 
> <http://us.rd.yahoo.com/mail/in/messengertagline/*http://in.me
> ssenger.yahoo.com> 
> 


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.

-------------------------------------------------------------------------
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
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to