Sorry, I missed this in my in box.

The reason you are not appending to the file stream is that pdf (and
therefore iText) doesn't work that way. If you could just "add" stuff then
there would be no need for a stamper. The pdf has to be re-built with the
new content included.

PdfWriter creates an "empty" stream regardless of your "Append" flag so you
get what you add to the stream and nothing else.

Cheers
AlanK 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Christian Cruz
Sent: Saturday, 27 January 2007 12:30 AM
To: [email protected]
Subject: Re: [iText-questions] layers and pdf concatenation

Hi Alan

Thank you for your reply.  I also tried to add the layer using the PDFWriter
object instead of the PDFStamper, which I now know doesnt support layers.
Here is my code:
(My question below the code)

--------------------------------------------------------------------------
//outFile is my concatenated file, built from individual files with layers
and ended up losing them in the concatenation, not sure why, maybe the
PDFCopy Object also doesnt support layers yet?

PdfReader reader3 = new PdfReader(outFile);
Document doc = new Document(reader3.GetPageSizeWithRotation(1));
if (File.Exists("C:\\TEST.PDF"))
        File.Delete("C:\\TEST.PDF");

PdfWriter writer;
writer = PdfWriter.GetInstance(doc, (Stream)File.Open("C:\\TEST.PDF",
FileMode.Append, FileAccess.Write));
doc.Open();
PdfLayer layer = new PdfLayer("BaseLayer", writer);
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI,
BaseFont.NOT_EMBEDDED);
PdfContentByte cb = writer.DirectContent;
cb.BeginText();
cb.SetTextMatrix(50, 790);
cb.SetLeading(24);
cb.SetFontAndSize(bf, 18);
cb.BeginLayer(layer);
cb.NewlineShowText("write to layer");
cb.EndLayer();
cb.EndText();
doc.Close();
--------------------------------------------------------------------------

The final doc ends up ONLY with the text -write to layer- but it doesnt have
the content of outfile.  I am new to iText, but shouldn't the final doc have
the content of outFile because that is how reader3 and doc where opened?

Thank you

Christian Cruz
Hantz Technology
[EMAIL PROTECTED]
(586) 207-5921 
 
 
--------------------------------------------------------

THIS COMMUNICATION IS INTENDED ONLY FOR THE USE OF THE INDIVIDUAL OR ENTITY
TO WHICH IT IS ADDRESSED AND CONTAINS OR MAY CONTAIN INFORMATION THAT IS
PRIVILEGED, CONFIDENTIAL OR EXEMPT FROM DISCLOSURE UNDER APPLICABLE LAW.  If
the reader of this communication is not the intended recipient (or the
employee or agent responsible for delivering to the intended recipient), you
are hereby notified that any dissemination, distribution, or copying of this
communication is strictly prohibited. If you have received this
communication in error, please disregard and delete this communication.  Do
not disseminate or retain any copy of this communication, or any
attachments.
--------------------------------------------------------

-------------------------------------------------------------------------
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
Buy the iText book: http://itext.ugent.be/itext-in-action/


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to