Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

syntaxerror:illegal XML character 1:

Community Beginner ,
Oct 13, 2018 Oct 13, 2018

Could someone please assist. I am getting a syntaxerror:illegal XML character 1: at line two on the following script:

var oMyDoc = <... PDF being operated on ...>

app.execMenuItem("Save", oMyDoc) ;

Thankyou in advance

TOPICS
Acrobat SDK and JavaScript
876
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 13, 2018 Oct 13, 2018

Well, it could actually have something to do with the first line, and without seeing it all, it's hard to say.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 13, 2018 Oct 13, 2018

Hi George,

Thankyou for your response. The script in total (line one and two) is:

var oMyDoc = <... PDF being operated on ...>

app.execMenuItem("Save", oMyDoc) ;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 13, 2018 Oct 13, 2018

In that case, the problem is what comes after the equals sign on the first line. Do you have reason to believe it or the second line is correct? It would help if you provide more details about what you're trying to accomplish, apart from "I want to save the current document".

Note that the "Save" menu item cannot be invoked with app.execMenuItem. More info is available in the documentation for app.execMenuItem: Acrobat DC SDK Documentation

so you might want to look into using the doc.saveAs method: https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 13, 2018 Oct 13, 2018

I realize now you probably got the code from that tutorial. In it Thom explains how it won;t work in certain situations, the

"<... PDF being operated on ...>"

part isn't intended to be valid, but rather be a placeholder for a document object. When I said the Save menu item can't be invoked, what I meant was from a document context, such as a button's Mouse Up script.

Use the doc.saveAs method for the most flexibility, and specify the same path as the document currently has, but the code would have to be executed in a trusted context, as is explained and demonstrated in the tutorial.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 14, 2018 Oct 14, 2018

Thankyou for your response George, it's appreciated.

I have created a form using acrobat dc pro incorporating an actionable button to prompt the user to make all the fields 'read only' (using a java script>mouse up action) before saving. This has worked well, the tricky part is that the form will be raised within an EDRMS using a template functionality. Typically this opens up launching a registration screen for the user to complete and nominate destination folder to where the form will be saved, once the registration screen is completed they select OK then the form opens to complete. The user completes the form, makes 'read only' through the button to ensure content cannot be modified  and closes the form and the EDRMS automatically prompts a save.  When I test this with Adobe pro DC it functions as required, however when this is tested using Adobe Reader (which most users will have) it always opens another window to 'Save As' locally. I have tried many things to get around this, so thought that maybe by adding an additional action using a java script to 'save' (only) on the same action button that makes the pdf read only it may work??

I'd appreciate any assistance, as you may have gathered I don't know java...

P.s I have also tried file>close action - unsuccessful

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 14, 2018 Oct 14, 2018

Reader does this even if you choose Save from the File menu. Apparently it's a security thing. Adobe Know Best.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 14, 2018 Oct 14, 2018

By the way, it isn't Java. It's JavaScript. I'm not just being picky (though that's fun of course). The key thing about using the wrong name is that the internet is full of advice on using Java which will be confusing and useless to you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2018 Oct 13, 2018

Change the first line to:

var oMyDoc = this;

On Sun, Oct 14, 2018, 07:47 annemariep67945361 <forums_noreply@adobe.com>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 14, 2018 Oct 14, 2018

Thankyou for your response, unfortunately it hasn't worked. Thank you anyway, it's appreciated

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 14, 2018 Oct 14, 2018

I should have looked better at what you're trying to do... First of all, the "Save" command will not work like that. You can use "SaveAs", but to silently save the file you will have to install a script on the computer itself.

In addition, the execMenuItem command only takes one parameter, so the second one should be removed either way.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 14, 2018 Oct 14, 2018
LATEST

The second parameter is optional and can be a document object. In the case of the Save menu item, it will save the specified open document.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines