I have a large Acrobat file (Acrobat XI Pro) which I have Bookmarked. The resulting Bookmarks are, however, all over the map so the goal is to sort the Bookmarks A-Z. I searched for an appropriate Acrobat Action without success. I did, however, locate some possible JavaScript in the the Acrobat XI SDK:
http://www.adobe.com/devnet/acrobat.html
I downloaded it (at bottom of EULA for version XI):
http://www.adobe.com/devnet/acrobat/sdk/eula.html
I found a reference on batch sequences with three sections of interest: (1) Gather bookmarks to an array; (2) Sort Bookmark subroutine; and (3) Copy bookmarks from an array.
Ideally I would like to combine all scripts into a single JavaScript call in the Action. My first attempt was to create an Action with two separate JavaScript calls (1) as the GATHER and (2) & (3) as the COPY with the SORT integrated
The first JavaScript compiles after I put the script into the JavaScript call in the Action. However, the second JavaScript would not compile. The error was an "unterminated string literal" at this line of code:
+'var that =
app.openDoc("'+ global.bmArray[i][1]+'.pdf", [ERROR PRESENTS HERE]
this);\r\t'
+'if ( this != that ) this.closeDoc();\r'
I researched this error online and tried various solutions without success.
When I failed with building within an Action, I took the put the two JS scripts – the Gather and the Sort - into a .txt file and saved it as a .sequ which, when , should automatically populate into Acrobat as an Action. When I did this Acrobat reported it as corrupt and unloadable so that didn't work either.
My hope is a review of Adobe’s code with a solution to the unterminated string literal error a guide that the location guidance on the insert location of the SORT into the COPY part of the script.
My goal, as noted, is to have an Action that merely re-sorts the Bookmarks. The JavaScript I found seems to fit the bill as it marks the Bookmark links to the respective document. If I am incorrectly reading this and could be steered in the right direction, it would be appreciated.
Related
I am attempting to have a Discord bot re-add all items from existing lists upon reinitialization, such that the titles of each list are saved in a preexisting local .txt file (e.g. AAA_filenames.txt), with items separated by semicolons (which the code successfully detects as individual parameters). Each title parameter is saved as another .txt file, and its items are appended to that file, once again, separating themselves by semicolons such that it can be read.
To my knowledge, all of this is completely successful and works perfectly, but the only problem I have is that I can't seem to put a template literal inside of a path (see paragraph 4 for an example path).
I've tried many things, most of which I've forgotten, but I can tell you that I've tried everything that both made sense to me and was on StackOverflow (to my knowledge).
Since I am using Discord Bot Maker (along with DBM-Mods) as my tool to format my code due to its efficiency and overall ease, I will be reluctant to release that code due to the fact that very few legitimate Discord bot creators use it (to my knowledge, of course), so for now, I will give you an example of the path that just doesn't work:
.\TXTSTORAGE\${tempVars("param-x")}.txt\
While I am aware that I am not supposed to simply post one line or an entire file, the startup initiative event is very long and its functions are spread throughout the entire file, so... my hands are tied here. Instead, I will tell you that all variables are stored correctly.
I've had the bot send back messages to the console and to a private Discord channel confirming that all variables do indeed exist and their values match up perfectly with what they should be.
I've also had the path point directly to the name of an existing .txt file that works the same way as the others in the same directory, that's all well and good, but it stops at one point because not all of the variables are in play when I do that; it must point at the variable-dubbed .txt file, which is fully dependent on which parameter AAA_filenames.txt has selected. So, that does confirm that the path itself can be read - however, it will refuse to read from a template literal, despite every other command on Discord Bot Maker allowing full access to template literals in this context.
I fear that it may have something to do with the raw code involved, but I couldn't find any issues with it. Maybe I've been working for too long at a time... but here's the raw text:
# ... rest of code
{
"filename": "C:\\Users\\Owner\\Desktop\\Sans Undertale\\Undewtale\\TXTSTORAGE\\${tempVars(\"param-x\")}.txt\\",
"storage": "1",
"varName2": "file-x",
"name": "Read File"
},
# ... rest of code
My expectations are listed in the first paragraph... actual results listed in title. Function refuses to read from path and carries on throughout the function until it's failed too many consecutive times. **So, here's what I'm looking for:
A vastly simpler way to force lists and their items to persist throughout resets without changing variable names
OR
A solution to this simple-looking, but quite possibly impossible issue.
My only condition: Discord Bot Maker-compatible, or at least compatible with a Node.js-exclusive export of the bot.**
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 am trying to import data from a tab delimited text file into a PDF using javascript. I am attempting to do this (testing just the first line, at least) through the JavaScript Console using the following code:
var blah = this.importTextData("/C/Users/sbarry/Desktop/abc123.txt", 0)
console.println(blah)
My text file looks like this:
First Second
ABC 123
DEF 456
GHI 789
I made sure I had form fields labeled First and Second on my PDF and then executed my code. The result is:
undefined
It runs successfully.
Under my preferences I have the checkbox "Enable JavaScript Actions" checked, and I have "Enable Safe Reading Mode" unchecked in order to overcome any security restrictions. How can I make this work?
I am using Foxit PhantomPDF ver. 7.2.
UPDATE:
I got a response from someone at the Foxit team. Apparently their software recognized the function but is unable to implement it, so hopefully that will be addressed in the near future. For now, I am going to be using this.importAnFDF by generating an FDF file from scratch. (NOTE: This function does not have a return value, unlike this.importTextData.)
For information on FDF file structure, see section 12.7.7 of this document:
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
The easiest way to see what an FDF file requires is to export one from your PDF editing software, open it with notepad or something similar and edit the field names and values to whatever is appropriate for your PDF form.
I have 2 docx files that I am working with. One docx file contains text information of a product (start serial number, length, width, and height). The other docx file contains a sticker label with an image and all of the text information from the first file.
This is what I do currently:
I open the first docx file and copy all of the text information (serial, length, width, and height)
Then I paste each info into the second docx file that contains the formatted label.
If I need to make more than one label, I copy the label and increment the serial number by 1.
This takes a lot of time to make several labels for different products. My goal is to come up with an easier way to take data from one docx and inject it into the other. Also, generating more labels when needed.
My first thought was to extract the docx file to get it's xml contents. Then read the data using javascript, c++, or any other language. Then Ask user to input number of labels to generate, manipulate the xml, and repack it as a docx file.
Then I thought about trying to use the windows office "mail merge" feature, but I have never done this before.
I would like to know if anyone has any suggestions for an easy solution to import data from one docx file and generating labels into another.
I am open for any suggestion.
Also, I am not a professional programmer. I am an undergraduate computer engineering student with some experience in c, c++, java, javascript, python, MIPS assembly, and php.
The only open-source (and probably easier to come by) solution I know know is:
http://poi.apache.org/
http://poi.apache.org/document/quick-guide-xwpf.html
This is a good bet when it comes to speed and it is free software.
But if you open a file, alter it and save it again - the result can be flaky: The formatting can be slightly off. At least in my tests with the pptx counterpart.
I reckon when you have user interaction (web page?) in order to create the document, you can build a small HTTP Api around the library.
There is also: http://www.docx4java.org/trac/docx4j - which I have not tested yet.
You can also go the C#/Redmond way: How do I create the .docx document with Microsoft.Office.Interop.Word?
The Interop (2nd Example in the first answer of the question above) way gives the best result when it comes to the accuracy of the formatting. Basically when you open a file with Interop - it will look the same when you alter and save it. But you cannot use this when interacting with a user - because it starts a separate MS Office process - and I would not count on this from my own user experience. But if you want to generate these files as a batch in a single user session - it will deliver a good result.
I cannot comment on the "OpenXML SDK" library described in the above SO question.
Wath about the Open XML https://www.youtube.com/watch?v=rMnEl6JZ7I8 and website developer http://openxmldeveloper.org/ .
On the site you found sdk for:
Open XML SDK for JavaScript: http://openxmldeveloper.org/wiki/w/wiki/open-xml-sdk-for-javascript.aspx. Demo: http://openxmldeveloper.org/blog/b/openxmldeveloper/p/openxmlsdkjs_demo.aspx
Open XML and Java http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2006/11/21/openxmlandjava.aspx
.Net Resources http://openxmldeveloper.org/resources/dotnet/m/cc/default.aspx
This will be just a noobie question: This is one step of a multistage process which runs predominantly in IMACROS. So I need a solution which I can access by IMACROS in firefox browser. I have a working solution, but I know there is a faster, better and elegant solution and something which I can run locally on my computer.
I cannot do CTRL+F and search since it will be automated and IMACROS do not support keyboard shortcuts.
I have a imacros script which extracts a text string from a website, feeds it as input to a (my 1000 line text file is preloaded in the text area) online grep utility at: http://www.online-utility.org/text/grep.jsp and then extracts the first matching line and parses the output in required format using javascript and then submits this extracted and parsed text string to another website.
ATTEMPTS & LIMITATIONS:
I tried using imacros SEARCH command, but it takes hardcoded search
string. I need something where it can take the search string as
variable, since the search string changes at every iteration.
I can programs whole thing in javascript and then do all the
processing at each iteration .i.e. read the file, search and then
output), But that will be unnecessary repeated reading the file from local
hard disk and will be CPU intensive. THIS STEP IS DONE 100K+ times a
day. (THIS WILL BE SLOW AND VERY MUCH CPU INTENSIVE, I AM RUNNING THESE
SCRIPTS IN VIRTUALBOX, SO RESOURCES ARE TIGHT)
I can program imacros to output search string to a file and then
write a shell script to run every 0.1 seconds and get content of
this newly created file and use (grep, sed or awk) to search and output in another
file and from where IMACROS can read the string and feed it to
another website. (THIS WILL HAVE ISSUES SINCE SCRIPT WILL BE RUNNING NON-STOP AND I
NEED IT TO BE 100% ACCURATE, ANY ERROR AND IT STOPS THE WHOLE PROCESS DOWNSTREAM AND
I HAVE TO CORRECT IT MANUALLY AT THE END OF THE DAY, PLAUSIBLE SOLUTION WILL BE
SOMETHING WHERE SCRIPT IS CALLED ONLY WHEN REQUIRED, I WILL BE MULTI-THREADING IT)
I need to be able to do it locally on my browser. Something like a search page, with input box for variable string and button to click and then it uses my CPU to search for the string in the HTML which can have the 1000 lines of text embedded in it (so basically it can search the HTML) or it can search the link to the local TXT file and show the output on same page.
A local clone of http://www.online-utility.org/text/grep.jsp will be perfect solution. But without all the ads and extra menus and stuff. Something which can cut short 2-3 seconds of the search and response time the online utility now takes.
Each second saved amounts to a lot of time savings. Simplest, creative and elegant solution is what I am looking for.