Tuesday 15 April 2014

Adding external images to PDF using iText -


I have to find out how to add an external image (referenced by a URL) using iText to add PDFs. Is such a thing possible?

In 7.1.5, the PDF device says that you should be able to use a URL specification in a PDF context through a URL. This is what I have so far received:

  PDF file display pdfSpec = PdfFileSpecification.url (author, "http://www.someurl.com/test.jpg"); Stringbuffer input speed sbis = new string buffer input (""); PDFForm = New PDFForm (SBIS, Author); Dict.put (PdfName.FILTER, PdfName.DCTDECODE) dict.put (PdfName.TYPE, PdfName.XOBJECT); Dict.put (PdfName.SUBTYPE, PdfName.IMAGE); Dict.put (pdf. Width, new pdfnm (100)); Dict.put (pdfname.high, new pdfnm (100)); Dict.put (pdfName.bitSPERCOMPONENT, new PDFF (8)); Dict.put (pdfName.LENGTH, new PDFF (0)); Dict.put (pdfn .f, pdfppec); PdfIdirectObject img = writer.addToBody (dict);  

I know that I still need to make sure that color space is added and stuff, but my main concern is just getting this document in the main part of the document. I can not understand how to do this ... It seems that I can not find a PDF page or resource dictionary or anything. Is it possible to use iText?

As a side note, this exercise is useless if I try to load the image image when being presented with a security alert. Does anyone know that this is the case?

The external content is described in the PDF device, but almost the PDF processor actually supports them Acrobat 9 has support for this, but I would be very cautious with that facility: Your customer or user will not be able to see the referenced content.


No comments:

Post a Comment