Skip to main content
Participating Frequently
Dec 7, 2017 9:22 AM UTC
Question

Revert file

Hello,

I'm wondering how to revert a pdf file to last saved version via javascript.

Any suggestions would be much appreciated.

Thanks in advance, M.

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

try67
Community Expert
Community Expert
Dec 8, 2017 10:55 PM UTC

var filePath = this.path;

this.closeDoc(true);

app.openDoc(filePath);

Translate
Legend
Dec 8, 2017 11:28 PM UTC

Will the script continue to execute after the document is closed?

I'm pretty sure the actual implementation of revert is much like this except

- note page number, page view, window size and position, and current viewing options

- close without saving

- reopen

- restore page number, page view, window size and position, and current viewing options

Translate
try67
Community Expert
Community Expert
Dec 9, 2017 12:05 AM UTC

Should be, yes.

Restoring the view state is possible, but only if the file is disclosed. Otherwise the openDoc command will not return a reference to it so it won't be possible to manipulate it after re-opening it.

Translate
Bernd Alheit
Community Expert
Community Expert
Dec 7, 2017 11:33 AM UTC

Close without save and re-open the document.

Translate
Thom Parker
Community Expert
Community Expert
Dec 7, 2017 6:07 PM UTC

Ha ha Good one!

I always thought it would be a cool to write backup tool for the internal PDF saves. Never had time though. 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often