Hi Harakiri,

I have got what you said. And i agree with you completely. I would not want
my user to first open the attachment and then save it. The "Save As"
functionality should have been there. But this is something that I may have
to live with.

However, I still need some help!

" I need a little help where instead of annotation's default image, i need
to actually give the Image object,
representing the "C:/word.jpg". I tried the following code instead
--------------------------------------- one line code starts
-------------------------------------------   annot =
PdfAnnotation.createFileAttachment(writer, testImage, "Images "+i, b, "",
"Test.tiff");

--------------------------------------- one line code ends
--------------------------------------------
 instead of 

--------------------------------------- one line code starts
-------------------------------------------
annot = PdfAnnotation.createFileAttachment(writer, new Rectangle(300, i *
250, 300, i * 250), "Images "+i, b, "", "Test.tiff");

but could not get the desired result.

Also, is there a better way of arranging the annotations instead of setting
their x and y coordinates?"

Please help if possible. I have been researching myself and keeping an eye
on other posts but no avail.

Thanks


Harakiri wrote:
> 
> You dont understand - open that pdf you supplied in the pdf reader - the
> "Save As" Dialog is greyed out in the attachments pane.....
> 
> http://www.nabble.com/file/p17662151/MyTestPdf.pdf
> 
> Only (as i said in the supplied original thread) right clicking within the
> pdf where the annotation is works but  - you want to teach your users to
> do it that way? why have an attachment pane - if you cant use save_as in
> the first place =)
> 
> What i did - for usability reasons - was to display all attachment names
> in the pdf in the header - and have a mouseover action which describes how
> to save attachments, furthermore - clicking on the attachment name
> resulted in an alert telling the exact same thing =) - the original
> intention was that you could use the attachment names to save
> as/automatically open - but most users are already customized to the build
> in feature of the attachment pane - so they wouldnt know how to save
> files!
> 
> --- On Thu, 6/5/08, Sumeet Gupta <[EMAIL PROTECTED]> wrote:
> 
>> From: Sumeet Gupta <[EMAIL PROTECTED]>
>> Subject: Re: [iText-questions] click on image and open the attachment
>> To: itext-questions@lists.sourceforge.net
>> Date: Thursday, June 5, 2008, 12:58 AM
>> Here's the code for opening an attachment when clicking
>> on an annotation. It
>> opens up the corresponding attachment (documents and tiff
>> images) when the
>> annotation is double-clicked. Also, when the attached word
>> document opens
>> up, it does have the "Save As" functionality. 
>> 
>> Attached is a sample PDF file generated by the code below. 
>> 
>> The code attaches 3 word documents and 3 tiff images, as
>> "CORRESPONDENCE
>> DOCUMENTS" and "IMAGES" section,
>> respectively. 
>> 
>> 
>> --------------------------------------- code starts
>> ---------------------------------------------------
>> 
>>              Document document = new Document();
>>              Color redColor = new Color(255, 0, 0);
>>              Color blueColor = new Color(0, 0, 255);
>>              Color grayColor = new Color(100, 100, 100);
>>              Color greenColor = new Color(0, 255, 0);
>>                      
>>              Font redFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD,
>> redColor);
>>              Font blueFont = new Font(Font.TIMES_ROMAN, 10,
>> Font.NORMAL, blueColor);
>>                   Font grayFont = new Font(Font.COURIER, 9,
>> Font.NORMAL,
>> grayColor);
>>              Font greenFont = new Font(Font.TIMES_ROMAN, 10,
>> Font.NORMAL, greenColor);
>>              
>>              ByteArrayOutputStream baosPDF = new
>> ByteArrayOutputStream();
>>              PdfWriter writer = null;
>>      
>>              try{
>>                      writer = PdfWriter.getInstance(document, baosPDF);      
>>                 
>>              }
>>              catch (DocumentException e){
>>                      e.printStackTrace();
>>              }
>>              
>>              document.setPageSize(PageSize.LETTER);
>>                      
>>              HeaderFooter header = new HeaderFooter(new
>> Phrase("My Header", grayFont),
>> false);
>>              header.setAlignment(0);
>>              document.setHeader(header);
>>                      
>>              HeaderFooter footer = new HeaderFooter(new
>> Phrase("My Footer", grayFont),
>> false);
>>              footer.setAlignment(2);
>>              document.setFooter(footer);
>>              
>>              document.open();
>>              Image testImage =
>> Image.getInstance("C:/word.jpg");
>> 
>>              Paragraph title = new Paragraph("WORKITEM PRINT
>> REPORT", redFont);
>>              title.setAlignment(1);
>>              document.add(title);
>>                      
>>              Paragraph emptyPara = new Paragraph("   ");
>>              document.add(emptyPara);
>>              document.add(emptyPara);
>>                      
>>              Paragraph currentDate = new Paragraph("Create Date:
>> "+ new
>> java.util.Date(), blueFont);
>>              document.add(currentDate);
>>                      
>>              Paragraph correspondencePara = new
>> Paragraph("CORRESPONDENCE DOCUMENTS");
>>              document.add(correspondencePara);
>>              
>>              PdfFileSpecification pf = null;
>>              byte[] b = null;
>>              PdfAnnotation annot = null;
>>              String filePath = "C:/Test.doc";
>>              for(int i = 1;i < 4;i++){
>>                      b = getBytesFromFile(filePath);
>>                      try{
>>                              annot = 
>> PdfAnnotation.createFileAttachment(writer, new
>> Rectangle(300, i
>> * 250, 300, i * 250), "Attachment "+i, b,
>> "", "Test.doc");
>>                      }
>>                      catch(IOException e){
>>                              e.printStackTrace();
>>                      }
>>                      
>>                      annot.setPage();
>>                      annot.setColor(new Color(122,122,122));
>>                      writer.addAnnotation(annot);
>>              }
>>              document.newPage();
>> 
>>              Paragraph attachmentPara = new
>> Paragraph("ATTACHMENTS");
>>              document.add(attachmentPara);
>>              
>>              filePath = "C:/Test.tiff";
>>              for(int i = 1;i < 4;i++){
>>                      b = getBytesFromFile(filePath);
>>                      try{
>>                              annot = 
>> PdfAnnotation.createFileAttachment(writer, new
>> Rectangle(300, i
>> * 250, 300, i * 250), "Images "+i, b,
>> "", "Test.tiff");
>>                      }
>>                      catch(IOException e){
>>                              e.printStackTrace();
>>                      }
>>                      annot.setPage();
>>                      annot.setColor(new Color(122,122,122));
>>                      writer.addAnnotation(annot);
>>              }
>> 
>>              document.close(); 
>>              StringBuffer sbFilename = new StringBuffer();
>>              sbFilename.append("MyTestPdf.pdf");
>>              
>>              System.out.println(sbFilename);  
>>              baosPDF.writeTo(new
>> FileOutputStream("C:/Test/"+sbFilename.toString()));
>>      
>> ------------------------------------------ code ends
>> -------------------------------------------------
>> 
>> If you run this sample code, you can see the PDF file with
>> a total of 6
>> attachments. I need a little help where instead of
>> annotation's default
>> image, i need to actually give the Image object,
>> representing the
>> "C:/word.jpg". I tried the following code instead
>> 
>> 
>> --------------------------------------- one line code
>> starts
>> -------------------------------------------
>> 
>> annot = PdfAnnotation.createFileAttachment(writer,
>> testImage, "Images "+i,
>> b, "", "Test.tiff");
>> 
>> --------------------------------------- one line code ends
>> --------------------------------------------
>> 
>> 
>> instead of 
>> 
>> --------------------------------------- one line code
>> starts
>> -------------------------------------------
>> 
>> annot = PdfAnnotation.createFileAttachment(writer, new
>> Rectangle(300, i *
>> 250, 300, i * 250), "Images "+i, b, "",
>> "Test.tiff");
>> http://www.nabble.com/file/p17662151/MyTestPdf.pdf
>> MyTestPdf.pdf 
>> --------------------------------------- one line code ends
>> --------------------------------------------
>> 
>> but could not get the desired result.
>> 
>> Also, is there a better way of arranging the annotations
>> instead of setting
>> their x and y coordinates?
>> 
>> Thanks.
>> 
>> 
>> 
>> Leonard Rosenthol wrote:
>> > 
>> > On Jun 4, 2008, at 7:01 AM, Paulo Soares wrote:
>> >> I couldn't find a way to create one in Acrobat
>> 7 and the one I made by
>> >> moving refs around didn't work. Can you get me
>> a pdf that launchs an
>> >> embedded file?
>> >>
>> >>
>> >    I just realized we didn't have any UI for it
>> either ;).
>> > 
>> >    For the /F key on the launch action, you should point
>> to an /EF  
>> > (embedded file).  I'll try to come up with a
>> sample today, if I can  
>> > get a chance.
>> > 
>> > Leonard
>> > 
>> > 
>> >
>> -------------------------------------------------------------------------
>> > Check out the new SourceForge.net Marketplace.
>> > It's the best place to buy or sell services for
>> > just about anything Open Source.
>> > http://sourceforge.net/services/buy/index.php
>> > _______________________________________________
>> > iText-questions mailing list
>> > iText-questions@lists.sourceforge.net
>> >
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>> > 
>> > Do you like iText?
>> > Buy the iText book: http://www.1t3xt.com/docs/book.php
>> > Or leave a tip: https://tipit.to/itexttipjar
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/click-on-image-and-open-the-attachment-tp17623373p17662151.html
>> Sent from the iText - General mailing list archive at
>> Nabble.com.
>> 
>> 
>> -------------------------------------------------------------------------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>> _______________________________________________
>> iText-questions mailing list
>> iText-questions@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>> 
>> Do you like iText?
>> Buy the iText book: http://www.1t3xt.com/docs/book.php
>> Or leave a tip: https://tipit.to/itexttipjar
> 
> 
>       
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Do you like iText?
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Or leave a tip: https://tipit.to/itexttipjar
> 
> 

-- 
View this message in context: 
http://www.nabble.com/click-on-image-and-open-the-attachment-tp17623373p17667421.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to