And I don't.. Thanks for you help though, you really got me to read that
Adobe spec, which
turns out wasn't needed, but I got a taste of it and must thank Bruno for
wrapping it all up.
Now, here is the solution to benefit all those that yet to run into it:
This method takes docWriter and attachmentThumbnail and returns
a Chunk that points to an embedded byte array, all that I needed.
Ignore MediaBase and type, these are specific to my app, but it should be
obvious anyway.
private Chunk createAttachmentChunk(PdfWriter docWriter, MediaBase att,
String type, Image attachmentThumbnail) {
URL url = new URL("${grailsApplication.config.baseUrl}" + type +
"/downloadByName/${att.id}_${att.fileName}");
byte[] b = loadBytesFromURL(url);
PdfFileSpecification pdfSpec =
PdfFileSpecification.fileEmbedded(docWriter, att.id +
att.fileName,
att.id + att.fileName, b, true);
PdfAnnotation annot = PdfAnnotation.createFileAttachment(docWriter,
new Rectangle(10,10,10,10), att.fileName, pdfSpec);
PdfContentByte cb = docWriter.getDirectContent();
PdfAppearance ap = cb.createAppearance(300, 300);
ap.setBoundingBox(attachmentThumbnail);
ap.setLineWidth(1);
annot.setAppearance(PdfAnnotation.APPEARANCE_NORMAL,ap);
annot.setAppearance(PdfAnnotation.APPEARANCE_DOWN, ap);
Chunk ck = new Chunk(attachmentThumbnail, 0, -5);
ck.setAnnotation(annot);
return ck;
}
Leonard Rosenthol-3 wrote:
>
> I give up!
>
> -----Original Message-----
> From: vickatvuuch [mailto:[email protected]]
> Sent: Sunday, September 13, 2009 6:58 PM
> To: [email protected]
> Subject: Re: [iText-questions] How-to embed Word document and make a
> clickable thumnail image to launch MS Word
>
>
> ok, so you agree that launch is not gonna do it; how about
> PdfAction.gotoEmbedded what it's made for?
>
>
> Leonard Rosenthol-3 wrote:
>>
>> So the iText API has exposed some Windows-specific extras of the Launch
>> action - OK, that's allowed, it's part of the format. But those are just
>> command line parameters to be passed. They also work with Mac OS X and
>> Unix/Linux as well.
>>
>> But it appears that API is only for external launching - you'll need to
>> create a variant of it for your needs.
>>
>> -----Original Message-----
>> From: vickatvuuch [mailto:[email protected]]
>> Sent: Sunday, September 13, 2009 6:07 PM
>> To: [email protected]
>> Subject: Re: [iText-questions] How-to embed Word document and make a
>> clickable thumnail image to launch MS Word
>>
>>
>> I'm reading the source code and it sais that parameters are windows
>> specific,
>> take a look below.
>> also I can not believe nobody needed to embed a word doc and launch it on
>> the click.
>> The API could be deficient, I don't disagree. If need be I will drop
>> itText
>> and use something that works, but that's wasn't my question.
>>
>> /** Launches an application or a document.
>> * @param application the application to be launched or the document
>> to
>> be opened or printed.
>> * @param parameters (Windows-specific) A parameter string to be
>> passed
>> to the application.
>> * It can be <CODE>null</CODE>.
>> * @param operation (Windows-specific) the operation to perform:
>> "open"
>> - Open a document,
>> * "print" - Print a document.
>> * It can be <CODE>null</CODE>.
>> * @param defaultDir (Windows-specific) the default directory in
>> standard DOS syntax.
>> * It can be <CODE>null</CODE>.
>> * @return a Launch action
>> */
>>
>>
>> Leonard Rosenthol-3 wrote:
>>>
>>> Launch works on ALL platforms since PDF is the PORTABLE document format.
>>> Launch works with embedded as well as external objects.
>>>
>>> Again, you are only looking at iText's APIs - you are NOT looking at
>>> what
>>> is possible with PDF. It may be that no one has needed the feature yet
>>> and you'll have to write it yourself (OH NO!!!!). Or you could hire
>>> Bruno
>>> to write it for you...
>>>
>>> Leonard
>>>
>>> -----Original Message-----
>>> From: vickatvuuch [mailto:[email protected]]
>>> Sent: Sunday, September 13, 2009 5:38 PM
>>> To: [email protected]
>>> Subject: Re: [iText-questions] How-to embed Word document and make a
>>> clickable thumnail image to launch MS Word
>>>
>>>
>>> Ok that makes sense, but it doesn't work either.
>>>
>>> For one thing that API is Windows specific, for another it seem to
>>> designed
>>> to work only with external files as there is no way to refer to an
>>> embedded
>>> file or is there?
>>>
>>> public static PdfAction createLaunch(String application, String
>>> parameters,
>>> String operation, String defaultDir) {
>>>
>>> I have two things describing embedded file: fileName and its descriptor
>>> aka
>>> handle, here is how I embed a file: PdfFileSpecification pdfSpec =
>>> PdfFileSpecification.fileEmbedded(docWriter, att.id + att.fileName,
>>> att.id
>>> + att.fileName, b, false);
>>>
>>>
>>> Leonard Rosenthol-3 wrote:
>>>>
>>>> Then you want Launch actions.
>>>>
>>>> Hopefully, you are embedded the 3D objects as standard PDF 3D models
>>>> and
>>>> not using some other format...
>>>>
>>>> Leonard
>>>>
>>>> -----Original Message-----
>>>> From: vickatvuuch [mailto:[email protected]]
>>>> Sent: Sunday, September 13, 2009 12:59 PM
>>>> To: [email protected]
>>>> Subject: Re: [iText-questions] How-to embed Word document and make a
>>>> clickable thumnail image to launch MS Word
>>>>
>>>>
>>>>
>>>>
>>>> 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-tp25424592p25424948.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-tp25424592p25427476.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-tp25424592p25427757.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-tp25424592p25428168.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-tp25424592p25429908.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/