155 comments

[ 3.0 ms ] story [ 221 ms ] thread
This was a fun read! Thank you
I second that comment! That was the most enjoyably nerdy thing I’ve read in quite a while.
I cannot let this opportunity go by without quoting On Exactitude in Science by Borges in its entirety

". . . In that Empire, the Art of Cartography attained such Perfection that the map of a single Province occupied the entirety of a City, and the map of the Empire, the entirety of a Province. In time, those Unconscionable Maps no longer satisfied, and the Cartographers Guilds struck a Map of the Empire whose size was that of the Empire, and which coincided point for point with it. The following Generations, who were not so fond of the Study of Cartography as their Forebears had been, saw that that vast map was Useless, and not without some Pitilessness was it, that they delivered it up to the Inclemencies of Sun and Winters. In the Deserts of the West, still today, there are Tattered Ruins of that Map, inhabited by Animals and Beggars; in all the Land there is no other Relic of the Disciplines of Geography."

https://en.wikipedia.org/wiki/On_Exactitude_in_Science

(comment deleted)
Or a portion of one of it's inspirations: Lewis Carroll's Sylvie and Bruno Concluded

  "We actually made a map of the country, on the scale of a mile to the mile!"

  "Have you used it much?" I enquired.

  "It has never been spread out, yet," said Mein Herr: "the farmers objected: they said it would cover the whole country, and shut out the sunlight ! So we now use the country itself, as its own map, and I assure you it does nearly as well."
Also Carroll, from The Hunting of the Snark

    He had bought a large map representing the sea,

    Without the least vestige of land

    And the crew were much pleased when they found it to be

    A map they could all understand.


    “What’s the good of Mercator’s North Poles and Equators,Tropics, Zones, and Meridian Lines?”
    
    So the Bellman would cry

    and the crew would reply

    “They are merely conventional signs!


    “Other maps are such shapes, with their islands and capes!

    But we’ve got our brave Captain to thank

    (So the crew would protest) that he’s bought us the best

    A perfect and absolute blank!”
There are some funny lines from They Might Be Giants' "Women and Men" that run along the same lines:

Women and men have crossed the ocean,

They now begin to pour

Out from the boat and up the shore.

Two by two they enter the jungle,

And soon they number more,

Three by three as well as four by four.

Soon the stream of people gets wider,

Then it becomes a river,

River becomes an ocean,

Carrying ships that bear

Women and men.

**

Borges: map of an area gets so detailed it becomes the same size as the area.

TMBG: creatures multiply and ultimately overrun an area so fully that their group behavior recreates the ecology of the area they took over

About 30 years ago I interviewed to be a summer intern at Microsoft, and one of the interviewers asked a question very similar to this but regarding Excel. This is the kind of topic that never gets old for understanding a person’s curiosity and ability to dissect the potential issues.
Please, nobody tell Randall Munroe!

Because I would literally spend days worth of time scrolling.

While the Germany PDF actually scrolls pretty quickly at 100% zoom (makes one realize just how much text is read in a day), the Universe one is pretty fun, Firefox's PDF reader at 100% zoom obviously doesn't budge the scrollbar at all.
Hackaday soon: Synchronizing a treadmill to a pdf the size of Germany.

Obligatory?: The pdf is not the territory.

Fun experiment alexwlchan! Two small mistakes in your post: you write "15,000,000,000.00 in" and "that the size of a page is 15 billion inches", but it should be 15 million.

You said you had difficulty formatting text. Here is a "hello world" pdf that just has these two words on a page: copy and paste this text (stripping leading spaces on each line) and save it in a .pdf file. Basically in order to write text you have to define a font (object 5) and then a stream with a Tf command to use the font, a Td command to position the text, and a Tj command to write it.

    %PDF-1.2
    1 0 obj
    <<
     /Type /Catalog
     /Pages 2 0 R
    >>
    endobj
    2 0 obj
    <<
     /Type /Pages
     /Kids [ 3 0 R ]
     /Count 1
     /MediaBox
     [ 0 0 612 792 ]
    >>
    endobj
    3 0 obj
    <<
     /Type /Page
     /Parent 2 0 R
     /Resources 4 0 R
     /Contents 6 0 R
    >>
    endobj
    4 0 obj
    <<
     /ProcSet[/PDF/Text]
     /Font <<
      /F1 5 0 R
     >>
    >>
    endobj
    5 0 obj
    <<
     /Type /Font
     /Subtype /Type1
     /BaseFont /Times-Roman
    >>
    endobj
    6 0 obj
    <<
     /Length 52
    >>
    stream
    BT
    /F1 48 Tf
    185 400 Td
    (Hello World)Tj
    ET
    endstream
    endobj
    trailer
    <<
     /Root 1 0 R
    >>
Is the xref at the end of a PDF required or not? Seems like it is in the spec.
It is required according to the standard. But in practice most PDF viewers don't care. They may complain the PDF is "damaged" or "no valid xref was found", but they will render it perfectly fine.
By the spec, yes. Some PDF readers will parse it anyway, some will not. In my experience depending on the renderer the xref table can be varying degrees of malformed before things go wrong. Edge's old PDF reader (the one before Acrobat and after PDFium) for example seemed to tolerate just about anything, falling back to the latest version of objects if the xref table was broken. There's also other mistakes you can make, like for example, the xref table requires carriage returns (each entry in the table is supposed to be an exact number of bytes) but some PDF readers will still interpret the xref table even if the carriage returns are missing.
As I understand it, the xref entries don’t require a carriage return, but they require a fixed line length. If you don’t want to use a CR, you can pad with a space.

So CR/LF, space/LF, and space/CR are all valid endings.

Yep:[1]

> The byte offset in the decoded stream shall be a 10-digit number, padded with leading zeros if necessary, giving the number of bytes from the beginning of the file to the beginning of the object. It shall be separated from the generation number by a single SPACE. The generation number shall be a 5-digit number, also padded with leading zeros if necessary. Following the generation number shall be a single SPACE, the keyword n, and a 2-character end-of-line sequence consisting of one of the following: SP CR, SP LF, or CR LF. Thus, the overall length of the entry shall always be exactly 20 bytes

This is interesting. Never actually saw anything other than CRLF in practice, even inside of PDF files that otherwise were LF-only.

[1]: https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandard... page 41

> "15,000,000,000.00 in" and "that the size of a page is 15 billion inches", but it should be 15 million.

Can you help me count zeroes? Why is it million and not billion?

The numerical and word versions are equal, but they're both wrong. 15 billion inches is to the distance from the Earth to the Moon.
>If we crank it all the way up to the maximum of UserUnit 75000, Acrobat now reports the size of our page as 15,000,000,000.00 x 15,000,000,000.00 in – 381 km along both sides, matching the original claim. If you’re curious, you can download the PDF.

15 billion inches are 381,000km. The original claim is the limit is 15 million inches.

He put too many zeroes. It should be "15,000,000.00 in" or 15 million.
Argh! I knew I was going to make a numerical mistake somewhere, thanks for spotting it. Correction will be up shortly. Thanks for spotting it! :D

And thanks for the text example! This looks like what I was trying, but clearly I had a mistake somewhere.

Spotted another math mistake: > The default unit size is 1/72 inch, so the page is 300 × 72 = 4.17 inches.
> Please don’t try to print it.

How will I know if I can fold it more than 7 times, though?

For a moment I wasn't sure if I wanted to click on the link.
It also screams buffer overflow.
PDF readers are probably mostly pretty hardened against "naive" non-conforming content.
> probably mostly pretty hardened

Quite possibly perhaps that might be true-ish to some extent, I think, but take that with a grain of salt, I'm not an expert, that's just my wild guess :-p

It's pretty ridiculous to peel that off the following qualifier.

Readers have been aggressively attacked for a long time. It's certainly not impossible that some basic demonstration PDF will cause an issue, but it's probably not reasonable to expect it.

On an only slightly related note: is there any good way to check PDFs for malware/executables?

If I'm stuck with an attempt at it, the best I can think of is opening in a new QEMU or docker with no Internet access, but that's 1) a fair but of work to check something, and 2) probably not even that secure. Using some cli tool, like xxx, bat, or ranger, that does some processing to extract the text and looking at just that feels more secure - but I know it really isn't.

What is a simple tool to "clean" PDFs? An ML tool that does QEMU/docker/no-net to extract the content, turns that into game, and saves a typst/latex template with it would probably be the best possible outcome - but that's a decent (yet potentially very lucrative) task.

What you mean with "PDFs with malware/executables"?

If you're talking about embedded active content within them, then a reader application can just ignore/not run it.

If you're talking about a crafted PDF that exploits, let's say, font rendering bugs inside the reader than it's near impossible. Keep your applications updated.

There are some pdf readers that protect you against those things.

On Android, for example, there is the GrapheneOS Pdf Viewer [1]. It's readme has a pretty good explanation of how it works.

1: https://github.com/GrapheneOS/PdfViewer

It seems germane at this point to paraphrase Steven Wright.

“I have a map of the United States. It’s actual size. “

I have a map of the Universe. Dunno, it keeps expanding ...........................................,............................................................................................................................
I have the map of US in my cell-phone.

I'm somewhat confused by its directions however when I look at the map and want to go somewhere. Is the top-part of the map where I'm moving? Or is the top-part North?

Seems it is not North and that is confusing because maps I've seen before have North at the top always.

If I turn 90 degrees, the map turns around. But I thought it was I who turned around.

And if I stop, the map cannot know where I'm going because I'm not going anywhere. So it is almost like I have to start moving before the map can tell me where to turn.

Or if I hold the smart-phone in front of my eyes the top of the map is towards the sky. Am I supposed to look at the map from above?

What are some good tactics on how to use Google-map on your cell-phone?

I really hate that too. You are in a intersection and the voice says "Drive north for x miles/km". What is wrong with "turn right and drive for x miles/km"? I normally have zero clue in what direction north is especially when I am in a location i have never been before. I drive a bike and have the phone in my pocket and can therefore not see any arrow that the app might display. I only have the audio to navigate from.
That’s Google maps for you. Try another one, most have way better voice cues (amongst other things!).
That's odd. My Google Maps tells me to turn left or right. It doesn't use compass directions.
It will do that if it doesn't already know what direction you're travelling, which is usually because you've just activated navigation and you aren't moving yet. Unless I happen to know which direction north is or which way to towards my destination I'll just pick a random direction and it will adjust the route if I guessed wrong.
> You are in a intersection and the voice says "Drive north for x miles/km".

Does that really happen? I have never experienced it. How do they tell which way is north?

Highway 101 runs through San Jose pretty much due east/west, but because it also runs up to San Francisco, it is officially a north-south highway. So you check your position on the map and you're traveling due east along an east/west road. Is that "north"? (Of course not. It's "south".)

If you want North to be up, tap the compass icon.
> What are some good tactics on how to use Google-map on your cell-phone?

For navigation?

1. Don't activate navigation. It's broken six ways to Sunday, and burns through battery like there's no tomorrow. Use route preview instead (i.e. the step after searching, but before activating the voice nav proper).

2. Use your fingers to rotate the map so it always faces the same way you're going.

3. If confused, recenter and press the compass so it rotates to have North at the top, and continue from there.

Now FWIW, I use Google Maps when navigating on foot/scooter, or as a pilot in the car. If I were a driver... I'd probably buy TomTom or whatever nav that's not shit.

There are two modes in Google Maps - one shows the map in a fixed rotation (north on top by default, but you can rotate the map with two fingers), the other mode automatically rotates the map based on what direction you're facing. *Facing*, not moving, so you don't actually have to walk for it to determine the direction.

You can switch between the modes by clicking a compass icon

Part of the confusion might be that it's pointing in the direction the phone is facing. Which is kind of obvious, but notably doesn't work if you put your phone in an upright phone holder, as many people do in their car.
> pointing in the direction the phone is facing

Do you mean where the top edge of the phone is directed towards when I hold the phone so that its display is pointing towards the sky?

Or where the backside of the phone is directed at if I hold it upright in front of my face?

You know you're reading a good technical article when it measures pdf width in kilometers
microSD cards can contain millions of miles in a very small space...
or billions of feet
A truly unfathomable quantity of toes on a single SD card!
Slightly tangential: if you are hacking on PDFs, manually or otherwise, this is an incredibly useful tool: https://pdfcpu.io/ (not the author, just a user)
Thanks for this. Any other tools that are useful when hacking on PDFs? I need to do a lot of programmatic PDF manipulation at work.
“But unlike Acrobat, the Preview app doesn’t have an upper limit on what we can put in MediaBox. It’s perfectly happy for me to write a width which is a 1 followed by twelve 0s:

Screenshot of Preview’s Document inspector, showing the page size of 352777777777.78 x 10.59 cm. If you’re curious, that width is approximately the distance between the Earth and the Moon. I’d have to get my ruler to check, but I’m pretty sure that’s larger than Germany.”

The size of every planet in our solar system, put next to each other, can fit in this doc with room to spare

Now I wonder how large of a file size would such a PDF be if it wasn't empty space...
pdf supports vector graphics! or it can be just a lot of "a" characters, it supports compression/repeat, right?
You have one 7 too many. 352777777777.78cm are 3,527,777.7777778km.
By my counting, that document is ~ 373 km^2, which is much smaller than germany. It turns out the ruler was needed after all
>Please don’t try to print it.

Sounds like a print bomb waiting to happen. Last time I had a printer it was next to impossible to cancel a print job on Windows. Back when people had wifi printers that were open or ill-secured, those were fun times.

> it was next to impossible to cancel a print job on Windows

It's still impossible. The only reliable method I've found consists of turning the printer off and then deleting the print job in the queue. Only way to get Windows to actually delete it. Doesn't work unless the printer is sitting right next to me, of course. I have no idea why this is so hard.

And sometimes windows won't delete it from the print queue as it can't talk to the printer. Fun times.
Some ~12 years ago, I was debugging POS integration with a receipt printer and accidentally sent garbage postscript to the receipt printer, which printed it out verbatim.

Stopping it was impossible. Power cycling that printer had absolutely no effect. It wrote the unfinished print job to some kind of persistent memory, and by god it was going to finish it.

It went through something like 2 1/2 rolls of receipt paper (yes it dutifully awaited the new rolls and then just continued) and due to the thermal printing process it smelled very odd, and I had quite a few metres of raw Postscript afterwards to decorate a wall with.

Only slightly more reliable method: unplug the printer and throw the computer out the window.
when i read

> Please don’t try to print it.

my first reaction has been: you are not my mom. >:-)

Just click “scale to fit on one page”.
I take offense to that diagram; Germany should refuse to be covered by a PDF that's not in proper DIN format.

In theory, DIN paper sizes go all the way from subatomic to the size of the universe. It seems like A(-39) is barely too small to cover Germany's land mass, but A(-40) should be more than sufficient. That's 882 x 1247 km if I didn't miscalculate.

Oh here we go again.
That's actually quite funny, especially because Germany almost has portrait DIN format.
:) I think maybe the joke was a hair too subtle for this crowd.
(comment deleted)
Reminds me of this PDF I created more than a decade ago from a Postscript implementation of the game of life. Seems it still works, but causes MacOS preview to crash. https://andrewcutler.net/docs/joke/life.pdf
Whew! Didn't crash on my Mac OS — just a static Game of Life render. This machine is still on Monterey FWIW.
It doesn't cause Preview to crash on Sonoma. FWIW, I can't see any animation, just the final state, while Firefox's PDF reader does show some animation. Skim has the same behaviour as Preview but doesn't show the grid.
Chrome's PDF reader reports the file size as disappointly 200.00 × 200.00 in (square)
And of course you can try and produce this pdf using TeX. In this post https://tex.stackexchange.com/a/27482/963 I created a pdf of 15283 pages (lettersize) filled with lorem ipsum text and without the program running out of memory.
I open the PDF in Google Chrome on a Mac. When I Ctrl+P, the dialog says it's 1 Page. I don't try to print it, but I think it will not consume more than 1 page?

Also, PDF preview in Chrome simply showing it like a normal PDF, but Preview seems confused (gray background instead of white)?

> I don't try to print it

Well, you can even without consuming a single sheet: just print to PDF.

> Preview seems confused (gray background instead of white)?

It tries to render it and fit in the preview.

I'll analyze PNG for comparison. The largest width and height is 2147483647 (2^31 - 1). Using the pHYs chunk (physical pixel dimensions), the lowest density we can specify is 1 pixel per metre. So, 2 billion metres (2 gigametres) is somewhat bigger than the diameter of the sun at 1.39 Gm. https://en.wikipedia.org/wiki/Orders_of_magnitude_(length)#g...

Using the sCAL chunk (physical scale) would allow extremely large dimensions because it uses ASCII floating-point.

> Using the sCAL chunk (physical scale) would allow extremely large dimensions because it uses ASCII floating-point.

AFAIK sCAL is more about the image's subject, not the image itself. A 1:10,000,000 scale world map would be < 10 m wide according to pHYs, but it will be ~40,000 km wide according to sCAL.

So I guess the question is, how did she figure out the size of the entire universe?
[flagged]
was? More like is. They're overlooking one right now, because of the last one they did.