[iText-questions] Header not found when using threads / piped streams
When I run the code below I get an IOException - Header signature not found. The reason I'm using that seperate thread is because I'm not using the FileOutputStream in my actual app. I'm using the Piped In/Out Streams (the commented lines). What I'm trying to do is to add some things to an existing pdf and then use PdfBox to convert the resultant pdf to an image. Now, when I run the below code using the Piped Streams I don't get an error. When I try to read in the pdf with PdfBox using the FileStream method I get that same error. When I try to read in the pdf with PdfBox using the PipedStream method it works but the text I have added displays as black. I realize that this could be a problem with the PdfBox library which, of course, has nothing to do with iText but I thought I would post this here just in case there was some glaring error that I'm overlooking. Any help is much appreciated, I've been stumped on this for days. -007 public class test { PdfReader reader = null; public static void main(String[] args) throws IOException{ javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { new test(); } }); } public test() { try { reader = new PdfReader("PathToPdf"); } catch (IOException iox) { iox.printStackTrace(); } try { // PipedInputStream inStream = new PipedInputStream(); // PipedOutputStream outStream = new PipedOutputStream(inStream); FileOutputStream fileStream = new FileOutputStream("PathToNewPdf"); // final PdfStamper stamper = new PdfStamper(reader, outStream); final PdfStamper stamper = new PdfStamper(reader, fileStream); new Thread() { public void run() { PdfContentByte cb = stamper.getOverContent(1); ColumnText textCol = new ColumnText(cb); textCol.setSimpleColumn( 10, 10, 100, 100 ); Font font = null; try { font = new Font(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED), 12, Font.NORMAL, Color.RED); } catch (Exception e) {} Phrase phrase = new Phrase(12, "test", font); textCol.addText(phrase); try { textCol.go(); } catch (Exception e) { e.printStackTrace(); } try { stamper.close(); } catch (Exception x) { x.printStackTrace(); } } }.start(); PdfReader reader2 = new PdfReader("PathToNewPdf"); // PdfReader reader2 = new PdfReader(inStream); } catch (Exception x) { x.printStackTrace(); } } } ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions
[iText-questions] Change Image button field in pre-existing PDF
I see lots of great examples of how to create a new PushButton field and assign an image to it. I am stuck trying to figure out how to read a PDF that has a field already in it and assign a "logo" to the existing field. I am using AcroFields.setField to assign text values to other fields, but I can't figure out how to assign the button image as a result of calling getField, getFieldItem, etc. Is there a way to modify the button image of a field in an existing PDF template? In a worst case, it looks like I could insert a new PushButton in the exact same location as the existing one (and then try to add an image to it), but that doesn't feel "right" to do. This seems like it is either simple and I missing something easy, or impossible... Any help is MUCH appreciated. Thanks, dave ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions
[iText-questions] Embedding fonts directly using PDFGraphics2D..?
Hi, I am using directly an PDFGraphics2D object to "draw" text and images directly in a PDF file. I searched previous posts in this newsgroup and found a couple concerning font-embedding. However, can somebody check if I understood everything correctly ? 1. If I don't use font embedinng it is not garanteed that on the target platform the text in the PDF will be displayed correctly - meaning with the correct font. Is it guaranteed using font embbeding ? (whats the difference between full and subset embedding) ? 2. Using PDFGraphics2D I would like all fonts NEEDED/USED to be automatically embedded. Is this automatic behaviour possible - the default is not to embedd fonts I guess ? Or does one have to embedd fonts at all, and can "draw" the glyphs as shapes instead - this way we wouldn't use a certain font, but shapes (font-independent). Is this totally crazy ? If not, how do I do such a thing ? 3. Are there any Licence Violations if I embedd fonts - I guess not, as only glyphs/shapes are embedded, right ? Cheers, jago ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions
[iText-questions] Text to stamp in a pdf generating on the fly
Hi All, I need to stamp a word on a pdf I am generating on the fly. Anyone can help me? Thanks, -- Cumprts,Carlos Bergueira ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions
[iText-questions] Page Rotation
Hello I read a mail a few days back in which one has told to add /ROTATE 180 info in the page dictionary. Can anyone please tell me that how do you get this page dictionary??? I have tried to get it and add values from PdfWriter.getInfo(), PdfWriter.getGroup() but it hasnt worked. Waiting for the reply, Shoaib __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions
Re: [iText-questions] Embedding fonts directly using PDFGraphics2D..?
java.jago wrote: >1. If I don't use font embedinng it is not garanteed that on the target >platform the text in the PDF will be displayed correctly - meaning with >the correct font. Is it guaranteed using font embbeding ? (whats the >difference between full and subset embedding) ? > > Only the 14 standard Type1 fonts (or a font that gives an identical result) are supposed to be on the target platform. If you embed the font, the description of the glyphs is inside the PDF, so all fonts will be displayed correctly. If you embed the complete font, all glyphs inside the font will be embedded; also the glyphs that are not used. In iText Type1 fonts are always embedded completely. If you embed a font subset, only the glyphs used in the PDF will be embedded. This is what happens in iText when you embed TrueType fonts. >2. Using PDFGraphics2D I would like all fonts NEEDED/USED to be >automatically embedded. Is this automatic behaviour possible - the >default is not to embedd fonts I guess ? > > This depends on the way you defined your FontMapper. >Or does one have to embedd fonts at all, and can "draw" the glyphs as >shapes instead - this way we wouldn't use a certain font, but shapes >(font-independent). > > This is another possibility. With PdfGraphics2D, you can let Java draw the glyphs instead of using a font. If you open the Document Properties->Fonts tab in Adobe Reader, you won't see any font. Of course, this could lead to PDF documents with a very large size... >3. Are there any Licence Violations if I embedd fonts - I guess not, as >only glyphs/shapes are embedded, right ? > There could be license violations, some fonts may not be embedded inside a document. Every font contains some license information. iText can throw an exception if the font may not be embedded due to license restrictions. br, Bruno ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions