Thursday, January 7, 2021

Just a test of PDF page number references in URLs

PDF

Apparently you can specify a page in a PDF in a link, so I'm going to try it. If you append #page=n where n is a 1-indexed page number, it's supposed to work. So we'll try it.

First, the link without a page specification:

Now the link with a page number. I'm guessing at the placement because there's already a ? query and an endpoint for viewing (the end of the link is "0B0KkM_vAe2HXVEcxMU8xR2Z6YWs/view?usp=sharing").

ETA: Nope, setting the link as "view#page=19?usp=sharing" doesn't work. What about inserting the '#page=19' after the specifier and before the /view endpoint?

Nope. None of them work with Google Drive and Chrome on a Mac. There might be a way to make them work for a very specific set of circumstances.

EDIT THE LATER

So I just whipped up a tiny HTML page using a PDF that happened to be on my computer, and it was able to link with page 4 without problems. So it's not the Macintosh or the Chrome that's the problem, it's how I formed the link to the PDF in Google Drive. I haven't read about the format of the URL for this sort of thing, so I assume it's possible (unless the URL-handling stuff strips that out of the URL) but I haven't figured it out.

Anyway, if your PDF is in a known location this will work, but there are a lot of cases where it's served to the user in a way that might mangle the URL and not present it properly. Probably worth knowing.

No comments:

Post a Comment