【发布时间】:2020-02-03 08:05:00
【问题描述】:
我在尝试将带有注释的 .pdf 保存(插入)到 SQL Server 数据库时遇到问题。该数据库位于 Visual Studio 内,我目前正在使用 adobe javascript 来保存它,但是当我单击 pdf 内的按钮时,我遇到了安全设置阻止访问此属性或方法。我正在使用 spire.pdf 中的 pdf 按钮字段来尝试保存到数据库中并将脚本传递给 pdf javascript 操作。
到目前为止,我已经尝试过使用受信任的特权功能,使用 adbc 连接和 odbc 连接以及 soap 方法,但它不起作用,我很迷茫下一步该做什么或继续。这些方法可以在 adobe javascript 参考以及 api 中找到。
PdfPageBase page = pdf.Pages[i];
PdfButtonField button = new PdfButtonField(page, "Save");
button.Bounds = new RectangleF(420, 10, 100, 40);
button.BorderColor = new PdfRGBColor(Color.AliceBlue);
button.BorderStyle = PdfBorderStyle.Solid;
button.ForeColor = new PdfRGBColor(Color.White);
button.Text = "Save";
button.BackColor = new PdfRGBColor(Color.Blue);
button.ToolTip = "Save";
button.Font = new PdfFont(PdfFontFamily.Helvetica, 9f);
pdf.Form.Fields.Add(button);
String script = "var nButton=app.alert({"
+ " cMsg: \"Do you want to save this paper into the database?\","
+ " nIcon: 2,"
+ " nType : 2,"
+ " cTitle: \"Confirm Save?\""
+ "});"
+ "if ( nButton == 4 ) {var myProxy = SOAP.connect(\"http://localhost:57103/test123.svc?wsdl) \"); var testString = (\"This is a test string\"); var result = (myProxy.echoString(testString)); console.println(\"Result is : + result\")};";
PdfJavaScriptAction confirm = new PdfJavaScriptAction(script);
button.Actions.GotFocus = confirm;
我应该得到的预期结果是能够将带有注释的 pdf 保存到 Visual Studio 内的 SQL Server 数据库中,并能够使用注释检索它。但是,实际结果显示安全设置阻止访问此属性或方法,我无法继续。
非常感谢您的帮助,谢谢! :)
【问题讨论】:
-
文件在数据库中的保存是不同的应用。问题出在服务 test123.svc 中。该服务必须在端口 57103 上运行。检查它是否正在运行 cmd.exe >Netstat -a 并查找端口号。
-
什么是“adobe javascript”?
-
@AngryHacker 与 Office 的 VBA 一样,Abobe 也为 Acrobat 提供了自己的 JavaScript 来为 PDF 文件添加可编程性。它在 Microsoft 意义上是跨平台的,因为它可以在多个 Adobe 应用程序中运行。
-
@jdweng - 我可以检查一下如何创建服务吗?
-
你有 test123.svc 吗?代码必须执行。有很多方法可以启动可执行文件。
标签: c# asp.net sql-server pdf adobe-javascript