如何使用Java创建pdf文件而不使用任何外部库? [英] How to create pdf file using Java without using any external libraries?

查看:239
本文介绍了如何使用Java创建pdf文件而不使用任何外部库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在不使用第三方库的情况下创建PDF文件,如iText,Apache PDFBox,PDFJet等?

Is there a way to create a PDF file without using a third-party library, like iText, Apache PDFBox, PDFJet and so on ?

推荐答案

如果您确实想这样做,请下载 PDF规范<的副本/ a>,并阅读它。 (它只有978页......阅读时间不会那么长......)然后设计并实现一个程序,该程序生成符合指定格式的字节流,并包含您想要输出的信息布局,等等。

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.

您可能会在一周或三周内生成一个简单的hello world文档。但是你需要(以及许多版本)才能达到现有库之一的复杂程度。

You could probably produce a simple "hello world" document in a week or three. But 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.

这篇关于如何使用Java创建pdf文件而不使用任何外部库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆