[英]Cannot access PDF doc pages/events from iTextSharp with JavaScript
理想情況下,我嘗試使用iTextSharp觸發PDF中的事件。 如果不這樣做,我想知道我是否可以觸發一個功能。
基本上,我只是想通過javascript來處理文檔。
這適用於PDF
(使用LiveCycle):
eApp.Page1.FormPurpose_PolicyNumber::click -
(JavaScript,客戶端)
this.rawValue = "hello";
從C#開始,在這種情況下我無法處理doc, eApp
。
var reader = new PdfReader(pdfFileStream);
var writer = new PdfStamper(reader, outputStream);
這個工作:( app對象)
PdfAction js =
PdfAction.JavaScript(
"app.alert('hello');",
writer.Writer);
writer.Writer.AddJavaScript(js);
這不是:
PdfAction js =
PdfAction.JavaScript(
"eApp.Page1.FormPurpose_PolicyNumber.execEvent('click');",
writer.Writer);
writer.Writer.AddJavaScript(js);
也不起作用:
PdfAction js =
PdfAction.JavaScript(
"eApp.Page1.FormPurpose_PolicyNumber.rawValue= 'hello'",
writer.Writer);
writer.Writer.AddJavaScript(js);
我已經找到了高低的答案,但卻找不到答案,是的,有類似的問題,但要么他們沒有回答,要么與我正在做的非常不同。
根據你的最新評論 - 這是行不通的。 iTextSharp只會在文檔中添加一些腳本。 該腳本將在一些客戶端應用程序中啟動,如Adobe Reader。 它不會在您的文檔中執行任何腳本。 假設在你的情況下使用c#更容易用文檔做你想要的文件,而不是將表格展平設置為true保存。
在我看來,工作解決方案是:
PdfReader reader = new PdfReader(this.pathToPDFTemplate);
...
PdfStamper stamper = new PdfStamper(reader, stream);
...
PdfAction action = PdfAction.JavaScript("this.xfa.form.form1.DesignArea.sfPart3.sfPart3_5.ck2.presence = 'hidden';", stamper.Writer);
stamper.Writer.SetAdditionalAction(PdfWriter.WILL_PRINT, action);
...
訣竅是使用this.xfa.form。 在你前往田野之前。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.