Just curious to know how can I generate a pdf file programmatically. I mean I know there are libraries in most of the programming languages to do so but I want to do it from scratch just like creating a text file. Open file.txt, write the data and close the file. But I guess, I can't do something like open a file.pdf, write data to it and then close the file. So How can I do it without any third party libraries.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (7)
Everything was fine till 'without any third party library'. Why the restriction?
I personally prefer using Pandoc.
"Pandoc is a free and open-source document converter, widely used as a writing tool and as a basis for publishing workflows."
Usage is as simple as that:
If you want to create a PDF file from scratch I'd recommend starting with reading the specification (tools.ietf.org/html/rfc7995 for example), learn how the format is structured and then you can write the code that generates that structure from arbitrary data
I thought about it but it is almost like a never ending manual and I hate reading manuals (of course because I don't get it๐ ๐ )
Reading RFC may seem daunting at first, but they're written in a very concise and clear way (since you shouldn't be able to misinterpret them).
Unless you find an article which breaks it down in simpler terms you're stuck reading RFC I'm afraid ;)
Unless you want to develop your own tool, then you could use LATEX (sharelatex.com/). Your code your own text and then save it into a .pdf format.
Our go to solution for that is wkhtmltopdf. You need to know HTML and CSS for that, but otherwise, it's pretty straightforward to use
I don't know without any library, but you can do with, # FPDF library for PDF document generation in Python.