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
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.
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.
Copy link to clipboard
Copied
Ahoy, TSN!
Encouraging. I'm sure this is within reach.
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.