You can't add content without breaking the extended rights. The extended rights
only work for fields and comments.
Paulo
> -----Original Message-----
> From: Hite . Gregory [mailto:gh...@drc.com]
> Sent: Tuesday, March 09, 2010 3:40 PM
> To: iText-questions@lists.sourceforge.net
> Subject: [iText-questions] Problem adding image to existing
> template with extended features
>
> [reposting now that I'm a proper member of the list - also
> added little more code for context]
>
>
>
> I've searched far and wide but cannot find an answer. I'm
> using iTextSharp 5.0.0 along with good ol' Adobe 9.
>
> I have a template with extended features enabled that I have
> to read in, populate certain form fields, add an image to an
>
> existing page in the document, and serve it up with extended
> features still enabled. I've narrowed my problem down to
>
> when I add the image. Before that point, I can close the
> PdfStamper and deliver the file with extended features still enabled.
>
> But adding the image using the code below somehow breaks and
> disables the extended features...
>
>
>
>
>
> FileStream ourFileStream = new FileStream("newfile.pdf"),
> FileMode.Create);
>
> PdfReader ourPdfReader = new PdfReader("Template.pdf"));
>
> PdfStamper ourPdfStamper = new
> PdfStamper(ourPdfReader, ourFileStream);
>
>
>
> ourPdfStamper.FormFlattening = false;
>
>
>
> AcroFields ourPdfForm = ourPdfStamper.AcroFields;
>
>
>
> // set some fields
>
> ourPdfForm.SetField("DATE PREPARED",
> DateTime.Today.ToString("yyyyMMdd"));
>
> ...
>
> ...
>
> // add image
>
> string chartLoc = @"C:\Code\714672M.jpg";
>
> Image chartImg = Image.GetInstance(chartLoc);
>
>
>
> // get position for image based on hidden field
>
> // in template that serves as place holder
>
> float[] position =
> ourPdfStamper.AcroFields.GetFieldPositions("PLACEHOLDER");
>
> float page = position[0];
>
> float llx = position[1];
>
> float lly = position[2];
>
> float urx = position[3];
>
> float ury = position[4];
>
> Single X, Y;
>
>
>
> Rectangle rect = new Rectangle(urx - llx, ury - lly);
>
> if (chartImg.Width > rect.Width || chartImg.Height >
> rect.Height)
>
> {
>
> chartImg.ScaleToFit(rect.Width, rect.Height);
>
> X = (rect.Width - chartImg.ScaledWidth) / 2;
>
> Y = (rect.Height - chartImg.ScaledHeight) / 2;
>
> }
>
> else
>
> {
>
> X = (rect.Width - chartImg.Width) / 2;
>
> Y = (rect.Height - chartImg.Height) / 2;
>
> }
>
> chartImg.SetAbsolutePosition(X + llx, Y + lly);
>
>
>
> PdfContentByte ourContent =
> ourPdfStamper.GetOverContent(page);
>
> ourContent.AddImage(chartImg);
>
>
>
> Why can I stamp all the other form fields but not add the
> image without disabling extended
>
> features? Is there a different/better way to add the image
> in order to overcome this?
>
>
>
> Thanks so much for any help you can provide!
>
>
>
>
>
> Greg Hite
>
> Dynamics Research Corporation
>
> IUID Software Developer
>
> (405) 622-3751
>
>
>
>
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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/