Hello all,
I'm loading a pdf with a form, filing in the form, and
adding it to my document. To do so, I'm using the
following code (suggested by Bruno):
PdfReader reader;
PdfStamper stamper;
ByteArrayOutputStream baos
RandomAccessFileOrArray model = new
RandomAccessFileOrArray("d:\model.pdf");
// first stamper
reader = new PdfReader(model, null);
baos = new ByteArrayOutputStream();
stamper = new PdfStamper(reader, baos);
form = stamper.getAcroFields();
form.setField("Date", "11/05/2005");
stamper.setFormFlattening(true);
stamper.close();
// copy content of first page
reader = new PdfReader(baos.toByteArray());
Document document = new
Document(reader.getPageSizeWithRotation(1));
PdfCopy writer = new PdfCopy(document, new
FileOutputStream("HelloWorldStampCopy.pdf"));
document.open();
writer.addPage(writer.getImportedPage(reader, 1));
// second stamper
//etc...
I want to add a barcode and to do so I've checked the
examples picked up the one named
AddWatermarkPageNumbers. Here the code I added right
before "stamper.close(); ":
Barcode128 shipBarCode = new Barcode128();
// preparing bar code here
Image imgShipBarCode =
shipBarCode.CreateImageWithBarcode(stamper.GetOverContent(0),
Color.BLACK, Color.BLUE);
imgShipBarCode.SetAbsolutePosition(10, 10);
stamper.GetOverContent(0).AddImage(imgShipBarCode);
stamper.Close();
And it doesn't work because stamper.GetOverContent(0)
returns null. Anyone know what am I doing wrong ?
For the record I've also tried to use the following
code right after "writer.addPage":
Barcode128 shipBarCode = new Barcode128();
// preparing bar code here
Image imgShipBarCode =
shipBarCode.CreateImageWithBarcode(writer.DirectContent,
Color.BLACK, Color.BLUE);
imgShipBarCode.SetAbsolutePosition(10, 10);
writer.Add(imgShipBarCode);
And in this case, it doesnt work either (even if i got
no error): there is no barcode on my pdf.
Thanking you in advance,
Fabio
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions