As the title suggests I'm trying to understand how to link a FileAttachment annotation with the actual file in javasacript. There are no properties that do this while I'm performing the addAnnot function. So after I've used addAnnot to create the annotation how would I link it to open an actual file?
Appreciate the help
Something like this but with a few caveats. First, you need to use a device independent path to the PDF, you can find out more in the Acrobat JS reference. Also, if you want to attach the file without user interaction, the script must be in a privileged context. Again, more on that in the JS reference. If you want the user to be able to select the file, leave cAttachmentPath empty and they'll get a file selection dialog. Note: Many file types like executables, .js, etc. can be attached but then not extracted by Acrobat or Reader for security reasons.
var annot = this.addAnnot({
page: 0,
type: "FileAttachment",
point: [0,0],
cAttachmentPath: "/c/temp/foo.pdf"
});
Related
I have a working Gulp script that I use to create my SVG sprites along with a preview page. But now I want to enrich the preview page, more precisely each icon in it, with information that I have in a separate json file. But I don't have any idea how to do this.
It should look something like this:
function taskFactory(name, spriteMode) {
return gulp.src(srcSvgDir + '*.svg')
.pipe(svgSprite(config))
.pipe(jeditor((json) => {
// read json file for this sprite
// iterate entries in json
// Find the location in preview page (by selector or placeholder string) and paste the information from the json entry.
}))
.pipe(gulp.dest(destDir));
}
But I have no idea if I even have access to this preview page that is being created. If anyone has a completely different idea, I'm open to anything.
In a case of emergency, I could write a C# console app that, after creating the sprite and preview page, parses and edits the latter file. I don't think that's so nice though, since I want to create it purely with Gulp.
I am attempting to have a button on a form that will launch file explorer for the user to select pdf files to insert into form.
The insertPages script will insert pages from a specific cPath, but I need the user to be able to select the pages to insert, as they will be different from case to case. Is there a way to accomplish this using javascript?
I am using Bluebeam, which is very similar to Acrobat. I have created several templates and javascript code using the Acrobat API Reference, and thus far the Bluebeam engine appears to operate nearly identically. In a perfect world, the button would launch the "Insert Pages" menu in Bluebeam.
Thanks in advance for the help!!
If this were Acrobat, I'd use app.browseForDoc(). The returned object has three properties...
cFS - A string containing the resulting file system name for the chosen file.
cPath - A string containing the resulting path for the chosen file.
cURL - A string containing the resulting URL for the chosen file.
Get the full path to the file from there then use insertPages.
In Acrobat, it can only be run in a Privileged context. I'm not sure if it will work the same way in BlueBeam though they have done a fairly good job of duplicating the form field related JavaScripts.
I understand this might just be impossible but when you're making JS available for easier debugging in devtools via the helpful //# sourceURL comment, I'd also like to map it to its respective local file, for easy editing.
Clarification on #// sourceURL=dynamicScript.js:
Note: Notice the "//# sourceURL=dynamicScript.js" line at the end of dynamicScript.js file. This technique gives a name to a script created with eval, and will be discussed in more detail in the Source Maps section. Breakpoints can be set in dynamic JavaScript only if it has a user supplied name.
The sourced file now exists in Sources under "no-domain", and is unable to map to my workspace's dynamicScript.js file.
You can map your local web app directory to a server path, so that you can live edit the JS file that evaluates some code, but there is no way to map the dynamically generated named script to a file on the system as far as I'm aware.
If you use eval to execute code from a string, adding //# sourceURL=dynamicScript.js' simply tells Chrome to simulate that script being an actual file, so that you can debug etc. The file doesn't actually exist, it's in memory. The dynamic 'file' cannot appear as part of a local workspace because it simply doesn't exist on the system.
I am trying to create a file in the extension using this code:
Components.utils.import("resource://gre/modules/FileUtils.jsm");
var file = new FileUtils.File("C:\\Windows\\hello.txt");
But nothing happens.The file doesn't appear
Any ideas?
Your file var is an object that represents a file at the location you specified. Creating this file object does not create a file directly (you might instead choose to read from the file, for example).
You can now use the nsIFile API to manipulate the file object. For example, you can create a file at that location:
file.create(file.NORMAL_FILE_TYPE, parseInt("0600", 8));
Note that Windows UAC can cause file access to fail. You might want to try:
file.isWriteable();
but ultimately you might find that it's not possible to write to directories that UAC is protecting so you can instead choose a non-protected location, perhaps using the special directory definitions explained on this useful MDN page: https://developer.mozilla.org/en-US/docs/Code_snippets/File_I_O
I'm trying to find a way by which a remote file, represented by an HTML element on the page, can be dragged to a drag-and-drop file upload box. The default functionality of a drag-and-drop file upload is to accept input from outside the browser using the browse dialog or dragging the file inside the area, but I'm not certain if there's an implementation that allows input from an element representing a file inside the browser page.
I'm using plupload but if another plugin supports that feature, I'd love to hear about it. Edited to add: insight as to whether plupload can support this or not would be very helpful, as it is part of the specification for the project. Not very knowledgeable in JS here. I hope this description comes across clearly, been trying to search for this but nothing seems to turn up. :)
https://github.com/blueimp/jQuery-File-Upload/wiki
In addition to drag/drop/browse it will allow you to add files "manually" to the upload queue (so you can set attribute data-file in some html element then access those & add them to the queue) but you'll need to get your hands dirty with javascript, it's great plugin but indeed require some JS fluency to have it do what you want it to do
NB: imo start by not using the ui/template system it offers with it, start with the basics : https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin
From the API page :
Blockquote
Programmatic file upload
Usually, file uploads are invoked by selecting files via file input button or by dropping files on the drop zone.
However it is also possible to upload files programmatically for browsers with support for XHR file uploads (see Browser support):
$('#fileupload').fileupload('add', {files: filesList});
The second argument must be an object with an array (or array-like list) of File or Blob objects as files property.
Other properties allow to override options for the file upload, e.g. the upload url:
$('#fileupload').fileupload('add', {files: filesList, url: '/path/to/upload/handler.json'});
more : https://github.com/blueimp/jQuery-File-Upload/wiki/API