Copy link to clipboard
Copied
Hello
I'm trying to flatten a PDF document and preserve its many internal and external hyperlinks.
Reading through this forum, it looks like it's possible to do with Acrobat, in this discussion, for instance :
The method seems to be:
"You need to use this code:
this.flattenPages({nNonPrint: 1});"
However, I have no idea where to insert this code in Acrobat?
Would love to get some help with this. Thank you.
You don't insert it anywhere. You can run it from the JS Console, or via a Custom Command, for example.
Your video can't be from an Adobe application. You probably used a third-party application that does not respect the security policy.
The way to achieve what you described is to outline the text, which basically converts it into an image. There's a built-in command in the Preflight tool that allows you to do that. Attached is the result.
This is considered very inconsiderate for the user, though, as it completely disables the option to search the file, for example.
Copy link to clipboard
Copied
You don't insert it anywhere. You can run it from the JS Console, or via a Custom Command, for example.
Copy link to clipboard
Copied
Thank you. This worked: the key word was "Custom Command", which I didn't know I needed to use.
I've done that now, setting a script command to run. I found out how to do it here: https://experienceleague.adobe.com/en/docs/document-cloud-learn/acrobat-learning/advanced-tasks/cust...
However, the script only does its magic for the first page or so, and not the other 677 pages. But that's for another question.
Copy link to clipboard
Copied
What do you mean? Are the other pages not flattened?
Copy link to clipboard
Copied
Sadly no. I thought that was due to the number 1 in the code : nNonPrint: 1
Maybe the script doesn't run, althought it says it does.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Look on the security tab on the document properties dialog. This will list the allowed permissions for the document. It's likely changes are blocked.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I should add that the initial PDF I ran the script on is secured, nothing's allowed on the permission page. It didn't make a difference though.
Copy link to clipboard
Copied
What are you trying to flatten, exactly?
Copy link to clipboard
Copied
The entire PDF, which is mostly text -- there are no illustrations, but for its cover and some ornemental chapter heads.
My hope is to make it difficult to copy the text (by dragging the mouse over its text and copying it), while retaining its many links, which really help people navigate the book/PDF.
Copy link to clipboard
Copied
I thought so. This is not what the flattenPages command does. You can protect the file using an encryption policy, but be aware there are plenty of ways around it.
Copy link to clipboard
Copied
Thank you for clarifying what "Flatten" does. And yes, although these techniques can't stop anyone from getting to the text, they may discorage some people.
Two comments:
+ There is still that single page at the beginning of the document that becomes "flattened", in the way that I hoped the whole text would. So, it's confusing. I guess there's no solution really.
+ I did "secure" the file with a password protected encryption, but the text could still be easily copy-pasted (as easily as without an encryption). And Acrobat doesn't seem to offer the possibility of encrypting the text in a way that would make the text un-copiable. So ... frustrating.
Thanks for your time.
Copy link to clipboard
Copied
- The command you used should not have any effect at all on the ability to copy the text, so there must be something else at play here. If you could share the file (both the original and the "flattened" version), even if only some pages from it, that would be helpful.
- You must make sure the check-box next to "Enable copying of text, images and other content" is NOT ticked when applying the policy:
Copy link to clipboard
Copied
Edited -
**Never Mind** I see that it is not fields you are interested in flattening.
odd behavior. Can you post the document, or at least a portion of the document?
Have you checked the "display" property on the fields on the other pages?
This is the property that is controlling the flattening.
Copy link to clipboard
Copied
Thanks for your help.
Here's a portion of the PDF: https://e.pcloud.link/publink/show?code=XZuuvMZFCCAnpfTqXbwKXq3UIaRXyzLCc87
The only links that work are external links, as they lead to external webpages -- of course, the internal links don't work because I've removed all the text that comes after the table of contents. You'll also note that the text is easily copyable by dragging one's mouse over it and copy-pasting it -- this behavior is easily noticeable on the last two pages of the PDF portion.
So, once again, I'd like the text to *not* be copyable by mouse (which is what I call "flattened"), while retaining functional links (external and internal).
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you.
1) Could you descrive the method you used to produced your tests? Did you use the "Password Security setting" method you describe in one of your previous posts?
2) See attached GIF: this is the behavior (copy and paste text) I'm trying to stop from happening -- the GIF shows text from the file you just exported.
Copy link to clipboard
Copied
And here's the behavior I'm looking for and that I somehow achieved yesterday, but on only one page (see GIF below):
Although I attempt to drag my mouth over the text to select it, I get nothing. The text is unselectable. My cursor turns into a hand icon and I can only move the page up and down. And all the while, the hyperlink is still valid and active.
This is what I'd like to achieve for the entire document.
Copy link to clipboard
Copied
Your video can't be from an Adobe application. You probably used a third-party application that does not respect the security policy.
The way to achieve what you described is to outline the text, which basically converts it into an image. There's a built-in command in the Preflight tool that allows you to do that. Attached is the result.
This is considered very inconsiderate for the user, though, as it completely disables the option to search the file, for example.
Copy link to clipboard
Copied
Ah ! Yes. This is it. It works.
Thank you very much. This is exactly what I was looking to achieve.
... and I'm not going to do it, because my readers wouldn't be able to search the document, which I had no idea would happen. It would also be inconsiderate, as you note yourself, and would defeat the purpose of the entire document to begin with. So ... not gonna happen.
Thank you very much for your generous time, and patience with my confusing questions. I'll keep this technique in mind for future PDF adventures.
Copy link to clipboard
Copied
I think that's the right call, and you're welcome!