Hi,
I am testing some code to do batch conversion of pdf to plain text.
I can use the doc.saveAs method to save a copy of a pdf file, but not a text file.
For example:
// This does not work:
var srcFile = app.openDoc({ cPath: "/c/3-Full-Interviews-Transcripts/01-Dr-Group.pdf", bHidden: false });
srcFile.saveAs("/c/3-Full-Interviews-Transcripts/01-Dr-Group.txt");
srcFile.closeDoc();
// Error is:
Console:Exec:4: NotAllowedError: NotAllowedError: Security settings prevent access to this property or method.
Doc.saveAs:4:Console:Exec
I have also tried with
srcFile.saveAs("/c/3-Full-Interviews-Transcripts/01-Dr-Group.txt","com.adobe.acrobat.plain-text");
That gives the console error:
Console:Exec:11: InvalidArgsError: InvalidArgsError: Invalid arguments.
Doc.saveAs:11:Console:Exec
I am suspecting that either you do not support conversion of pdf to text using this method, or I am using an incorrect cConvID string.
Any thoughts?
Also are you ever considering implementing breakpoints in the JavaScript window?
Thanks much
Help using doc.saveAS method to convert pdf to txt
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
anachroman
- User
- Posts: 3
- Joined: Tue Jan 09, 2024 11:57 pm
-
Sunilkumar
- User
- Posts: 10
- Joined: Sat Mar 14, 2026 10:27 am
Re: Help using doc.saveAS method to convert pdf to txt
Hello,
Based on the errors you've shared, it appears that Doc.saveAs() may be restricted to supported output formats and may not directly export PDF content to plain text. The NotAllowedError could also indicate that the method is being executed from a context where file system access is restricted by JavaScript security settings.
You might want to check whether PDF-XChange provides a dedicated export or text extraction method instead of relying on saveAs() with a .txt extension. If plain-text export is supported, there may be a specific conversion ID or SDK/API function required for that operation.
As a troubleshooting step, have you tried running the script from a trusted folder-level script or batch environment to rule out JavaScript security restrictions? It would also be helpful to know which PDF-XChange product and version you're using, as scripting capabilities can vary between products.
I'm interested to see whether the PDF-XChange team can confirm if plain-text export is supported through saveAs() or if a different approach is recommended.
Based on the errors you've shared, it appears that Doc.saveAs() may be restricted to supported output formats and may not directly export PDF content to plain text. The NotAllowedError could also indicate that the method is being executed from a context where file system access is restricted by JavaScript security settings.
You might want to check whether PDF-XChange provides a dedicated export or text extraction method instead of relying on saveAs() with a .txt extension. If plain-text export is supported, there may be a specific conversion ID or SDK/API function required for that operation.
As a troubleshooting step, have you tried running the script from a trusted folder-level script or batch environment to rule out JavaScript security restrictions? It would also be helpful to know which PDF-XChange product and version you're using, as scripting capabilities can vary between products.
I'm interested to see whether the PDF-XChange team can confirm if plain-text export is supported through saveAs() or if a different approach is recommended.
-
Daniel - PDF-XChange
- Site Admin
- Posts: 12928
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Help using doc.saveAS method to convert pdf to txt
Hello,
Thank you for the post, I had to check in with the Dev team on this, here was their reply:
Thank you for the post, I had to check in with the Dev team on this, here was their reply:
Kind regards,You have to specify cConvID, otherwise saveAs will fail as the file extension does not correspond to the requested format.
The proper converter ID for PDF->Text converter in the Editor is conv.exp.txt. It can be found in app.fromPDFConverters.
Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
[email protected]
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
[email protected]
-
Mathew
- User
- Posts: 835
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Help using doc.saveAS method to convert pdf to txt
Hi Daniel,Daniel - PDF-XChange wrote: ↑Wed Jun 03, 2026 3:00 pm Hello,
Thank you for the post, I had to check in with the Dev team on this, here was their reply:
Kind regards,You have to specify cConvID, otherwise saveAs will fail as the file extension does not correspond to the requested format.
The proper converter ID for PDF->Text converter in the Editor is conv.exp.txt. It can be found in app.fromPDFConverters.
I think there may be a bug in v11.0.0 for exporting to text.
I'm also not able to get this method to work for exporting to text in v11.0.0 -- I always get an empty text file:
Code: Select all
srcFile.saveAs({cPath:"/c/3-Full-Interviews-Transcripts/01-Dr-Group.txt", cConvID:'conv.exp.txt', bPromptToOverwrite: true});- Mathew.
You do not have the required permissions to view the files attached to this post.
-
Daniel - PDF-XChange
- Site Admin
- Posts: 12928
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Help using doc.saveAS method to convert pdf to txt
Hello, Mathew
Thank you for the report, I have run some testing and it seems this issue is resolved in our 11.0.1 internal testing, but I have escalated this to them for review just in case.
Kind regards,
Thank you for the report, I have run some testing and it seems this issue is resolved in our 11.0.1 internal testing, but I have escalated this to them for review just in case.
Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
[email protected]
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
[email protected]
-
anachroman
- User
- Posts: 3
- Joined: Tue Jan 09, 2024 11:57 pm
Re: Help using doc.saveAS method to convert pdf to txt
Thanks everyone. I will give it a try although I'm sure it will work. I am using Editor Plus v10.8.410. Originally, I tried it from a trusted location where another of my js functions work and from the console. I love this product. 
-
Sean - PDF-XChange
- Site Admin
- Posts: 1091
- Joined: Wed Sep 14, 2016 5:42 pm
Re: Help using doc.saveAS method to convert pdf to txt
Hi anachroman,
I hope that works out for you - please let us know if you have any problems, and we'll be happy to assist you.
Kind regards,
I hope that works out for you - please let us know if you have any problems, and we'll be happy to assist you.
Kind regards,
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623