Embedding a file is relatively easy, but I don't understand what you mean with
"exactly like word documents". Do you want to embed the files as OLE
links? As far as I know, this is not possible with iText nor with PDF actually.
public void embedFile(File file, int pX, int pY, String title, String
subject, String description, int embeddedFileCounter) {
try {
FileInputStream fis = new FileInputStream(file);
byte[] buffer = null;
try {
buffer = new byte[fis.available()];
fis.read(buffer);
}
finally { fis.close(); }
PdfAnnotation annot = PdfAnnotation.createFileAttachment(writer, new
com.lowagie.text.Rectangle(pX-12, pY - 10, pX, pY), title, buffer, "",
file.getAbsolutePath());
annot.put(new PdfName("Subj"), new PdfString(subject,
PdfObject.TEXT_UNICODE)); // Subject
annot.put(PdfName.T, new PdfString(author, PdfObject.TEXT_UNICODE)); //
Author
annot.put(PdfName.CONTENTS, new PdfString(description,
PdfObject.TEXT_UNICODE)); // Description
writer.addAnnotation(annot);
}
catch (IOException io) { io.printStackTrace(); }
}
Regards,
Rog
Alin Popa wrote:
> Hi,
>
> In iText is possible to attach one file (to insert one file) into a
> paragraph ?
> I want to attach one excel file (or other format) exactly like word
> documents.
> If this is possible, can someone tell me how please ?
>
> Thank you.
>
> --
> Best Regards,
>
> Alin
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions