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

Script to close a DIFFERENT attached sibling document than THIS - something like app.closeDoc()

Explorer ,
Jul 24, 2022 Jul 24, 2022

Copy link to clipboard

Copied

I've gained, from Gilad at this post, an understanding of how to determine the path of a given document, and to open same.  I now want to selectively close a given document, of several open at the same time.  I took a shot at doc.closeDoc(newPath), without success.  Here's a summary:

 

There is a 'master' document named Parent.pdf.  It contains attachments

  • Son.pdf
  • Daughter.pdf
  • Nephew.pdf

 

I am able to selectively open any one, using such as

var newPath = this.path.replace(this.documentFileName, "Nephew.pdf");
app.openDoc(newPath);

 

I now want to have a button, in any attachment but Nephew.pdf, which will close Nephew.pdf.  I do not find such a thing as an inverse, i.e. – app.closeDoc().  I am aware of variations on this.closeDoc.  But I wish to close THAT Doc.  I have read reference in the SDK to using doc.closeDoc, but in the context of a newly created, newly named, doc [newDoc.closeDoc() ].  I need to act on an existing attachment, which is already open.  I do not know how to properly refer to it [or its path].  And then to Close.

 

I have a general sense as to potentially crossed wires, in what I have crudely tried.  I can smell that there's a problem in managing ths.path, when I am in fact interested in THAT.path.  The script

var newPath = this.path.replace(this.documentFileName, "Nephew.pdf");
doc.closeDoc(newPath)

rerturns

ReferenceError: doc is not defined

TypeError: app.closeDoc is not a function

ReferenceError: doc is not defined

ReferenceError: doc is not defined

 

And I assume that this.path is largely moot, in re managing OTHER documents ? 

 

Guidance is welcomed.

 

 

TOPICS
Create PDFs , Edit and convert PDFs , General troubleshooting , How to , JavaScript , PDF forms

Views

233

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
LEGEND ,
Jul 24, 2022 Jul 24, 2022

Copy link to clipboard

Copied

closeDoc is a method of Doc, as you've observed. But what you may have missed is that you need to find the existing Doc object for the alreadyopened. You're trying to use the pathname, but that's not accepted at any level. Where do you find the Doc object for another document? Well, it's a bit of a challenge. Ideally, if you opened the document yourself with app.OpenDoc you would keep the Doc object safe in a variable. 

Otherwise, you can try using app.activeDocs, which returns an array of open documents. Your challenges?

- how do you know which of those Docs is the one you want?

- did you set disclosed for the open document? Otherwise, it is completely hidden from you (see the documentation for activeDocs). 

Documents being hidden from each other is not an accidental inconvenience. It's designed specifically to stop downloaded files from being able to get at your other files ("hey, I'll send my boss a file that emails me his PDF file with all the salaries"). You need to really understand the reasons for these security blocks, to find a way to work within them.

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
Explorer ,
Jul 24, 2022 Jul 24, 2022

Copy link to clipboard

Copied

LATEST

Ahoy, TSN!

 

Encouraging.  I'm sure this is within reach.

  1. I'm all in on the security considerations; my boss can rest easy.  Gotcha.
  2. Indeed, the document is entirely one I [or my audience] open myself, deliberately, in the course of an unfolding narrative story.  The siblings all have their say; at one point we return to the parent, and certain siblings are to leave the narrative.
  3. Yes, I've seen reference to app.activeDocs [e.g. Thom Parker's Creating a close-all-docs menu item with Acrobat X, August 23, 2011].  I'll bet mine is a simpler case.
  4. I know which of the docs is the one I want, because I know how the user got to it – I invited them to open it.
  5. Here's where the learning kicks in – app.OpenDoc [more below]
  6. Also learning – I dint set disclosed to nuttin' [but I should think I can; more below] 

 

A.  'Document Object' – I like it.  Give me a hint.  Only one hit on that term in SDK.  I understand the relevance, in theory.  I'm uninitiated, in practice.

 

B.  I'll betcha it has to do with that app.OpenDoc thing, you mention.  My entire use of app.OpenDoc, to date, is that code snippet above, calling app.openDoc on the variable newPath ("you would keep the Doc object safe in a variable" – but maybe not this one?).  And you're cautioning about path being unacceptable - but that may different than 'Doc object'.

 

C.  Pseudocode:  From Parent.pdf, attached Son.pdf is opened from a plain old GUI 'Go to a page view'.  From Son.pdf is a button which opens [with the first-above code snippet, app.openDoc] Nephew.pdf.  I'm sensing that here's my chance to collect a result to 'keep safe in a variable'?  Or a 'Doc Object' to hang onto?  When it's time for the user to leave Son.pdf [via button-script: this.closeDoc(true)], it's time for Nephew.pdf to leave the scene, as well [Close].

 

D.  "Disclosed" – I've seen Gilad refer to that term.  I'm tryna' catch up.  This may be a suitable instance to employ it. 

 

Conclusion:

The origins of all documents are known; not intended to be hidden.  Would happily be disclosed, if known how.  I'm hardly wedded to GUI 'Go to a page view'.  I'm all ears.  

 

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