2

I have an Adobe PDF document which when opened displays a warning dialog with the words "the document is trying to connect to" followed by a certain URL.

I choose the "Block" option to try to be safe.

But I'd rather not have this dialog displayed at all, or for the PDF document itself to contain the URL. Connecting to the URL is unnecessary for the document to be useful - it's contents can still be read when "Block" is chosen.

I'm not looking for a solution that addresses the symptom - i.e. the dialog - so I'm not looking for a solution that simply says something like: "change security settings to block on default" or something like that.

The solution I am looking for is to simply remove the URL mentioned in the dialog, from the actual PDF document, so that the dialog never occurs.

My first attempt at this solution was to open the PDF in the Notepad++ text editor (any text editor would suffice, if it has search). Then I searched for the URL mentioned in the warning dialog.

Here is the snippet of the PDF code from the PDF document itself, showing the URL

PDF snippet

This only occured once in the document. So I experimented with removing various bits: just the URL to leave () and then the whole snippet.

In all experiments with removing the URL and associated code, the warning dialog disappeared but instead Adobe Reader reported:

"the file is damaged but is being repaired"

and the PDF file still loaded and was displayed.

But obviously I'm looking for a solution that removes the URL without causing this other dialog to occur. Presumably my manual edit disturbed the code somehow, maybe a checksum or a offset position value became inconsitent with the actual position of some code.

So, is there a utility to strip/filter/remove such embedded URLs in PDFs with the resultant document intact without errors?

(By the way, I had to show the code snippet as a image as the it would not get displayed completely due to the double angled equality brackets being interpreted as markup I guess. The URL given was an example to illustrate the problem and not the actual one seen.)

6 Answers 6

7

PDF file contains a table with file offsets at the end, and they go wrong if you remove the URL.

You can replace it with spaces, preserving the count of characters (preferably in hex editor), and it should work fine.

Overwrite the

/S/URI/(http://....afile.exe)
with spaces and leave the braces around intact, like this:
7210 0 obj
<<                                            >>
endobj xref
(it's the "object reference", you don't want to change it because the offset table would go wrong)

Or, you can look for a PDF editor, but I believe this would be overkill.

Please post your results :)

8
  • Would blanks really work? Wow.
    – jpaugh
    Jan 23, 2012 at 4:21
  • It's a text file format :) Also, you can remove the offset table altogether - and then the offending object, but I can't quite recall how do to it by hand correctly.
    – wizzard0
    Jan 23, 2012 at 4:23
  • Nice idea about replacing text +1 for that but I think it will complain about the URL being invalid or empty because the URL call command would still be in there. In fact as I mentioned I tried removing everything between the () and it did complain. Your suggestion for a PDF editor might be worth considering. PDF X-Change viewer might be an option, as a trial at least. Jan 23, 2012 at 9:21
  • I think the solution might be to replace the URL and its calling command with comment characters to the exact amount. Jan 23, 2012 at 9:21
  • 2
    @therobyouknow "URL call command would still be in there" - if you read my answer more carefully, you'll see that the URL call command will be removed too. I'll clarify this, thanks.
    – wizzard0
    Jan 23, 2012 at 12:02
4

To answer my own question, a colleague just suggested another solution would be to print the PDF to a file - the resultant output file being in the format of PDF. The process of printing might sanitise the contents and remove the URL call.

An example print to file PDF "virtual printer" is the very good free open source PDF forge http://www.pdfforge.org/ This installs like a printer driver and is available in the standard Windows choice of printers via the Control Panel and as a printer in the list offered by Windows Applications that print stuff - such as Adobe PDF Reader :)

I'll give it a go and let you know...

4
  • 1
    Sounds simple enough. If it does not screw up the formatting/image compression/fonts etc, then maybe the simplest method.
    – wizzard0
    Jan 23, 2012 at 13:59
  • +1 @wizzard0 thanks for your support. I'll feedback on my findings later... Jan 23, 2012 at 15:15
  • PDFForge/PDF Creator did not work with this doc (it has worked with other non-PDF docs for me very well I should say) - in this case the program hung. CutePDF was another option to try, same idea, "virtual" printer, so print-to-file, appears on printers list. This gave a "damaged" document. The best answer is to replace the URL call code (the URL and the PDF command to call it including the << >> with the exact amount of spaces). Jan 29, 2012 at 12:07
  • Opening in Adobe Reader, printing to "Microsoft Print to PDF" and selecting "Document" in "Comments & Forms" did the trick for me.
    – Konamiman
    Feb 23, 2017 at 16:48
3

Both PDF-XChange Viewer and PDF-XChange Editor by tracker-software are able to add and delete links in their respective free versions (not limited to private use). Just hit Tools >> Link Tools and boxes will highlight areas with embedded links. Of course this is not an option to discard hundreds of links in huge documents.

2

Well I can give you a little help. PDFs are in a binary format, and most binary formats use byte counting to separate records instead of newlines. In other words, you can't change the filesize without making all of the counts wrong. Whatever you replace that url with had better be the same size. If you were willing to invest some time in studying the file format, you could remove it, then adjust the appropriate "counts," but no guesses as to where those are. Or, you could learn another PDF command that was innocuous and could be coerced to the same size as any url.

Or you could find a PDF editor to do the magic for you. This sounds like the easiest to me.

7
  • 2
    PDF files are text (allowing embedding of binary streams and encryption, though), and they tolerate quite an amount of garbage. They even support comments, but I don't want to look thru entire 1000+ page spec as of now.
    – wizzard0
    Jan 23, 2012 at 4:24
  • That's so cool. And horrible.
    – jpaugh
    Jan 23, 2012 at 4:33
  • You can even create "patch" PDFs that add, edit or remove (!) places of original PDF when appended to end of the file (Designed for tape drives too, yay). This format is really horrible.
    – wizzard0
    Jan 23, 2012 at 4:39
  • +1 on your answer for your suggestion for a PDF editor: this might be worth considering. PDF X-Change viewer might be an option, as a trial at least. Jan 23, 2012 at 9:22
  • 1
    I think that's the way I'd do it. But, I'm the kind of person who's curiosity is piqued at the mention of a 1000 page spec.
    – jpaugh
    Jan 23, 2012 at 9:50
0

If you have Acrobat Pro 9 try:

  1. Open the PDF file in AP9 and block any net access attempts.

  2. Click File Menu / Properties / Security Tab / Enter 'Security Method' = [No Security] (if you can)

  3. Click Advanced Menu / Document Processing / Edit All Javascripts

  4. Check for the URL in the code box, then if it exists:

Remove the Javascript functions but not the XML tags.

In my case I removed the code between (and not including):

/* * * * * * * * * * * belongs to: Document-Actions:Document Open * * * * * * * * * * */

and the next

//< /ACRO_script>

Click [OK] then look for external hyperlinks in the document and use the link tool on the Advanced Editing Toolbar to highlight them, and the Del key to delete them (the text of the link will remain).

If this is not correct for you it should hopefully provide some clues.

0

In case someone is still looking for a solution in Linux:

pdftocairo -pdf file_with_links.pdf file_without_links.pdf

1
  • 1
    Welcome to Super User. For the benefit of Linux users who don't have this, can you expand the answer to explain what it is, what it does, and how/where to get it? Thanks.
    – fixer1234
    Aug 4, 2019 at 7:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .