我想创建一个像iTextSharp这样的PDF Writer,而不要使用iTextSharp-从头开始创建PDF [英] I want to create a PDF Writer like iTextSharp not use iTextSharp - Creating PDFs from scratch

查看:159
本文介绍了我想创建一个像iTextSharp这样的PDF Writer,而不要使用iTextSharp-从头开始创建PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是有关PDF的不同要求.我不想使用第三方库来创建PDF,我想创建像iTextSharp这样的PDF编写器,以便从任何数据源创建PDF.本质上,我想创建自己的OWN PDF工具.

This is a little bit of a different request regarding PDFs. I don't want to use a 3rd party library to create PDFs I want to create a PDF writer like iTextSharp in order to create PDFs from any data source. In essence I want to create my OWN PDF Tools.

这不是将现有文档转换为PDF的要求(我已经知道如何使用interop这个词来做到这一点,并且我对iTextSharp很有经验).

This is not a requirement to convert existing documents to PDF (I already know how to use the word interop to do that and I have experience with iTextSharp).

我真正努力寻找信息的是如何从头开始创建PDF?在搜索中几乎找不到关于创建PDF需要做什么的信息.

What I am really struggling to find information on is how would I create PDFs from scratch ? There is very little to no information that I can find in my searches on what you need to do in order to create a PDF.

我已经阅读了PDF标准: https://www.adobe.com/内容/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf

I have read through the PDF standards: https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf

我了解所有PDF都必须遵守的格式要求,才能与Acrobat和FoxPDF等PDF阅读器一起使用,但是这些标准显然与技术无关,并且仅作为指导.

I understand the formatting requirements that all PDFs need to adhere to in order to work with PDF readers like Acrobat and FoxPDF but the standards are obviously technology independent and only work as a guide line.

所以我想问的是有关启动此项目的一些指导.我正在专门寻找与C#(.NET或Mondo)有关的教程,甚至只是几行内容,即可向我指出正确的方向.

So what I am asking I guess is for a little bit of guidance on starting this project. I am specifically looking for tutorials that pertain to C# (.NET or Mondo) or even just a few lines to point me in the right direction.

亲切的问候, 赫尔格德·瓦格纳

Kind regards, Helgard Wagener

推荐答案

您可能没有找到有关从头开始创建自己的PDF编写器的大量信息的原因之一是因为大多数软件开发人员通过经验认识到,通常情况下更好[em] 到重新发明轮子. (尽管我知道有时候在某些情况下您别无选择.)

One reason you probably haven't found much information on creating your own PDF writer from scratch is because most software developers realize through experience it's usually better not to reinvent the wheel. (Though I recognize that sometimes there are circumstances where you have no choice.)

从技术上讲,该规范为您提供了创建PDF所需的信息,大多数PDF阅读器都应可以阅读该信息.例如,您需要编写标题,对象主体,交叉引用表和预告片,以构成基本的PDF.

Technically the specification gives you the information you need to create a PDF that should be readable by most any PDF reader. You'd need to write the header, the body of objects, a cross-reference table, and a trailer for example to make up a basic PDF.

不过,让我告诫您,PDF文件可能会变得非常复杂,而编写与世界其他地方兼容的PDF可能会遇到同样复杂的问题.

However let me caution you, a PDF file can become enormously complicated and the problems that can occur in writing PDFs that play nice with the rest of the world can be equally complicated.

从前到后像书一样阅读文件格式规范,但是对我来说,这没有帮助,当您有一点经验之后,它可以作为参考使用.您可以做的一件事是使用Acrobat这样的PDF编写器,并创建一个非常简单的PDF,其中包含"Hello World"文本,然后将其保存到磁盘中,然后在您喜欢的文件编辑器中对其进行检查,以了解其结构和查看规范中的概念在实践中如何看待,例如拖车,身体中的物体等.

Reading a file format specification from front to back like a book however is not in my experience helpful, it's more useful as a reference to use after you have a bit of experience. One thing you could do is to use a PDF writer like Acrobat and create a very simple PDF with say "Hello World" text in it and save it to disk and then examine it in your favorite file editor to have a look at the structure and see how the concepts from the specification look in practice, e.g. the trailer, objects in the body, etc.

然后,您可以开始考虑如何构建代码结构以构建简单的PDF,并逐步添加您感兴趣的功能.

Then you could start thinking about how to structure you code to build up a simple PDF and piece by piece add your features of interest.

如果这仅仅是一项学术活动,那么您的能力就更大.但是,如果这是一个工作项目,那么我要重申,您应该使用现有工具.请注意,PDF空间中有很多播放器,但是创建时并没有完全相同.

If this is simply an academic exercise more power to you. However if this is for a work project, I'd repeat my refrain from above that you should reach for an existing tool. But as a caveat, there are many players in the PDF space, but they aren't all created equal.

这篇关于我想创建一个像iTextSharp这样的PDF Writer,而不要使用iTextSharp-从头开始创建PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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