0
saveAs() method doesn't work for PDF file
New Here
,
/t5/illustrator-discussions/saveas-method-doesn-t-work-for-pdf-file/td-p/1161521
Nov 29, 2008
Nov 29, 2008
Copy link to clipboard
Copied
I used the script below to generate a PDF file. When I ran it, no error occurred but no PDF was generated either
var pdf = new File("E:\\STWWEB1\\CDLG_ILL\\temp\\jpeg\\640\\1.pdf");
docRef.saveAs(pdf);
Does anybody know what's wrong?
var pdf = new File("E:\\STWWEB1\\CDLG_ILL\\temp\\jpeg\\640\\1.pdf");
docRef.saveAs(pdf);
Does anybody know what's wrong?
TOPICS
Scripting
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explore related tutorials & articles
Community Expert
,
/t5/illustrator-discussions/saveas-method-doesn-t-work-for-pdf-file/m-p/1161522#M238227
Nov 30, 2008
Nov 30, 2008
Copy link to clipboard
Copied
Yes, your file path. It needs to be something like this:
"/E/STWWEB1/CDLG_ILL/temp/jpeg/640/1.pdf"
"/E/STWWEB1/CDLG_ILL/temp/jpeg/640/1.pdf"
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Tri_Vuong_
AUTHOR
New Here
,
/t5/illustrator-discussions/saveas-method-doesn-t-work-for-pdf-file/m-p/1161523#M238228
Nov 30, 2008
Nov 30, 2008
Copy link to clipboard
Copied
I used the same kind of path to saveAs() AI and it worked though i.e.
var ai = new File("E:\\STWWEB1\\CDLG_ILL\\temp\\jpeg\\640\\1.ai");
docRef.saveAs(ai)
Anyway, I would still try what you suggested. Thanks.
var ai = new File("E:\\STWWEB1\\CDLG_ILL\\temp\\jpeg\\640\\1.ai");
docRef.saveAs(ai)
Anyway, I would still try what you suggested. Thanks.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Tri_Vuong_
AUTHOR
New Here
,
/t5/illustrator-discussions/saveas-method-doesn-t-work-for-pdf-file/m-p/1161524#M238229
Nov 30, 2008
Nov 30, 2008
Copy link to clipboard
Copied
I used the same kind of path to saveAs() AI and it worked though i.e.
var pdf = new File("E:\\STWWEB1\\CDLG_ILL\\temp\\jpeg\\640\\1.ai");
docRef.saveAs(ai)
Anyway, I would still try what you suggested. Thanks.
var pdf = new File("E:\\STWWEB1\\CDLG_ILL\\temp\\jpeg\\640\\1.ai");
docRef.saveAs(ai)
Anyway, I would still try what you suggested. Thanks.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Tri_Vuong_
AUTHOR
New Here
,
/t5/illustrator-discussions/saveas-method-doesn-t-work-for-pdf-file/m-p/1161525#M238230
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Hi try67,
I tried what you suggested and it still didn't save the file as PDF. Do you know why?
I tried what you suggested and it still didn't save the file as PDF. Do you know why?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
LATEST
/t5/illustrator-discussions/saveas-method-doesn-t-work-for-pdf-file/m-p/1161526#M238231
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
PDF needs to have a new instance of the PDFSaveOptions created. Look at the JS Reference
PDFSaveOptions
Options for saving a document as an Adobe PDF file, used with the saveAs method. All properties are optional.
Saving to PDF format
// Saves the current document as PDF to dest with specified options
// dest contains the full path and file name to save to
function saveFileToPDF (dest) {
var doc = app.activeDocument;
if ( app.documents.length > 0 ) {
var saveName = new File ( dest );
saveOpts = new PDFSaveOptions();
saveOpts.compatibility = PDFCompatibility.ACROBAT5;
saveOpts.generateThumbnails = true;
saveOpts.preserveEditability = true;
doc.saveAs( saveName, saveOpts );
}
}
PDFSaveOptions
Options for saving a document as an Adobe PDF file, used with the saveAs method. All properties are optional.
Saving to PDF format
// Saves the current document as PDF to dest with specified options
// dest contains the full path and file name to save to
function saveFileToPDF (dest) {
var doc = app.activeDocument;
if ( app.documents.length > 0 ) {
var saveName = new File ( dest );
saveOpts = new PDFSaveOptions();
saveOpts.compatibility = PDFCompatibility.ACROBAT5;
saveOpts.generateThumbnails = true;
saveOpts.preserveEditability = true;
doc.saveAs( saveName, saveOpts );
}
}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

