Read Javascript From Pdf Using Itextsharp
I have a script that runs after the pdf-file has been loaded and that populates some form fields in the pdf. I assume it is some kind of javascript running behind the scene. In the
Solution 1:
Modified from this SO answer:
varpdfReader=newPdfReader(infilename);
using (MemoryStreammemoryStream=newMemoryStream())
{
PdfStamperstamper=newPdfStamper(pdfReader, memoryStream);
for (inti=0; i <= pdfReader.XrefSize; i++)
{
PdfDictionarypd= pdfReader.GetPdfObject(i) as PdfDictionary;
if (pd != null)
{
PdfObjectpoAA= pd.Get(PdfName.AA); //Gets automatic execution objectsPdfObjectpoJS= pd.Get(PdfName.JS); // Gets javascript objectsPdfObjectpoJavaScript= pd.Get(PdfName.JAVASCRIPT); // Gets other javascript objects//use poJS.GetBytes(), poJS.ToString() etc to inspect details...
}
}
stamper.Close();
pdfReader.Close();
File.WriteAllBytes(rawfile, memoryStream.ToArray());
}
Here's a reference page for the PdfObject class.
Post a Comment for "Read Javascript From Pdf Using Itextsharp"