Is there a way to create a PDF file without using a third-party library, like iText, Apache PDFBox, PDFJet and so on ?
Asked
Active
Viewed 3,544 times
-4
-
4That is not simple, that's why there are libraries for this. PDF is not a simple format like a text file. If you really want to do this, you'll have to study what the PDF format looks like and implement it in your code. It will not be easy. – Jesper Sep 11 '13 at 11:33
-
Sure, go to freelancer.com or similar and pay someone to do your work for you. They'll charge a reasonable price. This is a huge undertaking though so expect several hundred US dollars minimum. The point of SO is to post what particular issue you have with your code, not do a very complex project for you. Here I'll start you off: public static void main(String[] args) { You're on your way now! – RossC Sep 11 '13 at 11:37
-
1@RossC - Several tens thousands of dollars would be more appropriate if he is going to create a PDF without using external libraries. – Stephen C Sep 11 '13 at 11:40
-
All above comments very well explain necessity of PDF generating libraries. But In case you are asking this question only out of curiosity & understanding like me then you can check this article that I created purely out of curiosity. But for professional work please prefer libraries. http://itsallbinary.com/2018/12/07/generate-pdf-in-java-from-scratch-without-any-library/ – Ravi K Dec 07 '18 at 07:59
1 Answers
10
If you really want to do this, download a copy of the PDF specification, and read it. (It is only 978 pages ... it won't take that long to read ...) Then design and implement a program that generates a byte stream that conforms to the specified format and contains the information you want to output with a suitable layout, etcetera.
You could probably produce a simple "hello world" document in a week or three. But my estimate is that it would take you years (and many versions) to get to the level of sophistication of one of the existing libraries.
A better idea is to not waste your time reinventing the wheel.

Stephen C
- 698,415
- 94
- 811
- 1,216