Expand my Community achievements bar.

Help with Button to Open File

Avatar

Former Community Member
I would like to be able to use a button in my form to open a document located on our network server on click, but using the user entered variable entered in a numeric field as the part of the file name;

ie. openDoc("/c/BC06-[user entered number from num field here].pdf");



I am not sure about how to open local files, is openDoc the correct function?



I have been vainly attempting to make this work, I apologize for my lack of skill, any help at this point will help me save my job!
7 Replies

Avatar

Former Community Member
You could do something like this:



var numValue = numField.rawValue;

openDoc("/c/BC06-" + numValue + ".pdf");



I'm not sure if openDoc actually opens the doc or just creates an Document object to use in script. If it doesn't work, you could try the launchURL() method.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Thanks Chris, that is useful.

I am trying to create an Index that lists a series of files, all withthe same prefix, i.e. BC05- and the user names the next file in the series by entering int he next number available.

What would be nice is to have a button, labelled BC05- that uses the numerals entered in the adjacent field as stated, that opens the file that is associated only with the numerical field next to it on the same line,i.e

[BC05-]+[01]

[BC05-]+[02]

[BC05-]+[03]

[BC05-]+[04]

So would there be a way, do you think, of having the button on the left refer only to the one right next to it?

I guess the work-around is to manually set the link for each line since I know that the series is in order form 1 to infinite.

Any help is so much appreciated!!

Avatar

Former Community Member
I'm not sure I understand. But to use the value entered by the user in the numeric field in the file path string, you just need to concatenate the rawValue into the string that is the path.



If I misunderstood let me know and I'll try to help further.



Chris

Adobe Enterprise Developer Support

Avatar

Level 6
Hi Jason,



Something to watch for with app.openDoc. I've noticed that in some versions of Adobe Reader (7.0.5 I think), it doesn't work properly unless you pass the second "optional" parameter, which must be a doc object. That object serves as "a base to resolve a relative path". I believe the syntax is app.openDoc("C:\Temp\mydocument.pdf", event.target);



Whatever you do, be sure to test in 7.0.5 when using app.openDoc.



Hope this helps,



Jared Langdon

J. Langdon Consulting, Inc.

Avatar

Former Community Member
Hello.

I'm having heaps of trouble with this. Your suggestion didn't work for me. I want the document to remain hidden but open so I can get some field details from the open form.



For example:



var DocProp = app.openDoc("{

cPath:"/C/PDF Containing User Details1.pdf",

bHidden: true;

});



Any other suggestions would be greatly appreciated.

Avatar

Former Community Member
Hi,



this is the way i did it and it worked for me:



app.openDoc({cPath: "fileToBeOpened.pdf", oDoc: this, sFS: "", bHidden: 0, bUseConv: 0});



This is out of the documentation 'Acrobat JavaScript Reference':



cPath:A device-independent path to the document to be opened. The path can relative to oDoc, if passed. The target document must be accessible in the default file system. NOTE:When cFS is set to "CHTTP", the cPath string should be escaped, perhaps using the core JavaScript global function encodeURI().

oDoc:(optional) A Doc Object to use as a base to resolve a relative cPath. Must be accessible in the default file system.

cFS: (optional, version 7.0) A string that specifies the source file system name. Two values are supported: "" (the empty string) representing the default file system and "CHTTP". The default is the default file system. This parameter is only relevant if the web server supports WebDAV.

bHidden:(optional, version 7.0) A boolean, which if true, opens the PDF file with its window hidden. The default is false.

bUseConv: (optional, version 7.0) This parameter is used when cPath references a non-PDF file. The bUseConv is a boolean, which if true, the method will try to convert the non-PDF file to a PDF document. The default for this parameter is false.

NOTE:(Security version 7.0) bUseConv can only be set to true during console and batch events.



For the file name you should concatenate variables and static strings like this:



var sUserInput=[user entered number from num field here];

var sFileName=("/c/BC06-" + sUserInput + ".pdf");



app.openDoc({cPath: sFileName, oDoc: this, sFS: "", bHidden: 0, bUseConv: 0});



Let me know.



Valerio

Avatar

Former Community Member
hi...I want to know if the given pdf file contains bookmarks or not....



the local path to pdf is passed using







from the browser.......

now i want to write a function to know if this file contains bookmarks or not..... using javascript......thanks in advance.....