0

I am having problems trying to save (insert) a .pdf with annotations into a SQL Server database. The database is located inside Visual Studio and I am currently using adobe javascript to save it, but I run into security settings prevent access to this property or method when i clicked the button inside the pdf. I'm using a pdf button field from spire.pdf to try to save into the db and pass the script into pdf javascript action.

So far, i have tried using trusted privilege function, using adbc connection and odbc connection as well as the soap method but it doesn't work and I'm quite lost at what to do or continue next. These methods can be found inside adobe javascript reference as well as 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;

The expected result i should get is to be able to save the pdf with annotations into the SQL Server database inside Visual Studio and being able to retrieve it with the annotations. However, the actual result showed the security settings prevent access to this property or method and i cannot proceed to continue.

Would really appreciate some help, thank you! :)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
tre3948
  • 1
  • 3
  • The saving of the file in the database is a different application. The issue is in the service test123.svc. The service has to be running on port 57103. To check if it is running cmd.exe >Netstat -a and look for the port number. – jdweng Oct 05 '19 at 05:52
  • What is "adobe javascript"? – AngryHacker Oct 05 '19 at 06:37
  • 1
    @AngryHacker Like VBA for Office, Abobe has their own JavaScript for Acrobat to add programmability to PDF files. It's cross-platform in the Microsoft sense in that it operates within multiple Adobe applications. – AlwaysLearning Oct 05 '19 at 09:35
  • @jdweng - May I check how to create the service? – tre3948 Oct 06 '19 at 02:27
  • Do you have test123.svc? The code has to be executed. There are lots of ways to start an executable. – jdweng Oct 06 '19 at 10:53
  • @jdweng - At the moment I do not have any code inside test123 .svc as I am not very sure what to put inside there, I used WCF service to generate test123.svc and after that I'm lost at what to do, the required URL – tre3948 Oct 06 '19 at 12:03
  • Take it one step at a time. You are trying to take a complicated application and do everything at one time. You need to 1) Create a database 2) write a pdf to the database 3) Write a sever to write pdf to database 4) write a server to accept a client 5) Write a client to connect to server. 6) send a pdf to server from client and have server store pdf into database. – jdweng Oct 06 '19 at 14:20
  • @jdweng - How do I do from 3 to 6? I'm quite new to this – tre3948 Oct 07 '19 at 00:47
  • do searches on web. There are lots of examples. – jdweng Oct 07 '19 at 09:24

1 Answers1

0

ADBC in Acrobat JavaScript is has been off by default since Acrobat 9. To activate ADBC, create a registry key of type DWORD with the name “bJSEnable” and a value of “true” (1) in the following location:

HKEY_CURRENT_USER\SOFTWARE\Adobe\Adobe Acrobat\VERSION\ADBC

Also the SOAP object was deprecated beginning with Acrobat 8.0. Use Net.SOAP instead.

joelgeraci
  • 4,606
  • 1
  • 12
  • 19