Thanks Paolo, but is not so easy. Some signatures don't cover all the document, but continue beeing valid ones. I think iText does not cover all possible cases involving signature validation...
-----Missatge original----- De: itext-questions-requ...@lists.sourceforge.net [mailto:itext-questions-requ...@lists.sourceforge.net] Enviat: miércoles, 21 de octubre de 2009 21:24 Per a: itext-questions@lists.sourceforge.net Tema: iText-questions Digest, Vol 41, Issue 78 Send iText-questions mailing list submissions to itext-questions@lists.sourceforge.net To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/itext-questions or, via email, send a message with subject or body 'help' to itext-questions-requ...@lists.sourceforge.net You can reach the person managing the list at itext-questions-ow...@lists.sourceforge.net When replying, please edit your Subject line so it is more specific than "Re: Contents of iText-questions digest..." Today's Topics: 1. Re: PDF signature validation problems (Paulo Soares) 2. Re: iText Font (1T3XT info) 3. How to set the page number of a specific page? (Sorin Marti) 4. Re: Help (thulasi ram) 5. Re: Modifying the value of forms in a PDF document, update! (Brown, Berlin [GCG-PFS]) ---------------------------------------------------------------------- Message: 1 Date: Wed, 21 Oct 2009 17:44:32 +0100 From: Paulo Soares <psoa...@glintt.com> Subject: Re: [iText-questions] PDF signature validation problems To: Post all your questions about iText here <itext-questions@lists.sourceforge.net> Message-ID: <0cfe9e34dd5ac241ab9092abd1f391ff27ffeb1...@glinttmail.glintt.com> Content-Type: text/plain; charset="utf-8" There's a method in AcroFields to check if the signature covers all the document. If it doesn't you may flag it as invalid. Paulo > -----Original Message----- > From: ?urea Alcaide [mailto:aalca...@catcert.cat] > Sent: Wednesday, October 21, 2009 5:16 PM > To: itext-questions@lists.sourceforge.net > Subject: [iText-questions] PDF signature validation problems > > Hi all, > > > > I have come to a problem about the validation of PDF > signatures. The extraction of the signed data from the PDF is > not the same with iText than with Adobe. > > If I?m not wrong, iText takes the ?/ByteRange? associated to > a signature to calculate the digest of the data. In some > cases, is possible to modify the data of the PDF (for example > with form?s fields), without these changes affecting the > ByteRange. But the visualization of the document changes, so > if there is a signature which covers that form field, the > signature should be considered invalid. If the changes in the > form field are included at the end of the document, it does > not affect the ByteRange, so iText is not able to detect > these changes. The problem is that Adobe does. So, Adobe and > iText are returning different validation results. > > > > In the attachment, I send you 2 documents, for making it more > understandable: > > > > test1.pdf ? PDF document certified and with 2 signatures, > each one covering different parts of the form. > > test2.pdf ? The same PDF but with the form field ?Name? > modified. iText says all signatures are valid. Adobe > recognizes the changes, and invalidates the signature which > covers that form field. If you look inside the PDF, you will > see that changes are included at the end of the document, so > do not affect the ByteRanges of any signature. > > > > My question is if has someone else got this problem, and if > so, if there is any way to reach it within the actual iText > last version? Or we will have to wait to a future > implementation of the feature? If it is an actual bug, will > it be reached in the future? > > > > Thanks in advance to you all, > > > > ?urea > > > > 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. ------------------------------ Message: 2 Date: Wed, 21 Oct 2009 19:00:30 +0200 From: 1T3XT info <i...@1t3xt.info> Subject: Re: [iText-questions] iText Font To: Post all your questions about iText here <itext-questions@lists.sourceforge.net> Message-ID: <4adf3e2e.3090...@1t3xt.info> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Greg Tomkins wrote: > Good Afternoon, > > I do not see this question covered anywhere: > > I want to have a basic table but (in some cases) I want the size of the > font used to render text within cells to shrink to fit the column width, > rather than wrap onto a second line or otherwise expand the size of the > cell. Any thoughts on this? This can't be done automatically. You need to define absolute column widths (no relative values, no width percentage for the table). Then you need to measure each piece of text you're adding to a cell. If the length < the column width, you either choose a smaller font (this is preferred), or you scale the Chunk (if the scaling factor doesn't deform the text too much). Another way to do this, is to use empty cells with a fixed height, and to pass the content to a cell event. The cell event gets a Rectangle object defining the size and position of the cell. There are different ways to fit the content in such a rectangle. > Bruno, if you read this, congratulations on a truly outstanding book. > And probably outstanding product, too, though I am just starting with it. A second edition is been written as we speak. It will be totally different from the first book, the aim is to have a complementary book that covers the same topics, but from a different angle (including the new features that have been added in the last 3 years). -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------ Message: 3 Date: Wed, 21 Oct 2009 19:29:08 +0200 From: Sorin Marti <sorin.ma...@gmail.com> Subject: [iText-questions] How to set the page number of a specific page? To: Post all your questions about iText here <itext-questions@lists.sourceforge.net> Message-ID: <d41c3bd10910211029k4edf909bs9928b3048dc42...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi all I have a generated document where I like to have a table of contents with page links. This works fine when i generate the toc as last page and then reorder the pages, shifting the last page (toc) to the second (page after title page). Right after creating the document and getting the writer instance i set the page Event writer.setPageEvent(new MyHeaderFooter(<various unrelated params>); In the MyHeaderFooter class I override the onEndPage method. public void onEndPage(final PdfWriter writer, final Document document) { // code to print header and footer if(printPageNumber) { // I print out the page number here } } In the printed document i see the page numbers as following: 1 [number of last page] 3 4 [and so on to last page] I would like now to change the [number of last page] to 2, so I can print it. I helped myself with just not printing the page number on the page by setting a member variable in MyHeaderFooter before printing the toc at the end... But i really would like to print the number if possible. So: How can I set a page number to a specific page? Thanks for any hint Sorin ------------------------------ Message: 4 Date: Wed, 21 Oct 2009 14:10:53 -0500 From: thulasi ram <pthulasi...@gmail.com> Subject: Re: [iText-questions] Help To: Post all your questions about iText here <itext-questions@lists.sourceforge.net> Message-ID: <9cdb19f30910211210u40e9e1a2u3413fac1b9ab0...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Thanks for ur response. I have one more issue. I have multipage color tiff, while i'm using Image.*getInstance write to pdf file always getting single page pdf file.* ** *If i'll use *Image.*getInstance i can able to read color tiff images but i'm not able to create multipage pdf file.* *If I'll use *Image.*getTiffImage i can't able to read color tiff iamges. * *Can any one let me know how get multipage pdf file using **Image.getInstance. Its posible to color Tiff to pdf file using iText?* *Here is my code.* tempFile = new File(finalPath); FileOutputStream fileOutputStream = new FileOutputStream(tempFile); byte[] read = new byte[input.available()]; File cacheFile = new File(finalPath1); FileOutputStream bos = new FileOutputStream(cacheFile); ByteArrayOutputStream outfile = new ByteArrayOutputStream(); Document document = new Document(PageSize.A4.rotate()); PdfWriter writer = PdfWriter.getInstance(document, bos); writer.setStrictImageSequence(true); document.open(); Image tiff = Image.getInstance(read); tiff.scaleToFit(800, 600); document.add(tiff); document.close(); outfile.flush(); On Mon, Oct 19, 2009 at 3:39 PM, Paulo Soares <psoa...@glintt.com> wrote: > Not only that, if you use a stream it's read to a byte array. Use a file > instead. > > Paulo > > ----- Original Message ----- > From: "Mark Storer" <msto...@autonomy.com> > To: "Post all your questions about iText here" > <itext-questions@lists.sourceforge.net> > Sent: Monday, October 19, 2009 9:24 PM > Subject: Re: [iText-questions] Help > > > Give the JVM more memory when you create it: > http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html > > This has almost nothing to do with iText, and everything to do with Java. > > > --Mark Storer > Senior Software Engineer > Cardiff.com > > #include <disclaimer> > typedef std::Disclaimer<Cardiff> DisCard; > > -----Original Message----- > From: thulasi ram [mailto:pthulasi...@gmail.com] > Sent: Monday, October 19, 2009 11:15 AM > To: itext-questions@lists.sourceforge.net > Subject: [iText-questions] Help > > Hi all, > I'm using iText Tiff2pdf method for converting Tiff to image pdf. I'm > getting "Outofmemory" error while converting large size (morethen 5MB) > images in the line of > ra = *new* RandomAccessFileOrArray(inStream);. > Can any one help how to create pdf for large size Tiff images. > > Thanks, > Ram > > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > 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 > Check the site with examples before you ask questions: > http://www.1t3xt.info/examples/ > You can also search the keywords list: > http://1t3xt.info/tutorials/keywords/ > -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 5 Date: Wed, 21 Oct 2009 15:24:54 -0400 From: "Brown, Berlin [GCG-PFS]" <berlin.br...@primerica.com> Subject: Re: [iText-questions] Modifying the value of forms in a PDF document, update! To: "Brown, Berlin [GCG-PFS]" <berlin.br...@primerica.com>, itext-questions@lists.sourceforge.net Cc: Berlin Brown <berlin.br...@gmail.com> Message-ID: <c30bf131a023ea4d976727cd4fc563fe063c9...@corp-msg-01.pfshq.com> Content-Type: text/plain; charset="us-ascii" ________________________________ From: Brown, Berlin [GCG-PFS] Sent: Wednesday, October 21, 2009 10:22 AM To: Brown, Berlin [GCG-PFS]; 'itext-questions@lists.sourceforge.net' Cc: 'Berlin Brown' Subject: RE: Modifying the value of forms in a PDF document, update! I am able to read the PDF document and all of that works fine. I am NOW having a problem trying to position NEW text near an existing form field. ColumnText ct = new ColumnText(canvas); float[] f = form.getFieldPositions("Text2"); ct.setSimpleColumn(f[1], f[2], f[3], f[4]); For example, with this code, the setSimpleColumn doesn't seem to be in a position I want. It could be that I am using 'ColumnText' ------------ "Your questions up till now didn't get much response because they are phrased in a rather autistic way (I know because I'm an autist myself). " I thought presenting the code, the snippets, "close enough" wording. I thought that might help. ----------------- OK, I figured out the problem. This code was causing the problem where the new text I wanted to display would not appear on the document. ColumnText ct = new ColumnText(canvas); float[] f = form.getFieldPositions("Text2"); ct.setSimpleColumn(f[1], f[2], f[3], f[4]); The result of "getFieldPositions" was off because apparently the PDF document I read or something made the document rotate so the absolute x/y positions I wanted to use were off. Sometimes the text would not display on the document. I changed the code above to code below: ColumnText ct = new ColumnText(canvas); float[] f = form.getFieldPositions("Text2"); ct.setSimpleColumn(f[2], rotHeight-f[1], f[4], rotHeight-f[3]); And that positions my text exactly where I want it to. Next Problem: I have another problem, hopefully I will solve it myself but I will ask anyway in case the problem comes up for someone else. Now, using the 'ColumnText' object, how can I get my alignment to center. Here are two variantions of my code. Neither work, "align my text" within the columntext bounding box. ------------ Variation 1: StyleSheet styles = new StyleSheet(); styles.loadTagStyle("p", "size", size + "px"); styles.loadTagStyle("p", "align", "center"); styles.loadTagStyle("p", "hyphenation", "en_us"); styles.loadTagStyle("p", "width", "100%"); ArrayList<Element> objects = HTMLWorker.parseToList(new StringReader(s), styles); ColumnText ct = new ColumnText(canvas); ct.setSimpleColumn(f[2], rotHeight-f[1], f[4], rotHeight-f[3]); ct.setAlignment(Element.ALIGN_CENTER); for (Element element : objects) { final Chunk cz = new Chunk("___ABC_____", F1); cz.setFont(F1); final Phrase jj = new Phrase(cz); ct.addElement(jj); } ct.go(); ------------ Variation 2: StyleSheet styles = new StyleSheet(); styles.loadTagStyle("p", "size", size + "px"); styles.loadTagStyle("p", "align", "center"); styles.loadTagStyle("p", "hyphenation", "en_us"); styles.loadTagStyle("p", "width", "100%"); ArrayList<Element> objects = HTMLWorker.parseToList(new StringReader(s), styles); ColumnText ct = new ColumnText(canvas); ct.setSimpleColumn(f[2], rotHeight-f[1], f[4], rotHeight-f[3]); ct.setAlignment(Element.ALIGN_CENTER); for (Element element : objects) { final Paragraph p1 = new Paragraph( "__Test__", F1); final PdfPTable table = new PdfPTable(2); final PdfPCell cell = new PdfPCell(p1); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); ct.addElement(table); } ct.go(); In variation 1 code, the text displays, the text is left aligned. I want to display the code center aligned within the bounding box used by setSimplecolumn. In variation 2 code, the text does not display at all. -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ------------------------------ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions End of iText-questions Digest, Vol 41, Issue 78 *********************************************** ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ 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 Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/