Set Button icon using attached file - javascript

I'm creating a kind of template for users to fill out in Adobe Acrobat Pro X, but they also need to attach photos. I've created a button based on this thread here which, when clicked, prompts the user to select a file and then attaches the file to the PDF. It works beautifully, except the template pdf has multiple pages with multiple locations for photos.
I need a way to keep track of which (picture) attachment belongs to which location. My main idea so far is to simply insert code that will take the file and use it as the button's icon. (This is also good in the case where the user accidentally attaches the wrong file, then goes and uploads the right one without deleting the old one; I'll see the most recent choice and assume it's the correct one).
The other idea would be to rename the files as they get attached (to Attachment1, etc.) but this doesn't seem to be as feasible.
There are 2 different functions for the button depending on if the users are using Reader 11 or not.
When they are not using Reader, the main code looks like this:
app.alert({
cMsg: "Please select a file to attach.",
cTitle: "Attach File",
nIcon: 3,
nType: 0
});
try {
var rc = this.importDataObject("Attachment" + attachment_num);
if (rc) {
attachment_num += 1;
app.alert({
cMsg: "Attachment successful.",
cTitle: "Attachment Successful",
nIcon: 3,
nType: 0
});
I was thinking as the first line of the if statement, I could insert code to change the icon of the button that this code is running from, but I can't figure out the right thing to try. I was looking at using buttonSetIcon based on here but I'm doing something wrong, probably because of my lack of JavaScript knowledge.
What I was trying was something along the lines of this
var f = this.getField("ImageButton");
f.buttonSetIcon(rc);
It doesn't work though. I am not sure what exactly importDataObject returns in the variable rc but I was hoping it would be the file itself.
When the user is using Reader 11, this gets even more confusing because everything seems to just be one line of code, annot.cAttachmentPath;, but I'll focus on the other version first.
Any ideas?

Put the following line of code in the Mouse Up action of the button.
event.target.buttonImportIcon();
This will open a file selection dialog where the user can select the image to import and set it as the "normal" button icon. It will import the icon into the button that was pressed so you can use it for multiple buttons.
Note that in Reader, the image will need to be converted to PDF first. In Acrobat, the conversion will be automatic.
If you need a way to add images (as images) to Reader and you can tolerate the user positioning them manually, you can simply paste the image from the clipboard and it will show up in the PDF as a stamp. You need to instruct the user on how to get the image onto the clipboard though. Then they need to scale and position the image.

Related

Automatically download a file from a website every day

I need to download a file from this website: "https://es.investing.com/indices/merv-historical-data", automatically and every single day. To download the file I must click a js button that says "Descargar Datos" (or "Download Data").
I can't find something that works for this, and I would really appreciate it if someone could help me.
If you want the data automatically exported in to Excel Spreadsheets, you can actually pull a table from a website. I found this article about how to do it:
After opening a new sheet in Excel, click "Data" in the navigator bar
All the way to the left, there should be a button that says "From Web"
After clicking it, it will ask for a URL. Just copy-paste "https://es.investing.com/indices/merv-historical-data" (without quotations)
The first time it might ask if you want to establish an anonymous connection, just click ok.
Excel will then try to connect to the website, give it a few minutes.
You will then get a file drop down with a bunch of tables. Table 0 is what you are probably looking for. Select it and then click "Load" in the bottom right corner.
This is basically what that button did on the website. It just compiled the data and then invoked a download.

Need help on scripting about crop with All pages.

What i have: I have 2 JavaScript files. (They are now in Menu section, thanks to #ReFran)
Trim PDF's all pages by their trim size.
Crop and extract all pages by their specified name.
PROBLEM: In this process before starting second script all the time, I have to activate "Set Page Boxes" then Manually select "ALL" from page range section then click on OK.
What i Want: I want to merge both script. If anyone knows how to activate "ALL" radio box in Page Range from JavaScript.
.
After running first script.(TRIM)
I want this through javasctipt.
This is finished version of extracted PDF.
You can't activate "ALL" from the dialog via JavaScript but you don't really need to. I suspect the reason you think you need to is that the script assumes the trim box exists. It might not... it's not a required page box type. When the script doesn't find the trim box, it gets a null and fails. To solve your problem, your script should check for the existence of the "trim" box and if it doesn't exist, use the "crop" or "media" box instead. This gets around your manual step.

Get Image URL/Address from webpage selection using Applescript/Javascript

I need a quick way to get the image URL, just like I would get if I right click on an image and select "Copy Image URL". I'm thinking Applescript, though others have mentioned Javascript.
This needs to be compatible with an Automator workflow and needs to work with Google Chrome, Chromium, and Safari, at a minimum.
More specifics:
I already have an Automator workflow that this will be added to.
The workflow begins with text and images that I have selected on a webpage using the mouse.
The processing of the text is working fine.
I just need a Applescript or Javascript or Shell Script (which I assume are the only outside code that can be added to an Automator workflow) that will grab any and all image URL's within the part of the page selected in step 2.
Images are NOT downloaded. Only the image URL is needed.
The basic logic is this:
Does selected input contain images?
If yes,
get URL of image(s)
pass to the next step
else continue
Any help or ideas appreciated!
OS X Services would be your best bet. Those work with text selections and are supported in most apps (e.g. see the Safari>Services submenu). You can also assign them keyboard shortcuts, which is very handy for repetitive tasks.
Basically, you want to get the selection as web content (i.e. HTML data, not plain text) then extract the URLs from that. You can create services in Automator, which includes various actions for working with web content, so I recommend starting there.

How to choose a specific thumbnail photo on like button

I have a webpage i keep adding a like button app to but whenever i click like i get some random member phot of a lady on facebook representing my page. this is frustrating.
I find all this html script and i cant seem to put it together properly so will you just please give me a simple paste ready like button formula with a set specific thumbnail photo that I can choose to represent my own page?
Use the open graph properties for your webpage defined here:
http://developers.facebook.com/docs/opengraph/

How to insert an image from client-side into an editor?

Like an "insert" menu, by which to insert an image into the editor, using JavaScript, I've no idea what's the solution at all,
should be in 2 steps:
Let the user choose an image (this should be doable by an input type=file).
Insert the chosen image into editing context(don't know how to implement).
You won't be able to achieve this without uploading the image to your server, since the only reference you can have inside the text area is to a public website (i.e. not the users hard drive).
I'd recommend checking IMCE; that's what I use.
It allows the user to upload images. Together with a nice WYGIWYS editor such as TinyMCE it works like a charm.

Categories

Resources