• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Make sure PDF is saved before script proceeds

Engaged ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

I have a script that writes a PDF to the user's desktop, then calls a VB script to attach the PDF to a Slack post. Most of the time it works just fine but occasionally the saved PDF is a zero-length file that Slack can't handle. My inclincation is to add some logic to check file.length before proceeding, but I'm not what to do if/when the file.length is zero. Pause for a few ticks and try again? 

 

Hoping someone else has encountered something like this.

 

Bob

TOPICS
Scripting

Views

178

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Hello Bob,

Check out all three answers on this post to see if they'll help you out.

https://stackoverflow.com/questions/7161739/how-can-i-check-if-a-file-exists

 

Regards,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

It's not a file.exists problem. The file exists but, once in a while, file.length is zero

Slack won't accept that, understandably.

I'm trying to use $.sleep to build in a short pause between executing fileExport and starting the Slack upload process. But I'm not clear on one important question: Does pause the script execution also pause the fileExport process? I wouldn't think so but I just don't know.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

LATEST

hi Bob,

 

Here's a post to check to see if the file size has changed.....maybe you can do the upload when the file size has stopped changing.

 

https://stackoverflow.com/questions/28298946/vb-script-to-check-if-the-file-size-has-been-increased-...

 

if you're doing the file export and move is the same script you could try asynchronousExportFile, and use waitForTask(); before the upload process starts.

 

below is an example copyied from one of my scripts.

 

 

 

task = doc.asynchronousExportFile(ExportFormat.PDF_TYPE, File(myFolder +'/'+ my_layer + mySuffix + "HR.pdf"), false, export_preset4);
task.waitForTask();

//Do your upload after the export has completed.

 

 

 

 

 

 

Regards,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines