Skip to main content
Participating Frequently
May 12, 2020
Question

How to catch a generated pdf doc at runtime? (javascript)

  • May 12, 2020
  • 1 reply
  • 1342 views

Hi,

i use Acrobat XI/Windows.- the methods used are app.trustedFunction.

 

The script generates a pdf doc through the Adobe PDF printer to be used subsequently in the same script, however, despite seeing how it has been stored in the local folder, at runtime app.openDoc () does not recognize it as [doc object]: JavaScript Debugger console returns "Invalid location. The file or folder does not exist".

 

The Adobe PDF printer settings allow you to display or not the printed pdf document. I have tried both ways. When it shows it, I try to select it with app.activeDocs, but it doesn't detect it either.

 

I am being forced to break into two action button scripts with user intervention (so the script works correctly), when I want the process to be completely silent and unattended.

 

I hope my question catches your attention.
Thank you.

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
May 12, 2020

What script does you use?

KasanAuthor
Participating Frequently
May 12, 2020

hi, Bernd_Alheit, Thanks for your interest

the work scheme is as follows: 

FORM-MODEL-BLANK.PDF --> FORM-FILLED.PDF --> FORM-FLATTED.PDF --->send email.

 

*****This is the function in mouse-up botton event*************

 

// script function process button in FORM-MODEL-BLANK.pdf (this)

function process()

{
var cpathform = "/D/TMAS/FILLINGFORMS/form-filled.pdf";
var cpathformflat = "/D/TMAS/FLATTENFORMS/form-flat.pdf";
var cTo = this.getField("email_To_TMAS");

myTrustedSaveAs(this, cpathform); //function <mySaveAs.js> in the application Javascripts folder

var pp = this.getPrintParams ();
pp.interactive = pp.constants.interactionLevel.silent;
pp.printerName = "Adobe PDF Converter TMAS";
pp.bUI = false;
pp.bSilent = true;

this.print(pp);

this.closeDoc();

//HERE is where the printed pdf document "form-flat.pdf" does not recognize
myTrustedOpenDoc(cpathformflat); //function < myOpenDoc.js > in the application Javascripts folder

// would wait for the return of the printed document as a [doc object] oDocx

/*send email:
oDocX.mailDoc({
bUI: true,
cTo: cTo.value,
cCC: "",
cSubject: " ",
cMsg: " "
});

oDocX.closeDoc();
*/
}

 

************Function <mySaveAs.js> in the application Javascripts folder

mySaveAs = app.trustPropagatorFunction(function(doc,path)

{

app.beginPriv();

doc.saveAs(path);

app.endPriv();

})

myTrustedSaveAs = app.trustedFunction(function(doc,path)

{

app.beginPriv();

mySaveAs(doc,path);

app.endPriv();

});

 

 

************Function <myOpenDoc.js> in the application Javascripts folder

myOpenDoc = app.trustPropagatorFunction(function(path)

{
try {
app.beginPriv();

app.openDoc({cPath: path});

app.endPriv();

} catch (e) {};
})

myTrustedOpenDoc = app.trustedFunction(function(path)

{
try {
app.beginPriv();

myOpenDoc(path);

app.endPriv();

} catch (e) {};
});

 

Thank you.

 

Bernd Alheit
Community Expert
Community Expert
May 12, 2020

this.print() will start the print job in background

You must wait until the print job is finished.

 

Why does you print the document.