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

How do I open another file and print it?

New Here ,
Apr 14, 2017 Apr 14, 2017

Hi. I've tried to work this out but I'm stuck

I have a menu.PDF that has several buttons on it. When you press on a button, it executes a javascript that opens a few PDFs and prints them.

    var otherDoc = app.openDoc("Form.pdf", this);

    var pp = this.getPrintParams();

     this.print(pp);

Issues :

1. On my mac I am only able to open the file if I use a relative path. Using /Users/xfolder/Desktop/OMR/Form.pdf doesn't work

2. It prints the menu.pdf, not the file that opens

Could you please tell me what I'm doing wrong? Thanks very much

TOPICS
Acrobat SDK and JavaScript
981
Translate
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

correct answers 1 Correct answer

Community Expert , Apr 14, 2017 Apr 14, 2017

2. use otherDoc not this

Translate
Community Expert ,
Apr 14, 2017 Apr 14, 2017

2. use otherDoc not this

Translate
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
New Here ,
Apr 14, 2017 Apr 14, 2017

Thanks very much for your quick reply. I tried :

    var otherDoc = app.openDoc("Form2.pdf", this);

     var pp = otherDoc.getPrintParams();

       otherDoc.print(pp);

But it doesn't work. The PDF opens but it doesn't print

Translate
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
Community Expert ,
Apr 14, 2017 Apr 14, 2017

Are both files located in the same folder?

Does the file open, but doesn't print? Or does it not open at all?

Is there an error message in the JS Console when you run this code?

On Fri, Apr 14, 2017 at 9:47 AM, doobeedoobee <forums_noreply@adobe.com>

Translate
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
New Here ,
Apr 14, 2017 Apr 14, 2017

Hi try67.

Both files are in the same folder. The file opens but doesn't print.

There is an error message that says otherDoc is not defined.

Thanks for your help

Translate
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
New Here ,
Apr 14, 2017 Apr 14, 2017

I've just found out about needing to set disclosure to true. I'm trying to do this but am finding that I can't get document level scripts to run. I'm using a test script with an alert but the alert isn't happening...

Translate
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
Community Expert ,
Apr 14, 2017 Apr 14, 2017

Have you set the disclosed property?

Translate
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
New Here ,
Apr 14, 2017 Apr 14, 2017

Hi Bernd.

I just found out about that. I went to Tools>Document JavaScripts and added a test script :

function test()

{

this.disclosed= true;

app.alert("test");

}

The alert is not happening and the otherDoc variable is still not defined. Am I missing something obvious? Thanks

Translate
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
New Here ,
Apr 14, 2017 Apr 14, 2017
LATEST

Fixed it. Changed it to just

this.disclosed= true;

app.alert("test");

It all seems to be working now. It's now printing from the other PDF.

Thanks very much for your help

Translate
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