Try taking out the ~ put the full path
This function will allow you to save a pdf....it expects a document to be currently open and a parameter of type string for the ouput directory:
@param string output
the path to save the pdf
//Basic PDF output options.
pageRange = PageRange.allPages;
acrobatCompatibility = AcrobatCompatibility.acrobat6;
exportGuidesAndGrids = false;
exportLayers = false;
exportNonPrintingObjects = false;
exportReaderSpreads = false;
generateThumbnails = false;
ignoreSpreadOverrides = false;
includeBookmarks = true;
includeHyperlinks = true;
includeICCProfiles = true;
includeSlugWithPDF = false;
includeStructure = false;
interactiveElementsOption = InteractiveElementsOptions.doNotInclude;
//Setting subsetFontsBelow to zero disallows font subsetting;
//set subsetFontsBelow to some other value to use font subsetting.
subsetFontsBelow = 0;
//Bitmap compression/sampling/quality options.
colorBitmapCompression = BitmapCompression.zip;
colorBitmapQuality = CompressionQuality.eightBit;
colorBitmapSampling = Sampling.none;
//thresholdToCompressColor is not needed in this example.
//colorBitmapSamplingDPI is not needed when colorBitmapSampling
//is set to none.
grayscaleBitmapCompression = BitmapCompression.zip;
grayscaleBitmapQuality = CompressionQuality.eightBit;
grayscaleBitmapSampling = Sampling.none;
//thresholdToCompressGray is not needed in this example.
//grayscaleBitmapSamplingDPI is not needed when grayscaleBitmapSampling
//is set to none.
monochromeBitmapCompression = BitmapCompression.zip;
monochromeBitmapSampling = Sampling.none;
//thresholdToCompressMonochrome is not needed in this example.
//monochromeBitmapSamplingDPI is not needed when
//monochromeBitmapSampling is set to none.
//Other compression options.
compressionType = PDFCompressionType.compressNone;
compressTextAndLineArt = true;
cropImagesToFrames = true;
optimizePDF = true;
//Printers marks and prepress options.
//Get the bleed amounts from the document's bleed.
bleedBottom = app.activeDocument.documentPreferences.
bleedTop = app.activeDocument.documentPreferences.documentBleedTopOffset;
bleedInside = app.activeDocument.documentPreferences.
bleedOutside = app.activeDocument.documentPreferences.
//If any bleed area is greater than zero, then export the bleed marks.
if(bleedBottom == 0 && bleedTop == 0 && bleedInside == 0 && bleedOutside == 0)
bleedMarks = true;
bleedMarks = false;
colorBars = true;
colorTileSize = 128;
grayTileSize = 128;
cropMarks = true;
omitBitmaps = false;
omitEPS = false;
omitPDF = false;
pageInformationMarks = true;
//pageMarksOffset = 12;
pdfColorSpace = PDFColorSpace.unchangedColorSpace;
//Default mark type.
pdfMarkType = 1147563124;
printerMarkWeight = PDFMarkWeight.p125pt;
registrationMarks = true;
simulateOverprint = false;
useDocumentBleedWithPDF = true;
//Set viewPDF to true to open the PDF in Acrobat or Adobe Reader.
viewPDF = false;
//Now export the document. You'll have to fill in your own file path.
var output_file = new File(output);
var file = new File(output_file.fsName.toString() + "\\" + app.activeDocument.name.substring(0, app.activeDocument.name.lastIndexOf(".")) + ".pdf");
Thanks for your posts, but post #1 is incorrect and post #2 has nothing to do with my question.
Re post #1: "A path name can start with a tilde (~) to indicate the user’s home directory. It corresponds to the platform’s HOME environment variable."
I use tildes all the time in paths without a problem.
Re post #2: I don't need to know how to export a PDF of the document; I want to save the preflight report, which according to the docs you can do by calling the method named "saveReport" on the preflightProcess object.
Do you have a Preflight profile called Test?
Good suggestion, but if I did not have a "Test" profile, the script would have failed at this line:
with the ever-popular "undefined is not an object" message.
Since it's not failing there, and since I DO have a "Test" profile, I'm afraid I can't award you points for the right answer. But, we have some lovely parting gifts AND a set of Samsonite luggage for you...
It turns out the the preflight report is actually implemented in ExtendScript, by a file named "ExportPreflightReport.jsx" inside the InDesign app's Scripts folder.
This script is apparently called by some C++ code inside InDesign. It's passed an array of arguments in the global "arguments" variable.
However, in my case, the "arguments" is zero-length; the C++ code is not supplying any arguments to the script.
Not sure what I can do about that at this point, but it was (for me) an interesting discovery.
This worked for me and made a pdf....I took the itemByName("Test"); out.
//Shows how to process an InDesign preflight profile.
// Assume there is a document.
var myDoc = app.documents.item(0);
// Assume the Test preflight profile exists.
var myProfile = app.preflightProfiles;
//Process the myDoc with the rule
var myProcess = app.preflightProcesses.add(myDoc, myProfile);
var myResults = myProcess.processResults;
//If errors were found
if (myResults != "None")
//Export the file to PDF. The "true" value selects to open the file after export.