-1

I'm getting a memory stream in and then trying to append a link annotation with calls some JavaScript. Simply put my code looks like:

PdfReader pdfReader = new PdfReader(streamFromSharePoint);
PdfStamper pdfStamper = new PdfStamper(pdfReader, pdfMemoryStream);

iTextSharp.text.Rectangle r = new iTextSharp.text.Rectangle(100f,500f,200f,600f);
PdfName n = new PdfName("Name");
PdfAction a = PdfAction.JavaScript("alert('hi');", pdfStamper.Writer);
PdfAnnotation l = PdfAnnotation.CreateLink(pdfStamper.Writer,r,n,a);

pdfStamper.AddAnnotation(l,1);

pdfStamper.FormFlattening = true;
pdfStamper.Writer.CloseStream = false;
pdfStamper.Close();

I can see a box on the screen for the border, but clicking on it does nothing. Any thoughts? Thanks!

1 Answer 1

1

ECMAScript / JavaScript is not the same as Acrobat's JavaScript. try replacing:

"alert('hi');"

with:

"app.alert('hi');"
1
  • Bingo. There's probably an error message in the JS log. To see that log in Reader, you need to enable it via the JS preferences. Kind of a pain. Feb 17, 2011 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.