Thanks, I'll check the PdfImportedPage. I'll buy the second edition of the
book too.
I wrote some code to try to replace a button filed with some PDF content and
the button is not replaced. Both the PDF content and the button still appear
on the final pdf document. Any idea why? I thought the button would be
completely replaced by the PDF content. Here is the code:
public static void fillForm(String filename, OutputStream out) throws
IOException, DocumentException
{
PdfReader reader = new PdfReader(filename);
PdfStamper stamper = new PdfStamper(reader, out);
AcroFields form = stamper.getAcroFields();
HashMap<String,AcroFields.Item> fields = form.getFields();
System.out.println("Fields: " + fields);
Set<String> fieldnames = fields.keySet();
System.out.println("Field names: " + fieldnames);
form.setField("name", "Dave Matthews");
form.setField("school", "DMB");
form.setField("year", "2020");
form.setField("classname", "Music Class");
form.setField("classnumber", "101");
form.setField("students", "4");
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new
ByteArrayOutputStream()); // use memory, not a file
document.open();
PdfContentByte contentbyte = writer.getDirectContent();
Rectangle pagerectangle = writer.getPageSize();
float width = Math.abs(pagerectangle.getRight() -
pagerectangle.getLeft());
float height = Math.abs(pagerectangle.getTop() -
pagerectangle.getBottom());
PdfTemplate wagonwheelcharttemplate = contentbyte.createTemplate(width,
height);
BaseFont bf = BaseFont.createFont(
BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
wagonwheelcharttemplate.saveState();
wagonwheelcharttemplate.beginText(); // BT
wagonwheelcharttemplate.moveText(36, 806); // 36 806 Td
wagonwheelcharttemplate.moveText(0, -18); // 0 -18 Td
wagonwheelcharttemplate.setFontAndSize(bf, 12); // /F1 12 Tf
wagonwheelcharttemplate.showText("Wagon wheel chart");
wagonwheelcharttemplate.endText();
wagonwheelcharttemplate.restoreState();
PushbuttonField bt = form.getNewPushbuttonFromField("wagonwheelchart");
bt.setLayout(PushbuttonField.LAYOUT_ICON_ONLY);
bt.setProportionalIcon(false);
bt.setTemplate(wagonwheelcharttemplate);
form.replacePushbuttonField("wagonwheelchart", bt.getField());
stamper.setFormFlattening(true);
stamper.close();
}
Thanks
Fred
On Sun, Feb 21, 2010 at 20:06, 1T3XT info <i...@1t3xt.info> wrote:
> Fred Janon wrote:
> > PdfTemplate wagonwheelcharttemplate = new PdfTemplate(); *// no such
> > constructor, where do I get the PdfTemplate from?*
>
> Based on your description I think you need a PdfImportedPage.
> (This class extends PdfTemplate.)
> There's an example in the second edition of iText in Action
> (on number 2 in the top 10 of the best selling MEAP book:
> http://www.manning.com/affiliate/idevaffiliate.php?id=223_0_3_14 )
> --
> This answer is provided by 1T3XT BVBA
> http://www.1t3xt.com/ - http://www.1t3xt.info
>
>
> ------------------------------------------------------------------------------
> 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/
>
------------------------------------------------------------------------------
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/