使用普通的C / C添加注释到PDF ++ [英] Add annotation to PDF using plain C/C++

查看:185
本文介绍了使用普通的C / C添加注释到PDF ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一种方式来注释添加到PDF,只使用普通的C / C ++(没有第三方库)。

I am looking for a way to add a note to a PDF, only using plain C/C++ (without a third party library).

我怎样才能得到这样的结果?

How can I get this result?

推荐答案

下面是的 PDF文档参考第三版

PDF文件是由不同的二进制对象组成的,这可以是COM pressed,连接codeD或使用不同的算法进行加密,COM pression方案(有损和无损)和编码器。每个对象在参考表中引用与它的文件中的位置信息。
你需要知道如何处理这个表,就需要实现所有可能的COM pression方案,编码器和加密算法,然后你将不得不处理PDF对象的所有可能的结构。

PDF files are composed by different binary objects, that can be compressed, encoded or encrypted using different algorithms, compression schemes (lossy and lossless) and encoding filters. Each object is referenced in a reference table with information on its position in the file. You will need to know how to deal with this table, you will need to implement all possible compression schemes, encodings filters and encryption algorithms, and then you will have to deal with all possible structures of PDF objects.

在的PDF说明书中,这些对象被称为字典,并且它们由条目组成。每个条目都有一个类型可以是一个简单的类型,或其他词典(或对它的引用),或一种以上这些元素类型的阵列。因此,我们可以说,一个PDF基本上是字典对象的树。

In the PDF specification, these objects are called dictionaries, and they are composed by entries. Each entry has a type that can be either a simple type, or another dictionary (or a reference to it), or an array of one more of these element types. So we can say that a PDF is basically a tree of dictionary objects.

一旦你的code是能够处理与规范中每一个可能的解释,并与树状结构,你可以去的第八章 - 互动功能的规范的,部分的 8.4 - 注释的,并实施加注释词典到PDF文件的方式

Once your code is able to deal with every possible dictionary in the specification, and with the tree structure, you can go to Chapter 8 - Interactive features of the specification, part 8.4 - Annotations, and implement a way of adding annotation dictionaries to a PDF file.

您应该注意到,我连提PDF文件的热点话题,如字体,色彩空间,投影胶片和画一个页面中的说明。我assumming,你将能够再次加载的所有对象在文件中,创建一个注释对象,以某种方式将其插入您的对象树,并保存所有对象,因为它们。这或多或少 iText的是如何工作的,所以如果你真的想实​​现这一点,你可以采取源一看iText的的code所以你可以有工作量的一个小窗口,这种项目的要求。

You should notice that I am not even mentioning hot topics of PDF files such as Fonts, color spaces, transparencies, and drawing instructions inside a page. I am assumming you will be able to load all objects in a file, create an annotation object, insert it somehow on your objects tree, and save all objects again "as they are". This is more or less how iText works, so if you really want to implement this, you can take a look on the source code of iText so you can have a small window of the amount of work that this kind of project requires.

您可能还需要看一看这个答案的SO

这篇关于使用普通的C / C添加注释到PDF ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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