Copy link to clipboard
Copied
Hi all.
I try to create a PDF form. Instead of text lines, I use images (imported from another program), as it gives me more styling options, and removes the font & encoding issues. However, in the resulting PDF, these images are selectable. So if I have a big image, on which there are (say) 4 fields, all the them are selectable. How do I define the images as unselectable?
Also, I want one of the images to be hidden (and later be turned visible, when the form is complete). I think that can be done with JavaScript, if the image as a name (something like this.getField("Image1").display = display.visible). But how do I define a name to this pasted image?
Thanks a lot!
Copy link to clipboard
Copied
Use image fields and import the images.
Copy link to clipboard
Copied
It doesn't work... the images are still selectable.
Copy link to clipboard
Copied
You can set the image fields as hidden.
Copy link to clipboard
Copied
How do I do that? I don't want them to be permanently hidden. They have to be turned visible (when the form is complete). If it's to be done by JavaScript, then I think these fields must have names. And I couldn't find how to give images a name.
Copy link to clipboard
Copied
You can't assign names to images. Use the name of the image field.
Copy link to clipboard
Copied
Your basic approach is wrong. There shouldn't be any font or encoding issues with plain text, if you create the file with a proper PDF converter. That's the entire point of PDF files, making documents that are portable and can be viewed correctly, no matter where.
Copy link to clipboard
Copied
I'm creating my files with PDFill (www.pdfill.com). I don't know if you count it as "a proper PDF converter"... anyway it does have some issues with encoding of text in some languages. And as I mentioned, the encoding is only one reason why I use images. The other reason is the styling. Creating images in another program gives far more options of styling, design, colors, shapes and many more features.
And about "names to images", I did indeed mean the names of the images FIELDS. Using PDFill, I found no way to give or view these names. I even viewed the PDF with a text editor, trying to identify anything that looks like the field name of the image, and found none.
And I'm still looking for a way to make these images unselectable. Is there any?
Copy link to clipboard
Copied
Do you use Adobe Acrobat?
Copy link to clipboard
Copied
I don't know about PDFill, but if you have Acrobat Pro you can import the images as an OCG layer, which can be hidden or shown with JavaScript.
Here's a tutorial:
https://acrobatusers.com/tutorials/create_use_layers
About the images being selectable. What do you mean? How are they being selected? With what tool, in what viewer?
Copy link to clipboard
Copied
I'm creating the PDFs using PDFill. After they're created, they're to be viewed by Acrobat Reader (at least, that's what most of my costumers will be using).
About hiding the images, OCGs are indeed the solution. It works perfectly. Thanks!
What I meant in "selectability", is that, normally, when the PDF contains an image and the user clicks on it, the image gets the focus. That's undesirable in my case, as the images are to be part of the PDF "background". The user shouldn't be able to interact with them in any way (the fillable fields are on the images, and the images getting focus is really ugly). Is there any way to cause the click on the images to do nothing at all?
I tryed using something like this.getFields("Default").setFocus() every time an image is clicked. Now they really don't get the focus, but some flickering occurs. Is there any way to get rid of that?
Copy link to clipboard
Copied
Maybe you can make it read only. Might work.
Copy link to clipboard
Copied
In Adobe Acrobat use password protection and allow only form filling.
Copy link to clipboard
Copied
The only way the behavior you have described could happen in Acrobat Reader is if the image is in a Button Field. You need to be very explicit when you talk about these things. Images that are part of the content do not do this. However, you're in luck. There is a very very easy solution. Make the Button field containing the image ReadOnly.
Copy link to clipboard
Copied
Sorry for my ignorance... you should take into account that not all the posters here are PDF-experts, and therefore don't always express themselves in the correct terms. Furthermore, things that are obvious for you, Experts, may be somewhat difficult for others. For example, I spent a lot of time trying to figure out what is exactly a "Button Field" and how do I make it readonly. I didn't want to bother you with that, as I realized it's too trivial for you... however, I failed. I found out (easilly) how to define a Form Field as readonly, but not an image. I tried to access the image properties in every way I could think of, scanned the net for a clue, but all in vain. So, how do I define this image as RO?
(The images were cut & pasted into PDFill from another program, in case that matters)
Thanks for everything.
Copy link to clipboard
Copied
I wanted to understand about how the image is being added to the PDF because that determines the solution. So putting the image in a button must be a feature of PDFFill. Makes sense since the name implies it is a form filler.
There two solutions. The first is, as all the other posters have said, to use the form tools to make the image (button) field readonly. The other solution is to flatten the button field into the page content, both of these options require Acrobat Pro, or some 3rd party tool that can do the same. Actually I think you may be able to set readonly on a field from reader using the JS console window.
Copy link to clipboard
Copied
I've uploade the PDF to images.pdf - DocDroid
You can open it in Reader, and see two images. If you click the upper one, it gets the focus. If you click the second one, it gets the focus and immediately loses it (it runs this.getField("Default").setFocus() while "Default" is a text form field in the upper-left corner). Both these actions are undesirable. I want the images to be completely uninteractable, if possible.
(Also there's a watermark, and that's all in this file. No buttons at all).
About using JS to make the field readonly, I understand it's possible only if I know the image's name (that is, the fieldname). However I don't. I couldn't find any way to discover the name. I even scanned the file (using a text editor) and saw nothing that could be the fieldname.
About using Acrobat Pro - well, I'll probably need to do this to a large number of files, and it should be done automatically. I don't mind opening the PDF as a text file and modify it with anything able to modify text (a text editor for one-time changes, a scripting language that is good at text editing for the automatic process). I did it before. If there's some way to edit the file itself to mark the image as "page content", that would be great.
Copy link to clipboard
Copied
As TSN says, you cannot edit a PDF in a text editor, or any other simple editing tool. PDF is a complex binary format. If you don't understand it, don't touch it.
Now, you can download a free tool here which will allow you to use the JavaScript console in Reader:
You'll find a video on using the console here:
Free Video Content & Full Listing of Available Videos
Run this code to discover all button field names in the PDF, and to set them to readonly
for(var i=0;i<this.numFields;i++)
{
oFld = this.getField(this.getNthFieldName(i));
if(oFld.type == "button")
{
console.println(oFld.name);
oFld.readonly = true;
}
}
Copy link to clipboard
Copied
(As I mentioned, I have some experience in editing PDF files. I know something about the xref table. But of course I can use a scripting language. Many of these have modules that can manage PDF, while treating the PDF as a text file. But never mind).
You didn't try your JS code on the file I've uploaded, did you? I tried, and discovered that there're only text fields. oFld.type is "text" for the only two fields... that means that the images aren't fields. At least, this.numFields doesn't count them.
Copy link to clipboard
Copied
You mentioned another option - to make these images part of the content of the file. Any easy way to do that?
And on another topic. When I create a field and define it as a date (by defining a format), the user (that uses Reader, at least) can type in the date manually, or alternatively can open a small calendar to choose a date. That's a cool feature. But I want to prevent any possible typos. I want the user to be unable to type in any date - just to choose from the calendar. Is it possible? I thought about defining the field as readonly (with a JS piece to remove the readonly, modify it and re-define it was redonly), but then of course the calendar won't open, too. Any way to do it?
Thanks a lot!
Copy link to clipboard
Copied
Okay, I've managed to flatten the images into the page content. Now they can't get the focus, and that's great.
However, I'd like to do it dynamically, too. Can the page content be changed via JavaScript? say, when the user clicks a button? I want a click to make a specific image appear, and another click to make it disappear, thus emulating OCG-layer-like behavious (only that OCG doesn't work in the page-content context, and therefore the images are selectable).
Is it possible?
Copy link to clipboard
Copied
You can add images to buttons and show/hide the buttons.
Copy link to clipboard
Copied
if you’re using a different piece of software to make your PDF you probably need to seek help from the makers of that software. We gave no idea what that software does if you “paste an image”.
Copy link to clipboard
Copied
The makers of that software weren't very helpful so far, unfortunately. And i think you underestimate your ability to help. As PDFs have their own terminology (unfamiliar to those unfamiliar with PDFs...), most pieces of software that deal with PDFs follow this terminology.
For example, a few posts ago I learned about OCG , a concept totally unknown to me before. I looked in my software, and could find nothing with that name. However, that post also taught me that they're called 'Layers', too, their definition is document-wide and every object can be made part of a layer. Knowing that, I knew what and where to search, and easily found the way to do it.
Now I have no idea what a 'Button Field' is. Sounds like a field of buttons. Is it a general term or tied to a specific button object? is it docuemnt-wide or defined on each object? how does it relate to images? my PDF doesn't even have a button (I created a test PDF with only one image...), so I'm clueless on where to start searching. And most imprtant, does it have any alternate name, just like OCGs are also called Layers?
Copy link to clipboard
Copied
The fact is you are somehow adding images using software we don't have, so we don't know what it does. We speculate it's a button field, which is a type of form field. Form fields which are buttons can have an image and/or text. You would use the form editor in Acrobat Pro to check this and to change to read-only.
If you want to share a PDF, people here should be able to tell you about the image, and how to use Acrobat Pro to modify it if possible.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more