You are using a GOTOEMBEDDED action (aka PdfAction.gotoEmbedded!). You need a LAUNCH action.
-----Original Message----- From: vickatvuuch [mailto:[email protected]] Sent: Sunday, September 13, 2009 4:06 PM To: [email protected] Subject: Re: [iText-questions] How-to embed Word document and make a clickable thumnail image to launch MS Word Leonard, I see that the data is embedded in the file (looking at it in textpad) and I do use actions, but when I click on thumbnail of the attachment image nothing happens on the click, there is some disconnect between an action and the embedded file descriptor, take a look at the code below: Do you see where it might not be done right? private Chunk createAttachmentChunk(PdfWriter docWriter, MediaBase att, String type) { URL url = new URL("${grailsApplication.config.baseUrl}" + type + "/downloadByName/${att.id}_${att.fileName}"); byte[] b = loadBytesFromURL(url); PdfFileSpecification pdfSpec = PdfFileSpecification.fileEmbedded(docWriter, att.fileName, att.title, b, false); Image imageAttachment = Image.getInstance(new URL("${grailsApplication.config.baseUrl}images/icons/attachment.png")); imageAttachment.scaleToFit(40, 40); imageAttachment.setAlignment(1); PdfTargetDictionary target = new PdfTargetDictionary(true); target.setEmbeddedFileName(att.fileName); PdfDestination dest = new PdfDestination(PdfDestination.FIT); dest.addFirst(pdfSpec.getReference()); PdfTargetDictionary intermediate = new PdfTargetDictionary(true); intermediate.setAdditionalPath(target); PdfAction action = PdfAction.gotoEmbedded(att.fileName, intermediate, dest, true); Chunk ck = new Chunk(imageAttachment, 0, -5); ck.setAction(action); return ck; } Leonard Rosenthol-3 wrote: > > I've already told you what you need to do - use a Launch action. Why you > refuse to take my advice is beyond me... > > Leonard > > -----Original Message----- > From: vickatvuuch [mailto:[email protected]] > Sent: Sunday, September 13, 2009 3:40 PM > To: [email protected] > Subject: Re: [iText-questions] How-to embed Word document and make a > clickable thumnail image to launch MS Word > > > Thanks for the info, but then why would I need an API like iText, if I > learn > all the constructs at the byte level, I could make up a PDF file without > iText isn't it? Its sort of like you would say before you can store data > in > the Oracle table you'd need to figure out how they partition their indexes > and also how then physical data is written and looked up.. > My latest experiment led me to the code below, which in my understanding > would embed the word document at the top level and attach an action onto > the > Chunk holding thumbail image. > However it attaches it, but the action doesn't do anything, although the > image is clickable now. > > private Chunk createAttachmentChunk(PdfWriter docWriter, MediaBase > att, > String type) { > > URL url = new URL("${grailsApplication.config.baseUrl}" + type + > "/downloadByName/${att.id}_${att.fileName}"); > > byte[] b = loadBytesFromURL(url); > > PdfFileSpecification pdfSpec = > PdfFileSpecification.fileEmbedded(docWriter, att.fileName, > att.title, > b, true); > > docWriter.addFileAttachment(pdfSpec); > > Image imageAttachment = Image.getInstance(new > URL("${grailsApplication.config.baseUrl}images/icons/attachment.png")); > > imageAttachment.scaleToFit(40, 40); > imageAttachment.setAlignment(1); > > PdfTargetDictionary target = new PdfTargetDictionary(true); > target.setEmbeddedFileName(att.fileName); > > PdfDestination dest = new PdfDestination(PdfDestination.FIT); > dest.addFirst(pdfSpec.getReference()); > > //intermediate.setAdditionalPath(target); > > PdfTargetDictionary intermediate = new PdfTargetDictionary(true); > intermediate.setAdditionalPath(target); > > PdfAction action = PdfAction.gotoEmbedded(att.fileName, intermediate, > dest, true); > > //imageAttachment.setAdditional(pdfSpec); > > //imageAttachment.setOriginalData(b); > > //PdfAnnotation annot = PdfAnnotation.createFileAttachment(docWriter, > new Rectangle(0,0,0,0), > // att.fileName, b, "", att.title); > > //imageAttachment.setAnnotation(annot); > > Chunk ck = new Chunk(imageAttachment, 0, -5); > ck.setAction(action); > //ck.setAnchor(url); > > return ck; > } > > > > Leonard Rosenthol-3 wrote: >> >> I think you need to read the PDF Reference/ISO 32000-1 to understand the >> options available to you - also having a program like Adobe Acrobat >> Professional where you can interactively build a working PDF would be a >> HUGE help. >> >> After you've built a working sample - THEN you can use that information >> to >> program it in iText. >> >> Leonard >> >> -----Original Message----- >> From: vickatvuuch [mailto:[email protected]] >> Sent: Sunday, September 13, 2009 1:09 PM >> To: [email protected] >> Subject: Re: [iText-questions] How-to embed Word document and make a >> clickable thumnail image to launch MS Word >> >> >> I added the pdf screenshot. As you can see, I have Chunk objects with a >> scaled down Image in it. >> At this point I ck.setAnchor(url); which makes it clickable and it >> fetched >> an image or word document >> from the server and opens it up. >> All attempts to embed the attachment data and use that stand-alone didn't >> work. In one case my thumbnail image disapears in another the whole >> document >> gets screwed up. >> >> Steps I tried to follow: >> //get attachment as byte array >> byte[] b = loadBytesFromURL(url); >> >> //created embedded file spec giving it byte array title and >> name >> PdfFileSpecification pdfSpec = >> PdfFileSpecification.fileEmbedded(docWriter, att.fileName, >> att.title, >> b, true); >> //add file level attachment to the pdf using above spec >> docWriter.addFileAttachment(pdfSpec); >> >> //create action to go to the embedded >> PdfAction action = PdfAction.gotoEmbedded(att.fileName, >> pdfSpec, >> dest, true); >> >> //finally attach action to the Chunk wrapping thumnail image >> >> Chunk ck = new Chunk(imageAttachment, 0, -5); >> chunk.setAction(action); >> >> As a result of the above, my document thumbnail image disapears, only >> image >> title is visiable and and its not clickable.. >> >> >> vickatvuuch wrote: >>> >>> >>> >>> 1T3XT info wrote: >>>> >>>> Leonard Rosenthol wrote: >>>>> Without seeing a final PDF page of what you are intending, my personal >>>>> recommendation is to look at the new Portfolio features of Acrobat 9 >>>>> (PDF 1.7-ADBE-3) for incorporating non-PDF content into your >>>>> documents. >>>>> >>>>> If you want to put the content directly inline (vs. the portfolio >>>>> model), then you want to be using Launch actions for your link >>>>> annotations. >>>> >>>> For inspiration, take a look at >>>> http://lowagie.com/itextwiki/doku.php/collections >>>> -- >>>> This answer is provided by 1T3XT BVBA >>>> http://www.1t3xt.com/ - http://www.1t3xt.info >>>> >>>> ------------------------------------------------------------------------------ >>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>>> 30-Day >>>> trial. Simplify your report design, integration and deployment - and >>>> focus on >>>> what you do best, core application coding. Discover what's new with >>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>>> _______________________________________________ >>>> iText-questions mailing list >>>> [email protected] >>>> 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/ >>>> >>>> >>> http://www.nabble.com/file/p25424948/pdfScreen.jpg >>> http://www.nabble.com/file/p25424948/pdfScreen.JPG pdfScreen.JPG >>> >> >> -- >> View this message in context: >> http://www.nabble.com/How-to-embed-Word-document-and-make-a-clickable-thumnail-image-to-launch-MS-Word-tp25424592p25425068.html >> Sent from the iText - General mailing list archive at Nabble.com. >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and >> focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> iText-questions mailing list >> [email protected] >> 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/ >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and >> focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> iText-questions mailing list >> [email protected] >> 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/ >> >> > > -- > View this message in context: > http://www.nabble.com/How-to-embed-Word-document-and-make-a-clickable-thumnail-image-to-launch-MS-Word-tp25424592p25426421.html > Sent from the iText - General mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > iText-questions mailing list > [email protected] > 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/ > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > iText-questions mailing list > [email protected] > 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/ > > -- View this message in context: http://www.nabble.com/How-to-embed-Word-document-and-make-a-clickable-thumnail-image-to-launch-MS-Word-tp25424592p25426668.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list [email protected] 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/ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list [email protected] 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/
