By Date: <-- -->
By Thread: <-- -->

Adding javascript to existing pdf to print



That's done with a PdfStamper.

----- Original Message ----- From: "Dilip Ladhani" <dilip.ladhani (at) gmail.com>
To: <itext-questions (at) lists.sourceforge.net>
Sent: Monday, February 06, 2006 10:18 PM
Subject: [iText-questions] Adding javascript to existing pdf to print



Hey Guys,

I understand that this question has been asked before, but something is not
working for me. I have a PDF doc (as a byte array). I want to add javascript
to it, so that it prints out on the client. Pasted below is my code

When I do a document.close(), I get an error "The document has no pages". I
am not sure, what I am doing wrong.
I tried to add some content to the doc, but then, it only prints the new
content.
I also tried to add javascript to the document object, instead of the
writer, but that doesn't work either.

Can someone help me with this.  Thank you so much guys*

byte[] pdfData = dctxt.getDocData();  // getting the pdf data
ByteArrayOutputStream bos = new ByteArrayOutputStream(pdfData.length);
bos.write(pdfData);
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, bos);
writer.setViewerPreferences( PdfWriter.HideMenubar | PdfWriter.HideToolbar|
PdfWriter.HideWindowUI );
document.open();
writer.addJavaScript(
  "this.print({bUI: false,bSilent: false,bShrinkToFit: true});" +
  "\r\n" +
  "this.closeDoc();"
  );
document.close();
response.setHeader("Content-Type", "application/pdf");
response.setContentLength(bos.size());
OutputStream os = response.getOutputStream();
bos.writeTo(os);
os.flush();
os.close();


*



-------------------------------------------------------
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
iText-questions (at) lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions