PDF Workflow - Computerphile
ฝัง
- เผยแพร่เมื่อ 21 ส.ค. 2024
- To Conclude Professor Brailsford's series on PDF he discusses how PDFs are created.
PDF, what is it for? : • PDF, What is it FOR? -...
Programming in Post Script: • Programming in PostScr...
Unrolling the Loops: • Unrolling the Loops - ...
Google Deep Dream: • Deep Dream (Google) - ...
FPS & Digital Video: • FPS & Digital Video - ...
Password Cracking: • Password Cracking - Co...
/ computerphile
/ computer_phile
This video was filmed and edited by Sean Riley.
Computer Science at the University of Nottingham: bit.ly/nottscom...
Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com
I could listen to this guy forever. He's like the David Attenborough of software
That is absolutely spot on!
+
Will the prof do a video on LaTeX maybe?
+
my thought exactly
that would be awesome indeed
Oh yes, please. That would be awesome!
+
I worked with pdf this summer, and I must say that pdf is a half brilliant, half horrible thing. It is brilliant in that everything uses it, but it is a 1700 page specification. Just let that sink in. If you want to produce something to render pdf properly, you have to read 1700 pages and then write something that handles every use case presented in them. Also it is a really weird half binary half text format that doesn't make it easy to do things that should be simple like extracting text.
Acrobat Reader is something of a security disaster, but it seems pretty competent in other ways. What other big problems does it have? Resource usage?
EebstertheGreat Do you need security in a pdf reader?
Tuupertunut Acrobat Reader is a famous vulnerability for web-based malware, much like Flash Player (though I would assume Flash is a far more common vector). A tremendous number of vulnerabilities in unpatched versions of Acrobat have been discovered that allow for arbitrary code execution by a file the reader attempts to open. By carefully crafting a file and giving it the extension .pdf, the attacker can ensure any computer instructed to open all .pdf files with Reader by default will get infected.
To be clear, it isn't one or two bugs, it is dozens of bugs which allow arbitrary code execution (the worst possible kind of vulnerability). Not many people really expect the current version to be safe, since every month or so another vulnerability is discovered.
But I don't want to sound too fatalistic. Even if this hole is plugged, there are many others (including he aforementioned Flash Player). There are other dimensions you can judge a program on. I want to know if Acrobat ranks high on those.
pdf.js provides safe PDF display without relying on any external binary plugins. There are other commercial JavaScript-based PDF viewers as well. Acrobat and Reader should disable the automatic launching of Flash embedded inside PDFs. Now with PDF 2.0, Adobe may choose not to implement the full PDF standard anymore. Actually, Acrobat has never followed the specs with 100% accuracy. There are known differences between the open PDF and Adobe's interpretation of it.
I was going to read that whole specification. I read the last page and it sort of ruined it for me.
Hi, Brady. I don't usually leave comments on TH-cam, but this time I could not prevent it. Thank you for the video! This reminds me so much of the best times in college when professors would tell their tech related stories. Indeed, a heart warming break for my afternoon.
I'd love to hear Professor Brailsford's thoughts on how various OSs render fonts.
Please do this!
Top, TOP class gentleman, "Explainer in chief" - this guy tells a story so clearly and thoroughly but without piffle and waffling. Thank you.
"I put a 700GB satellite image into a lossless Powerpoint presentation, but when I 'printed' it in a low res 300dpi A4 format, it was only 10mb..." Um, yeah, misleading much?
That is actually not at all what he said.
if you converted a 700 GB image into a pdf format and so lossless, it would not be bound by size not unless you specifically chose a lossy compression to a specific size, just as he explained. it would be the same image that could be scaled up and down to how you wanted to print it of course when large than the pixel density supports it would show.
The point is the pdf version would still compress everything else lossless, and it would even still be smaller than a BMP image, just because of compression, just like .zip and .rar.
You may wanna watch both videos again, because the point flew miles over your head.
He compared the "print" function. Which outputs at a specific DPI IIRC. So yes, it can save around half the space when *converting* to PDF. But when printing, it in no way losslessly compresses the file into a 10mb PDF. (Though again, Apples and Oranges as PDF looses the layer information, Powerpoint would allow you to go back in and remove/move images without loosing data with cropping or layer ordering)
It's not misleading if you understand what he's trying to say. The lossy compression he's talking about is practically no different then the lossless in most cases. After all it's mostly just text.
A bmp for example will be very huge: 3 bytes per pixel, no matter what the content is, basically x * y * 3 + some more. Lossless compression can shrink some image alot, like if all the pixels are the same color, it can say "this color times x pixels" instead of defining each pixels individually. Then, you can also use the fact that the pixel neighbour is usually not much different in color, so you can skip some bits and say "last pixel color plus X", where x take less space than a full pixel... You can also find some blocks that repeat and so on.
Take that zip bomb for example, it's a 42 kbytes .zip files that would take 4.3petabytes (that's 43000 terabytes). It does so by finding the redundant blocks. (ok, that one is cheating, it has been manually crafted, but would have been the same if you were to actually do it for real with that special files)
Can you do a video about LaTeX
I don't know, that sounds like a bit of a stretch.
html/css does have DPI support. In fact, the px unit is not a pixel, but is instead adjusted based on the screen's DPI.
You need to do a video on PostScript. I have no clue what it is and I'm sure I'm not the only one.
He has done one. Search for computerphile programming in postscript.
Awesome, thank you for making these videos and sharing your knowledge!
I maintain my resume in PDF. It has a makefile. TeX -> DVI -> PostScript -> PDF
Do you enclose the source code to the resume at the end of it? And, if so, does it work recursively on itself? :-)
Why the PostScript step?
Because I first did my resume in TeX before PDFTeX existed and haven't bothered to update the workflow.
I too maintain my resume in LaTeX. Markdown won't cut it unless you want ugly HTML all over.
so how about svg can that draw a one inch line?
It amazes me that some people don't like PDF and will still ask for a .doc
I honestly think those people shouldn't be allowed to ever touch a computer or work in administration
If they were content with an .odt file, I could understand it, but .doc is beyond the capabilities of my computer system (especially the new .docx format). I would flat out refuse to send files in this format, just because.
***** Yeah, well, in the non-Microsoft world, it's still kind of annoying though.
+Navaron The ISO standard for what?
I wouldn't be surprised if it was because offices don't allow acrobat to be installed due to the abominable security record and haven't bothered with an alternative viewer (even modern web browsers would do). The only other reason I know of is to allow editing, but the recent versions of Word will open a pdf and attempt to convert it to a word document for editing anyway.
Actually HTML can draw a line 1" long: {width: 1in;}. Anyway I agree on PDF as universal document representation. HTML was specifically design for screens. Not comparable.
Can we have a video on why it's so difficult converting a PDF file back to a Word file? Back when I was in IT at the NHS this problem came up when a department had Adobe Writer and was attempting to convert a PDF they had to Word. The formatting was always messed up in the conversion. Doing research if I remember right (was back in 2008-9) I roughly remember it was an issue with the formatting of the original PDF. Writer could only convert to what it had available on the PC the conversion was happening on. So if it was missing the original fonts etc, it would never be perfect.
I'd also be interested in hearing about the development of epub and where that technology is going.
Reflowing *almost* works on e-readers from Sony as old as 2006. Lack of automagic hyphenation rules is the caveat. Long nonbreaking words will overflow out of your page border. The rest of it works beautifully to change the size of text. Images OTOH, well, "it's a monochrome e-ink display: It's for *text*."
I like him :) He gets excited as he explains
MInor correction: LaserWriter was Apple’s brand name for a series of Apple laser printer models so “laser printer” is the proper generic name for that type of printer no other company made “LaserWriters” other then Apple.
There are free ways to 'print' to a PDF - Nitro PDF and Primo PDF. You can choose the 'quality levels' to save space, or preserve the images.
I would love to see Pr. Brailsford give us his opinion on LaTeX.
What do you think of a video about how product keys work? That would be really interesting
I'm pretty sure you can specify lengths in centimeters / inches in CSS now
Effective Pixel density (after compensation) and zoom on all levels aren't always fully known to the renderer.
That makes it hard to really have mixed documents (px and cm, for example)
It's not terrible, but it's not perfect (because it's not easy to have all the components working together and following the same guidelines)
PDF bedtime stories :D
As always, amazing to listen.
These two videos feel like the intro and outro to PDF without the informative and detailed bits this channel is known for. Was that really it?
ProfDaveB Thank you for the explanation. I am very much interested in PDF's nitty gritties, but couldn't really push myself to reading up on it. I'd love to have a more general knowledge on the format and whould be really happy if you whould do this :D
Yes, html can do a 1 inch line, with CSS.
Though he doesn't actually say it clearly, I *think* what he's saying is that the HTML *of the day*, as a potential competitor to PDF, could not do that. Also, the *principle* of what he's saying still applies. A PDF file describes *precise layout*, and no matter where you print it, all of the relative sizes will be the same. (You might need to scale it and "break" that "1 inch is 1 inch" rule to fit a large document onto small paper or what have you, but relative sizes and relative permissions will always be preserved.) HTML+CSS *can* be twisted to do that, sort-of, but it doesn't come easily or naturally, and idiomatic HTML by definition is about flowing content into a viewport whose size is not predetermined, with the exact results being different in different viewports. The bottom line is simply that PDF and HTML are solving different problems, and suggesting HTML as a solution to the typesetting problem is using a hammer to drive in a screw.
It's a bad example. HTML with CSS can do 1 inch lines. (Though you typically want to scale everything relative to text.)
But to place something relative to the bottom of the viewport, or right edge of the page, you need JavaScript.
I tried to get HTML to do A4 pages, defining the size of the viewport for screen and print media. It was consistently ignored. It is possible in SVG, but that's another story.
Sometimes I wonder why the web isn't done in DVI.
Well... with modern browsers, you can actually place things relative to the bottom or right edge. If you use "position: absolute" or "position: fixed", then you can specify "right: 1em" to anchor something 1em from the right, for example. What *is* still lacking is placing items *relative to other items*. It would be nice to be able to say, "This box should be stuck to the left edge of this DIV, wherever it is", and currently *that* definitely requires JavaScript in the general case.
Not really related, but I have some of those paper cups in my desk. Bought them on Amazon...
You got my attention. You're welcome
This man's career has quite a strange sort of coherence to it.
What about Ventura Publisher? In 1986 it could render and layout documents on screen and onto printers and image setters with excellent results, That was several years before Postscript made it to the desktop. Amazingly enough it's still a current Corel product!
The majority of the PDF files the average Web user encounters have no text in them, just images of photos, diagrams and text like a JPG. A company that has 10's of thousands of specification sheets doesn't bother to OCR and error check every one. They just set the source device to output as PDF as fast as possible.
?????
Well, yes, if CSS did not specify that actually, 1in = 96px... [edit: I wrote 'always', which is incorrect]
Replying to get emails when this is answered
Alfio Emanuele Fresta px are relative though. They are not defined as 'dot on some screen'. They could be 'two dots on a display' as is the case with most phone screens
Actually, the specification says that 1 pixel should be 1/96th of physical inch. So 1in = 96px comes from the fact that there should always be 96 pixels per inch on screen, given the pixel definition. How browsers define 1 css pixel is another matter though.
I think he meant that html alone without css cannot do that.
since it was SGML vs PDF, I still think PDF should have won. Faster, stored fonts, stored resources, extensible, vector for nearly everything.
Love your histories Professor !!
Did you ever use PSAlter, a fabulous bit of software that enabled you to write PS and debug it, single step, breakpoints etc etc, made life SO much easier when coding PS
Omg i love listening to his voice. Said it before on other videos of his, but this is ASMR to me :)
Or rather, this is a video that produces ASMR ha
Could you make a video about LaTeX?
The irony of all this, is that all the enormous effort undertaken to avoid using a simple bitmap to create a faithful representation of the original, was to save memory.
Ironic; because memory has now become cheap and abundant.
Nearly all the vectoring and font data can now be extracted from an image, therefore the enormous accomplishment of creating the PDF engine has been diminished somewhat.
Wow. Subscribed. Thank you for sharing your knowledge!
Question to add in a future PDF video: why does distiller need to have fonts available for embedding in the PDF and is there a way to avoid the problem and associated fail to distill the PS file when fonts can't be embedded? I still use the PS > distiller > PDF process, as Distiller came as a component of Adobe Framemaker.
professor, I used LaTeX (or MikTeX) a lot as a student, have you ever worked with that?
No mention of Display Postscript (which powered the NeXT).
I can't remember the last time I was in the under 300 club on a computerphile video
Amazing video!
HTML & CSS - I'm pretty sure if you assign " width:1in; " to a block element, it will be absolute just the same as PDF.
Or am I mistaken?
This issue if reflowing PDFs is particularly true on mobile devices with smaller screens when trying to read scanned ebooks. On a pc with a large screen the problem is not that acute.
What is the advantage of html over pdf,?
Please do a video on extracting text from pdf files..
The solution to this is called Prince, formerly known as PrinceXML. It lets you convert HTML plus CSS into super high quality PDFs.
Anyone else think the 50FPS is a bit odd? I swear I can tell the difference between this and 60fps
What about svg ?
9:05 "HTML can't do that"... fortunately, with CSS3, HTML now supports 'real' centimeters and millimeters!
Until your device uses resolutions or zoom and modification beyond the pixel ratio known to CSS3...
As long as the document is using a consistent unit system, everything stays at least the right size relative to each other. Unfortunately, I don't think I'll stumble across a web document using resolution dependent sizes that doesn't have px at all any time soon
We get a different story every year. One year it's em and the next it's rem and then it's back to px (since px is a relative unit despite being an 'object' on your screen), and the cycle repeats itself.
@Tatsh2DX, Alfio Emanuele Fransta says that CSS3 and HTML now support 'real' centimeters and millimeters and then you (Tatsh2DX) go on to talk about em and rem. Em and rem are relative unit, you wouldn't use them for absolute elements. CSS supports absolute units such as centimeters, millimeters, and inches.
Well, he's right though - CSS can't do that, in a device-independent way. See discussions elsewhere on this video's comment section for details.
Benny Löfgren kinda.right for the wrong reasons.
Here's something I don't understand. Why PDF if you've already got Postscript? What can PDF do that Postscript can't?
PDF files are generally smaller than the equivalent PostScript file, since the reduced operator subset gives more opportunity to abbreviate and pack things together. Another advantage is that PostScript can very easily contain malicious code, and that potential for malicious code is not possible to eliminate without removing some core PostScript functionality. PDF on the other hand has a much simpler execution model that prevents files from containing nontrivial payloads.
PS files are actual programs that need to be executed via an interpreter. It's not guaranteed that a PS program that contains loops actually finishes, and it's almost impossible to predict whether it's going to finish in a reasonable time or not. PDF can have tiny PS functions, but no loops whatsoever. If you ignore JavaScript, PDF is fully declarative, like HTML+CSS, so no interpreter or virtual machine is required, because there is nothing to execute. The introduction of JavaScript complicated this, but you can easily ignore it, and not execute anything. Furthermore, PDF Type0 fonts can only have one descendant, which significantly simplifies PostScript composite fonts (but fonts are still the most complex area).
Very useful reply. Many thanks. Yes -- and PostScript being a full programming language can read in a value from standard input and depending on this number deliver a multitude of different graphic effects. PDF can't do that. The data it needs cannot be read in at viewing time - it must already be bound in to the PDF so that the outcome is a single predictable graphic effect. In essence Acrobat is still "interpreting" the static data structure that is PDF.
ProfDaveB it's a joy watching your videos and learning from you. :-)
Is there a way to go from pdf (with math notation) to a text-based document (ie latex, .doc)?
pdf writer is damn good
get ya ruler out! :D
DjVu?
Shout out to PDFTK
PDFs can be reflowed if they are XFA based.
what's the Weissmann score on that pptx->pdf conversion? :D
I was hoping for a video showing how Word actually creates a PDF file.
Yeah... When ever we have customers send us PDF to edit directly, that's not a good sign.
But the "normal" case of working on a layout document (InDesign, Illustrator, etc) and only _exporting_ to PDF is completely fine by me.
You wouldn't complain about how you can't edit a flattened PNG after losing the PhotoShop layers, would you?
Fonts are still a problem with PDF readers that are not Acrobat...
Strangely, often only in print. When I open a DHL shipping label on my computer, it uses the Evince PDF reader (or some GUI front end that's based on that), everything looks fine. Then I go to print it, and for example the lines of the border are interrupted and start to continue a few mm to one side, so it looks just horrible. So the PDF engine that generates these files must do something wrong which, in combination with the post script printer driver then produces these errors.
dam... Didn't know PDF were that powerful every time I hear about Adobe the company has been just acquiring other companies and just leveraging (draining is more like it) to their own operations.
SVG will do almost the same as PDF and in some aspects even more
Alas, SVG doesn't compatibly support multiple pages! There are several extensions that do, but they're not compatible and most programs that do SVG don't support any of them. PDF really is the only option for print-ready end-user documents.
I don't quite get this. So Apple invented PDF in 1985 to make PS render fast, by removing loops and such, correct?
Then how on earth could PS become the de-facto standard by 1990 when the superior PDF had already been around (reducing, presumably, render times)?
I must be missing something. Or is there no correlation between the two, as in: nothing could really view PDFs (nor PS), but at least you could print PS?
+ThePixelize might be worth watching the linked previous video. PS came first, invented by Adobe. When they 'unrolled the loops' to allow Apple's demo to work better that gave them the idea for PDF.
he said PS in 1985 and PDF initial release in 1992/3
Thx!
Wait a sec.... HTML does support sizes in cm :P though the problem would be the display since hardly any display correct dpi setting :P
you can not just go around comparing pdf to html... it is like comparing elevators to washing machines... pdf is meant to display things on paper while html is meant to display things on screen
Yet you can display both on either.
Like putting things inside a washing machine to move them is similar to putting other things in elevators to move them too. ; )
Yes, but it's not unreasonable to want a unified model for "displaying things" on any sort of 2D output medium. The problem is that "static output" and "reflowable output" don't easily morph from one to the other.
look pops ..what is it that your trying to say ?
2nd
Does any one know how compiler are made and how long it takes to make one ?
just google it
what does your compiler compile?
Nowadays it's way easier, you can use the LLVM/Clang framework to make new language, together with parser, lexxer and compiler.
C and c++
Even if you targeted a very small subset of C, it would take you years to make a compiler from scratch. Try something simpler if your goal is to learn about compilers.
why is this called 'pdf workflow', not 'the story of pdf' or something?
I'm limited by the technology of my time
He's a linguistician.
♪PDF Writer....♪
[Warning PDF!] ... /joke
First
Nobody gives a flying f***. Watch the video and shut up!
Nilguiri I am.
Honestly, pdfs are the worst invention that we hzave ever made an industry standart. Everybody would have had it easier if Microsoft made a setting to lock and sign word files.
sooo... you just don't know the difference between saving a document and exporting it.
Is there a difference ?
Yes. Exporting loses information
I guess the terminology in your mind requires any "exportable" format to save less (if not different) information ?
You might have a specifc example in mind but in many cases the information is just presented differently or in a way more convenient for the user (or the next program in the chain) to manipulate.
Losing information is more a side effect of specific formats you want to save your document to rather than part of the definition of "exporting".
I should point out that as a data analyst, I hate PDF!
Who uses powerpoint to make pdf's , real men write the postscript by hand, and then idiots cannot modify you work :p.
pdf must die
Why? O.o
why
and please not before there's a format that could replace it perfectly
probably because it's a popriotary plugin
Paul: PDF isn't a plugin. It's an open standard for a file format, and you're free to implement it in any non-proprietary way you like. In fact, many browsers already have, for example.
just looked it up, confused it for adobe flash
sorry
never liked pdf
PDF is a terrible format. Documents should just be stored in XHTML with embedded resources.