I fixed the problem with this:

// adobe javascript code for the silent print
StringBuffer javascript = new StringBuffer();
javascript.append("var params = this.getPrintParams();");
javascript.append("params.interactive =
params.constants.interactionLevel.silent;");
javascript.append("params.pageHandling =
params.constants.handling.shrink;");
javascript.append("this.print(params);");


PdfAction pdfAction= PdfAction.javaScript(javascript.toString(), writer);
writer.addJavaScript(pdfAction);



-------------------------- Original Message --------------------------
Subject: PdfContentByte not showing when doing a Silent Print
From:    "Frank Griffith" <[EMAIL PROTECTED]>
Date:    Fri, December 1, 2006 6:01 pm
To:      itext-questions@lists.sourceforge.net
Cc:      [EMAIL PROTECTED]
----------------------------------------------------------------------

I'm building my PDF by adding individual TIFF pages to the
PdfContentByte. Then I'm added some text to the PdfContentByte to be
displayed at the top of each page. It works fine when I open the pdf
and print it from the menu, but when I use the silent print, the text
I've added doesn't print.

I'm not sure if I need more sophisticated javascript to be added to
the document so that Adobe know to print the text I've added. Or if
I'm handling the PdfContentByte improperly in my code.

Any assistence is greatly appreciated.




Document document = new Document();

PdfWriter writer = PdfWriter.getInstance(document, stream);

document.open();

PdfAction pdfAction= PdfAction.javaScript("this.print(false);", writer);
writer.addJavaScript(pdfAction);

document.newPage();

PdfContentByte cb = writer.getDirectContent();

image = Image.getInstance(file.toString());

// add the image to the pdf
if (null != image) cb.addImage(image);

cb.beginText();
cb.setFontAndSize(bf, fontSize);
cb.moveText(x, y);
cb.showText("bla bla bla");
cb.endText();

document.close();







-------------------------------------------------------------------------
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
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to