Skip to main content
Participating Frequently
December 7, 2017
Question

Revert file

  • December 7, 2017
  • 2 replies
  • 843 views

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 has been closed for replies.

2 replies

try67
Community Expert
Community Expert
December 8, 2017

var filePath = this.path;

this.closeDoc(true);

app.openDoc(filePath);

Legend
December 8, 2017

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

try67
Community Expert
Community Expert
December 9, 2017

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.

Bernd Alheit
Community Expert
Community Expert
December 7, 2017

Close without save and re-open the document.

Thom Parker
Community Expert
Community Expert
December 7, 2017

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. 

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