|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
set.AnnotationThis code snippet works when it is part of a writer stream
but not stamper Just want to add a clickable highlight to an existing PDF Any ideas as to why???? It fails when you add the Stamper.addAnotation
line I am using Groovy inside Filemaker…. PdfReader
reader; PdfStamper
stamper; reader
= new PdfReader (fm_FileIn) ; stamper
= new PdfStamper(reader, new FileOutputStream( fm_FileOut)); Annotation
annot = new Annotation(35, 60, 65, 80, new
URL("mailto:john@...")) stamper.addAnnotation(annot); stamper.close(); john
renfrew Right Way
Up ------------------------------------------------------------------------------ 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@... 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/ |
|
|
Re: set.AnnotationJohn Renfrew wrote:
> This code snippet works when it is part of a writer stream but not stamper > > Just want to add a clickable highlight to an existing PDF > > Any ideas as to why???? It fails when you add the Stamper.addAnotation line It would also fail if you'd ask a human to add the annotation manually. You'd automatically get the counter-question: "OK, but on what page do you want me to add the annotation?" -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ 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@... 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/ |
|
|
Re: set.AnnotationIf you change it to
Stamper.addAnnotation(annot, 1) - it fails Or PdfStamper.add.Annotation(annot, 1) it fails So I have given it a page. Ask me another question. john renfrew Right Way Up Office +44 1675 475341 Fax +44 1675 475342 Mobile +44 7767 443992 -----Original Message----- From: 1T3XT info [mailto:info@...] Sent: 31 October 2009 10:39 To: Post all your questions about iText here Subject: Re: [iText-questions] set.Annotation John Renfrew wrote: > This code snippet works when it is part of a writer stream but not stamper > > Just want to add a clickable highlight to an existing PDF > > Any ideas as to why???? It fails when you add the Stamper.addAnotation line It would also fail if you'd ask a human to add the annotation manually. You'd automatically get the counter-question: "OK, but on what page do you want me to add the annotation?" -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ---------------------------------------------------------------------------- -- 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@... 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/ ------------------------------------------------------------------------------ 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@... 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/ |
|
|
Re: set.AnnotationJohn Renfrew wrote:
> If you change it to > Stamper.addAnnotation(annot, 1) - it fails > Or > PdfStamper.add.Annotation(annot, 1) it fails > > So I have given it a page. Ask me another question. Have you tried this example: http://1t3xt.be/?X0f9 -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ 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@... 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/ |
|
|
Re: set.AnnotationJohn Renfrew wrote:
> Annotation annot = new Annotation(35, 60, > 65, 80, new URL("mailto:john@...")) A closer look at the code snippet you've sent, reveals that you're mixing up Annotation (for use with PDFs built from scratch only) and PdfAnnotation. The book "iText in Action" explains the difference. -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ 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@... 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/ |
|
|
Re: set.AnnotationReason I have asked the question is that I HAVE the book. But it is out of
date, compared to code snippets on the website. There is no explanation of whether you can or can not do the thing that works with Annotation in stamper using PdfAnnotation. If you woldd be so kind as to point me to the page then I can surely read it myself and not trouble you any more..... john renfrew Right Way Up Office +44 1675 475341 Fax +44 1675 475342 Mobile +44 7767 443992 -----Original Message----- From: 1T3XT info [mailto:info@...] Sent: 31 October 2009 11:22 To: Post all your questions about iText here Subject: Re: [iText-questions] set.Annotation John Renfrew wrote: > Annotation annot = new Annotation(35, 60, > 65, 80, new URL("mailto:john@...")) A closer look at the code snippet you've sent, reveals that you're mixing up Annotation (for use with PDFs built from scratch only) and PdfAnnotation. The book "iText in Action" explains the difference. -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ---------------------------------------------------------------------------- -- 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@... 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/ ------------------------------------------------------------------------------ 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@... 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/ |
|
|
Re: set.AnnotationJohn Renfrew wrote:
> If you would be so kind as to point me to the page then I can surely read it > myself and not trouble you any more..... page 466: An Annotation object is added to the Document object, whereas a PdfAnnotation is added to the PdfWriter instance. You're trying to add an Annotation to PdfStamper. PdfStamper is NOT a Document object, it's a special type of writer. Therefore you need to create a PdfAnnotation, NOT an Annotation. The new examples will be in the second edition (due Summer 2010). -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ 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@... 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/ |
|
|
|
|
|
Re: set.AnnotationI saw too late that the OP went off-list.
This was my answer, accidentally sent to the OP personally. John Renfrew wrote: > So I now have > > stamper.addAnnotation(PdfAnnotation.createLink(writer, new Rectangle > (35,60,30,20), PdfAnnotation.HIGHLIGHT_NONE, "mailto:john@...")); > > or > > stamper.addAnnotation(PdfAnnotation.createLink(stamper, new Rectangle > (35,60,30,20), PdfAnnotation.HIGHLIGHT_NONE, "mailto:john@...")); > > neither work. But am I getting warmer???? Your first reflex should be to look at the API docs: http://1t3xt.info/api/com/lowagie/text/pdf/PdfAnnotation.html#createLink%28com.lowagie.text.pdf.PdfWriter,%20com.lowagie.text.Rectangle,%20com.lowagie.text.pdf.PdfName,%20java.lang.String%29 You're using a createLink() method that creates a link to a "named destination". Is "mailto:john@..." a named destination? No, it isn't! So that's not going to work. You should use something like this to create the PdfAnnotation: PdfAnnotation link = PdfAnnotation.createLink(writer, new Rectangle(35,60,30,20), PdfAnnotation.HIGHLIGHT_NONE, new PdfAction("mailto:john@...")); There are other ways to do it, but this works. Furthermore, you're still not telling the stamper on which page you want to add the annotation. You have something like: stamper.addAnnotation(link); But that doesn't even compile! It should be: stamper.addAnnotation(link, 1); In attachment you can find a working example. -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.Paragraph; import com.lowagie.text.Rectangle; import com.lowagie.text.pdf.PdfAction; import com.lowagie.text.pdf.PdfAnnotation; import com.lowagie.text.pdf.PdfReader; import com.lowagie.text.pdf.PdfStamper; import com.lowagie.text.pdf.PdfWriter; public class AddLink { /** * Creates a PDF file: hello.pdf * @param args no arguments needed */ public static void main(String[] args) throws DocumentException, IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document, baos); document.open(); document.add(new Paragraph("Hello World!")); document.close(); PdfReader reader = new PdfReader(baos.toByteArray()); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("test.pdf")); PdfWriter writer = stamper.getWriter(); PdfAnnotation link = PdfAnnotation.createLink(writer, new Rectangle(35,60,30,20), PdfAnnotation.HIGHLIGHT_NONE, new PdfAction("mailto:john@...?subject=stuff")); stamper.addAnnotation(link, 1); stamper.close(); } } ------------------------------------------------------------------------------ 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@... 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/ |
| Free embeddable forum powered by Nabble | Forum Help |