7 ms·
Please don't turn nice formats into a format that's similar to screenshots of text. Pandoc has an option to pack all images and styles needed to render the page
by Aachen 1y ago
Please don't turn nice formats into a format that's similar to screenshots of text. Pandoc has an option to pack all images and styles needed to render the page into one html file:
pandoc --self-contained input.html -o output.html
- agedclock 1y agoPandoc would be my preferred tool. It is excellent at converting between other formats as well.
- TylerE 1y agoBeing (not so easily) edited is often a feature, not a bug.
- guywithahat 1y agoI was thinking this too, PDF's exist so people don't mess with the document. That said, it's still a clever feature, and pandoc can convert html into a pdf as well with a conversion engine. That said, I suspect it'll fail on anything sufficiently complex pandoc input.html -o output.pdf --pdf-engine=<your engine>
- ryandrake 1y agoIs this really that much of a motivation in 2025? Maybe in 2000 you could publish a PDF with the assurance that only the people who paid for Acrobat would be able to edit it, but today, there are a lot of accessible ways to edit PDFs, I don't think I'd choose PDF if I for whatever reason wanted to limit others from editing.
- craftkiller 1y agoIf that is your goal, you should be cryptographically signing your documents with your PGP key. That way you actually have assurance the document has not been modified rather than just hoping someone hasn't modified the document. Additionally, PGP can sign anything so you are open to use whatever format you want.
- Aachen 1y agoMay I recommend .html in that case? You can embed scripts that control who can run it, having it fetch a decryption token from a server or require a decryption password with a safe password hashing algorithm of your choice It's much more versatile than PDF and, if the algorithm decides the user is allowed to read the document, then the user gets to make use of all of the document's options like a better search function (PDF can't find words that are bro- ken across lines because that information of what's a word is gone, transformed into coordinates of what characters need to go where). It's also much more readable on different screen sizes, as the user can resize the window to whatever is comfortable on a 27" screen, or fits on their pocket e-reader. You can even draw it on a canvas if you want to prevent people from extracting the decrypted strings (though it's evil, you have that option). There's only benefits! PDF is the lazy way to half-ass a read-only document while screwing, ahem, making anyone using a mobile phone zoom, pan, and squint. Thankfully, phones are falling out of fash— wait, scratch that, I just heard text reflow is more relevant than ever as phone use continues to soar
- crazygringo 1y agoOr, please do? I use PDF's so I can send them to my iPad to read offline, highlight them, annotate them, and then send them back to my filesystem with highlights and annotations intact. I sure can't do that with any "nice formats" like HTML or TXT or EPUB or MOBI.
- mr_mitm 1y agoYou could, though. What you are describing are features of an editor, not a file format. I can imagine a browser addon performing the same tasks.
- deleted 1y ago[deleted]
- whenc 1y agoPDF annotations sit within the file.
- mr_mitm 1y agoI know, even though that depends on the editor. Okular for example places them in an extra file, last I checked. That's not unique to PDFs. HTML files are modifiable. There is nothing preventing an editor to put annotations in it as well.
- crazygringo 1y agoPDF is designed for annotations in the file format. You annotate in one editor, you can change the annotations in another. You can always distinguish between original content and annotations. I see no indication that Okular stores highlights or annotations in a separate file, that would be bizarre. There is no mechanism for annotations in HTML or the other formats I listed. An editor would just be editing the original content in its own non-standardized, non-portable way, which is not desirable for a number of reasons. So when you say: > What you are describing are features of an editor, not a file format. That is incorrect. It is an intentionally designed and standardized feature of the file format.
- moralestapia 1y agoPlease don't police what other people do.
- Aachen 1y agoIf I were police, I could still not enforce that this is what they run until it's law. They're free to choose this option if they like the merits
- layer8 1y agoHTML+CSS+media files isn’t a nice format, and much less portable through time and space than PDF.
- Aachen 1y agoNot sure if I'm misreading your comment, but it's not plural files with all those formats separately That's what the "self contained" option does: turn it into one nice file. Makes no difference if you copy example.pdf or example.html when both contain all images and styles (except one of them also contains the original semantic text)
- kelnos 1y ago> Please don't turn nice formats into a format that's similar to screenshots of text Converting HTML to PDF shouldn't result in an image wrapped in a PDF. Text will be preserved as text in the final PDF. (Unless the converter is garbage, of course.)
- Aachen 1y agoIf you've ever copied text out of a PDF, you'll know it's not the original text anymore. Besides ligatures, you get broken sentences with extra hyphens inserted in wrong places (that were word/line breaks in the PDF-rendered version), if it'll properly let you select more than a few words at all. It works like "put these couple words at position x,y" and not (html's) semantic "here comes a heading" tag that helps people accessibly read your text, and if you're not suffering from any impairment or mobile devices with narrower screens than this particular render was designed for, it also lets you work with the document more easily. It's like you remove all HTML and keep only the CSS: all definitions of what's a section, sentence, emphasis, or caption are gone I didn't mean literally an image, hence saying image-like. You get similar limitations to when using OCR, which seems very image-like to me
- jasode 1y agoFyi... the preferred new syntax since 2022 is: --embed-resources --standalone. https://github.com/rstudio/rmarkdown/issues/2382 https://github.com/rstudio/rmarkdown/issues/2382 https://pandoc.org/MANUAL.html#:~:text=Deprecated%20synonym%20for%20%2D%2Dembed%2Dresources%20%2D%2Dstandalone. https://pandoc.org/MANUAL.html#:~:text=Deprecated%20synonym%...
- Aachen 1y agoI noticed when trying it out for this comment, but then looked around when it was introduced and it seems recent (as in, an LTS distribution won't have it). Someone on stackoverflow said they get "unknown option --embed-resources". The old option will work for everyone and is also simpler, one instead of two parameters. People whose client supports the new option will see the upgrade suggestion when they run this. In the end I saw mainly downsides to mentioning the new rather than the old way
- craftkiller 1y agoI was excited to try this today, but this is unusable. It absolutely mangles the page. - It duplicated the headline, one in the correct place top-center but then a 2nd copy of the headline left-aligned below that. - It shrunk the width of the content of the page (in fact, it seems to have completely discarded the css for the #content selector) - It discarded the CSS for my code blocks, so now they are unreadable. - My images are no longer center-aligned - It added CSS that was not in the original document. For some reason, it addded hyphens: auto, overflow-wrap: break-word, text-rendering: optimizeLegibility, font-kerning: normal . None of those rules existed in the original document anywhere. Now my text is breaking mid-word with hyphens inserted. - It pointlessly HTML-escaped some characters (like every quotation mark in every paragraph). This didn't break anything, but just... why? Implementing the same functionality is like less than 100 lines of python, so I'm just going to go that route. I've implemented it once before, but it was for a previous company so I no longer have access to that code, but its like 1 afternoon of scripting and doesn't randomly destroy your documents. I don't know how pandoc got this so wrong. For context: the document I am attempting to process has no javascript. It is a simple Emacs Org document (similar to markdown) rendered to HTML and then processed with pandoc. The only external content was a couple of images.
- Aachen 1y agoHuh, that's a bummer! I only used it once myself to send colleagues draft versions of some markdown file that would later go on our blog, maybe it somehow helped that the source was markdown instead of html? Not sure, I'm sorry to hear of this disappointing experience :/
- craftkiller 1y ago> maybe it somehow helped that the source was markdown instead of html? That's probably it. Most of my issues were related to CSS, which markdown does not have[0]. The duplicated headline wasn't CSS though, that is by far the oddest issue. I'll probably file a bug report to pandoc after I replace all the text in this document with lorem ipsum (it is a document for work, so I can't share it publicly in its current form). [0] unless you embedded your own CSS since markdown technically allows arbitrary HTML