将元数据添加到PDF [英] Adding metadata to PDF

查看:212
本文介绍了将元数据添加到PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将元数据添加到使用 prawn 创建的PDF中.稍后,可能会通过 pdf-reader 提取该元数据.该元数据将包含内部文档编号以及下游工具所需的其他信息.

I need to add metadata to a PDF which I am creating using prawn. That meta-data will be extracted later by, probably, pdf-reader. This metadata will contain internal document numbers and other information needed by downstream tools.

将元数据与PDF的每一页相关联会很方便. PDF规范声称我可以在页面片断字典"中存储每页的私有数据.第14.5条规定:

It would be convenient to associate meta-data with each page of the PDF. The PDF specification claims that I can store per-page private data in a "Page-Piece Dictionary". Section 14.5 states:

可以使用逐页词典(PDF 1.3)进行私人保存 符合产品数据.数据可以与页面或 通过页面中可选的PieceInfo条目形成XObject 对象(请参见表30)或表单字典(请参见表95).开始 在PDF 1.4中,私有数据也可能与PDF相关联 通过文档目录中的PieceInfo条目输入文档 (请参阅表28).

A page-piece dictionary (PDF 1.3) may be used to hold private conforming product data. The data may be associated with a page or form XObject by means of the optional PieceInfo entry in the page object (see Table 30) or form dictionary (see Table 95). Beginning with PDF 1.4, private data may also be associated with the PDF document by means of the PieceInfo entry in the document catalogue (see Table 28).

如何设置带有虾的分页字典"?我正在使用大虾0.12.0.

How can I set a "page-piece dictionary" with prawn? I'm using prawn 0.12.0.

如果这不可能,那么我又如何实现在页面级别或文档级别存储有关每个页面的元数据的目标?

If that's not possible, how else can I achieve my goal of storing metadata about each page, either at the page level, or at the document level?

推荐答案

您可以查看虾的来源

https://github.com/prawnpdf/prawn/commit/131082af5abb71d83de0e2005ecceaa829224904

info = { :Title => "Sample METADATA",
             :Author => "Me",
             :Subject => "Not Working",
             :CreationDate => Time.now }

@pdf = Prawn::Document.new(:template => filename, :info => info) 

这篇关于将元数据添加到PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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