|
Subject: RE: Embedding files as attachments in pdfs (anything new?) Newsgroups: gmane.comp.java.lib.itext.general Date: 2005-11-07 18:19:18 GMT (3 years, 34 weeks, 18 hours and 32 minutes ago)
Here's the solution:
Document document = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("c:\\test_attach.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
cb.rectangle(100, 100, 100, 100);
cb.stroke();
Rectangle rect = new Rectangle(100, 100, 200, 200);
PdfFileSpecification pf = PdfFileSpecification.fileEmbedded(writer,
"c:\\thumb.png", "thumb.png", null);
PdfAnnotation annot = PdfAnnotation.createFileAttachment(writer, rect,
"thumb.png", pf);
PdfAppearance ap = cb.createAppearance(100, 100);
ap.setBoundingBox(rect);
ap.setLineWidth(1);
annot.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, ap);
annot.setAppearance(PdfAnnotation.APPEARANCE_DOWN, ap);
annot.setPage();
writer.addAnnotation(annot);
document.close();
> -----Original Message-----
> From: Antoine [mailto:melser.anton <at> gmail.com]
> Sent: Monday, November 07, 2005 4:09 PM
> To: Paulo Soares
> Cc: Leonard Rosenthol; itext-questions <at> lists.sourceforge.net
> Subject: Re: [iText-questions] Embedding files as attachments
> in pdfs (anything new?)
>
> On 29/10/05, Paulo Soares <psoares <at> consiste.pt> wrote:
> > I asked for one of those PDF and I'm still waiting.
>
> Sorry about the long wait... I have been a little too busy to even
> think about it until now... I fully will fully understand if you
> forget me!
> http://melser.anton.neuf.fr/itext/A%20nice%20subject.pdf
> is where you get the resulting pdf and
> http://melser.anton.neuf.fr/itext/A%20nice%20subject.msg
> is the original email. I would really like to avoid acrobat altogether
> (as there is a bug when there are .msg attachments, ie, it leaves off
> the .msg and so the attachment can't be opened, and I can't work out
> how to get the to/from/subject in English...), and just export to xml
> from outlook and then create the pdfs with itext.
> So can I do this with itext? Will it be very hard/long (I am not much
> good but want to learn so am prepared to spend the time...)?
> Cheers
> Antoine
>
> > > Leonard Rosenthol wrote:
> > > > At 02:06 PM 10/26/2005, Antoine wrote:
> > > >
> > > >> A few months ago I was looking for a way to embed
> files as attachments
> > > >> in pdf documents and pretty much found no way to do
> it. It was even
> > > >> pretty shakey with acrobat 7.
> > > >
> > > >
> > > > Huh?
> > > >
> > > > What is wrong with the File Attachment
> mechanism in Acrobat 7?
> > > >
> > > >
> > > >> The problem being that I need to refer to these
> internal files as
> > > >> hyperlinks.
> > > >
> > > >
> > > > Acrobat 7/PDF 1.6 fully supports links into
> embedded files.
> > >
> > > Any idea how to make a link to one that does NOT have an
> icon, like the
> > > pdfmaker installed into outlook does? I tried for ages
> and couldn't find
> > > out how.
> > > Cheers
> > > Anton
> > >
>
>
> --
> This is where I should put some witty comment.
>
|
|
|