Copy link to clipboard
Copied
I will try to test on a windows machine o see if there is any difference.
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
filePath = "/Users/$USERNAME/Desktop/myfile1.pdf"
var fileRef = new File(filePath);
var pdfOpenOptions = new PDFOpenOptions
pdfOpenOptions.antiAlias = true
pdfOpenOptions.mode = OpenDocumentMode.RGB
pdfOpenOptions.resolution = 72
pdfOpenOptions.page = 3
app.open( fileRef, pdfOpenOptions )
app.preferences.rulerUnits = originalRulerUnits​
2 Correct answers
Try changing this:
filePath = "/Users/$USERNAME/Desktop/myfile1.pdf"
var fileRef = new File(filePath);
To this:
filePath = "~/Desktop/myfile1.pdf";
var fileRef = new File(filePath);
alert(fileRef.exists);
What is the result of the alert?
https://theiviaxx.github.io/photoshop-docs/Core/File.html
I think that there's a misunderstanding in your expectations. That's the correct and expected result of the test. False is the result if there is no file at the path of the file object. The new File() is a programming object used to work with a literal file, not a method to create a literal file. To create a literal file, you would need to create a new document and save it using the appropriate file format save options.
Explore related tutorials & articles
Copy link to clipboard
Copied
Try changing this:
filePath = "/Users/$USERNAME/Desktop/myfile1.pdf"
var fileRef = new File(filePath);
To this:
filePath = "~/Desktop/myfile1.pdf";
var fileRef = new File(filePath);
alert(fileRef.exists);
What is the result of the alert?
https://theiviaxx.github.io/photoshop-docs/Core/File.html
Copy link to clipboard
Copied
I tried to run it and getting False. I also checked the path of Desktop and the file wasn't created.
I tried search extend script on Mac and there seem to be some limitations. I used VS code to run extend scipt with small tool someone developed. I can't run the official extend script debugger because it only suppport Intel chips. My machine it too weak to run Rosetta with VSCODE which would probably solved this problem..
Copy link to clipboard
Copied
I think that there's a misunderstanding in your expectations. That's the correct and expected result of the test. False is the result if there is no file at the path of the file object. The new File() is a programming object used to work with a literal file, not a method to create a literal file. To create a literal file, you would need to create a new document and save it using the appropriate file format save options.
Copy link to clipboard
Copied
OK, thanks, I understand. But this excercise still not working. It fails on app.open( filleRef, pdfOpenOptions ) yelling it does expect an existing file:
Error 1233: Expected a reference to an existing File/Folder
Copy link to clipboard
Copied
If the file has the correct case-sensitive spelling at the path and exists = true, then the code works.
Copy link to clipboard
Copied
yeah, I kinda mixed up with open, where it use in code sometimes "creating a file". But here it means open an already created file. Thanks for the help.
Copy link to clipboard
Copied
Use app.documents.add() to create a new Photoshop document, then you can save or export to a pdf.
Copy link to clipboard
Copied
As @maya293983654m0v was attempting to open page 3 of a PDF, if the PDF doesn't exist and needs to be created and saved, it will take more work than a standard image:
https://theiviaxx.github.io/photoshop-docs/Photoshop/PresentationOptions/presentation.html
Copy link to clipboard
Copied
A newly created file would be blank and have no page 3 😄
Copy link to clipboard
Copied
A newly created file would be blank and have no page 3 😄
By Lumigraphics
That's why I was saying that it would take more work to create a multipage PDF.
Copy link to clipboard
Copied
Can Photoshop even create a multipage PDF?
Copy link to clipboard
Copied
Can Photoshop even create a multipage PDF?
By Lumigraphics
Yes, it can, that's why I linked to the PDF PresentationOptions() DOM code reference earlier in the topic.
Here's a topic where I merge file pairs to create multiple 2-page front/back PDF files.

