Copy link to clipboard
Copied
Hi, I have a InDesign file which contains hyperlinks. I'm using InDesign CC server with JavaScript to convert this indd file to pdf file:
app.pdfExportPreferences.includeHyperlinks = true;
var myPDFexportPreset = app.pdfExportPresets.item("[Press Quality]");
// myPDFexportPreset.includeHyperlinks = true;
app.documents.item(0).exportFile(ExportFormat.pdfType, myFile, myPDFexportPreset);this gives me a pdf without hyperlinks. If I add "myPDFexportPreset.includeHyperlinks = true" it gives an error "Error number: 35852" and will not generate the pdf.
Could anyone please to take a look?
Yes, it would copy those prefs over. And yes it would be slower. If you don't want to copy the prefs, just hardcode them into the export preferences instead of the for loop, like Mike suggested. Using hyperlinks goes against certain PDF export standards which is probably why you were getting the error in the first place.
Copy link to clipboard
Copied
Could you try exporting as interactive pdf? It uses a different preference object. Here's an example showing most of the properties:
function setInteractivePDFExportPreferences () {
with (app.interactivePDFExportPreferences) {
exportAsSinglePages = false;
exportLayers = false;
exportReaderSpreads = false;
flipPages = false;
generateThumbnails = false;
includeStructure = false;
interactivePDFInteractiveElementsOption = InteractivePDFInteractiveElementsOptions.INCLUDE_ALL_MEDIA;
openInFullScreen = false;
pageRange = PageRange.ALL_PAGES;
pageTransitionOverride = PageTransitionOverrideOptions.NONE;
pdfDisplayTitle = PdfDisplayTitleOptions.DISPLAY_FILE_NAME;
pdfJPEGQuality = Populator.settings.pdfExportSettings.quality;
pdfMagnification = PdfMagnificationOptions.FIT_PAGE;
pdfPageLayout = PageLayoutOptions.SINGLE_PAGE;
pdfRasterCompression = PDFRasterCompressionOptions.JPEG_COMPRESSION;
rasterResolution = Populator.settings.pdfExportSettings.dpi;
viewPDF = false;
}
}See InteractivePDFExportPreference.
- Mark
Copy link to clipboard
Copied
You need to copy the preset preferences to the pdf preferences, add add hyperlink, then print without preset. Or just make and load your own correct preset, not Press Quality, and call that.
On mobile but the algorithm is essentially:
for p in preset
try { exportPrefs[p] = preset[p] }
catch(e) {}
Copy link to clipboard
Copied
Thanks! How should I copy the preset preferences to the pdf preferences?
Can I use provided preset like [Smallest File Size]? I am using this preset for now, and hope to continue using it so the resolution is not changed.
Copy link to clipboard
Copied
Sure yeah. Like I said,
for (var p in preset) {
try { prefs[p] = preset[p] }
catch(e) {}
}
Then just don't call a preset on export. And add your hyperlink line.
Copy link to clipboard
Copied
It worked with this:
var myPDFexportPreset = app.pdfExportPresets.item("[Smallest File Size]");
for (var p in myPDFexportPreset) {
try {app.pdfExportPreferences[p] = myPDFexportPreset[p];}
catch(e) {}
}
app.pdfExportPreferences.includeHyperlinks = true;
app.documents.item(0).exportFile(ExportFormat.pdfType, myFile);Does it mean the output still has the same settings/resolutions as before with "[Smallest File Size]"?
This script seems to be slower than before after I added this forloop.
Copy link to clipboard
Copied
Yes, it would copy those prefs over. And yes it would be slower. If you don't want to copy the prefs, just hardcode them into the export preferences instead of the for loop, like Mike suggested. Using hyperlinks goes against certain PDF export standards which is probably why you were getting the error in the first place.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more