Hi,

When i want to write document-actions into a PDF, I do something like this:

|PdfAction action =  PdfAction.javaScript("app.alert(\"I'm 
here!\");\r",writer);  |
|writer.setAdditionalAction(PdfName.WP,action); 
|

What I can't figure out is the best way to open & read a PDF file and 
get its document-actions. I'm looking for something like 
getAdditionalAction(). I read section 8.5 of the PDF Reference and it 
said I need to get ahold of the Document Catalog's additional-actions 
(AA) dictionary and then look for any entries therein (DC, WS, DS, WP, 
and DP). I did something like this, but it seems clunky. Is there a 
better way?

|PdfReader reader = new PdfReader(infile);
PdfDictionary aa = 
(PdfDictionary)PdfReader.GetPdfObjectRelease(reader.Catalog.Get(PdfName.AA));
foreach( PdfName key in aa.Keys)
{
  if (key.ToString() == PdfName.DC.ToString())
    OutputMessage("Document Close action:",false);
  else if (key.ToString() == PdfName.WS.ToString())
    OutputMessage("Will Save action:",false);
  else if (key.ToString() == PdfName.DS.ToString())
    OutputMessage("Done Saving action:",false);
  else if (key.ToString() == PdfName.WP.ToString())
    OutputMessage("Will Print action:",false);
  else if (key.ToString() == PdfName.DP.ToString())
    OutputMessage("Done Printing action:",false);
  iTextSharp.text.pdf.PdfObject huh = aa.Get(key);
  PdfDictionary action = 
(PdfDictionary)PdfReader.GetPdfObjectRelease(aa.Get(key));
  foreach( PdfName key2 in action.Keys)
  {
    if (key2.ToString()==PdfName.JS.ToString())
    {
      PdfObject val2 = action.Get(key2);
      OutputMessage(val2.ToString(),false);
    }
  }
}

|

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
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