使用.net在pdf中编辑javascript
问题描述:
是否可以使用.net编辑pdf文档的javascript?
Is it possible to edit the javascript of a pdf document with .net?
我查看了 Acrobat SDK ,但是运气不佳.看起来您可以从表单等中检索值,但不能编辑文档.
I've looked at the Acrobat SDK, but without much luck. It looks like you can retrieve values from forms etc. but not edit the document.
我偏离轨道了吗?这有可能吗?
Am I way off track? Is this even possible?
我已经尝试过 iTextSharp ,但是由于pdf包含表单字段,因此当我保存了pdf.
I've tried iTextSharp, but since the pdf contains form fields, the fields are lost when I save the pdf.
有什么建议吗?
答
好吧,显然您可以使用 iTextSharp :
Well, apparently you can with iTextSharp:
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
PdfReader reader = new PdfReader(@"Source.pdf");
FileStream output = new FileStream(@"Destination.pdf", FileMode.Create);
PdfStamper pdfStamper = new PdfStamper(reader, output, '\0', true);
pdfStamper.JavaScript = "app.alert(\"Hello world!\");";
pdfStamper.FormFlattening = false;
pdfStamper.Close();
reader.Close();
((该问题有所帮助)