Skip to main content
Inspiring
April 8, 2024
Answered

Script to outline text when open pdf

  • April 8, 2024
  • 2 replies
  • 747 views

use AI to directly open pdf , if some computer missing font, so these character will show error glyph.  

how to write a correct script , the highlight is selected? thanks

 

 

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var pdfOptions = app.preferences.PDFFileOptions;
pdfOptions.pageRangeToOpen = "all"; 
pdfOptions.placeAsLinks = false;

 

//how to add outline action in here?


var idoc = app.open(File(path)); // full path to your pdf
app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;

 

This topic has been closed for replies.
Correct answer m1b

Hi @rui huang, I think you might be able to do what you ask in Acrobat. I don't know of any way to do it in Illustrator for the reason Carlos gave—Illustrator has no power to alter a pdf without first instantiating DOM objects, eg. TextFrames, and by that time, the opportunity is gone. I'd be surprised, however, if Acrobat couldn't do it. I did a quick search and this answer by Scott mentions a way to do it in Acrobat.

- Mark

2 replies

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
April 8, 2024

Hi @rui huang, I think you might be able to do what you ask in Acrobat. I don't know of any way to do it in Illustrator for the reason Carlos gave—Illustrator has no power to alter a pdf without first instantiating DOM objects, eg. TextFrames, and by that time, the opportunity is gone. I'd be surprised, however, if Acrobat couldn't do it. I did a quick search and this answer by Scott mentions a way to do it in Acrobat.

- Mark

CarlosCanto
Community Expert
Community Expert
April 8, 2024

also, opening the pdf as Links will preserve the fonts, at that point you might be able to flatten the file

rui huangAuthor
Inspiring
April 15, 2024

Hi Carlos, 

I see you reply in other post,  said that can use app.executeMenuCommand('Flatten Transparency'), but it will pop up a window to prompt. the action is not good for user.

CarlosCanto
Community Expert
Community Expert
April 8, 2024

Flattern Transparency is not part of OpenOptionsPDF, you have to open the pdf then apply Flattening after the pdf opens

rui huangAuthor
Inspiring
April 8, 2024

Hi Carlos, 

After opening the PDF document, then outline text, it is meaningless , because the fonts are missing.
function outlineText() {
while (app.activeDocument.textFrames.length > 0) {
app.activeDocument.textFrames[0].createOutline();
}
}