iText 7-将PDF图层(OCG)与基本PDF合并 [英] iText 7 - Merge PDF layers (OCG) with the base PDF

查看:742
本文介绍了iText 7-将PDF图层(OCG)与基本PDF合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将PDF(OCG)的图层与基本PDF合并以形成没有图层的PDF?

Is it possible to merge layers of a PDF (OCG) with the base PDF to result in a PDF without layers?

我看到可以通过使用"Flatten Layers"选项使用Adobe Acrobat DC这样的应用程序来完成此操作,但是我需要使用iText7在Java应用程序中对此进行编程.

I saw that it's possible to accomplish this using an application as Adobe Acrobat DC using a "Flatten Layers" option but I need this programmed in my Java application using iText7.

@joelgeraci提供了一个有用且很好的答案,可以解决上一个问题,但是我最初有一些隐藏层,当从目录中删除OCProperty时,这些隐藏层仍会显示.

@joelgeraci has a useful and good answer that solves the previous question, but I have initially some hidden layers that will be displayed anyway when removing the OCProperties from the catalog.

推荐答案

您实际上不需要合并"图层.所有的图层内容已经是页面内容的一部分.图层,或更恰当的说是可选内容组",是观众可以根据设置进行绘制或不绘图的指令集,对于不支持图层的观众而言,它们只会显示.要拉平"图层,您只需要修改PDF,以使查看者认为没有任何可选内容.最简单的方法是从目录中删除OCProperties词典.一旦有了目录对象,请使用删除"传递OCPropreties词典的名称.

You don't actually need to "merge" the layers. All of the layer content is already part of the page content. Layers, or more properly Optional Content Groups, are sets of instructions that the viewer can either draw or not, depending on the settings, for viewers that don't support layers, they just all show. To "flatten" the layers, you just need to modify the PDF so that the viewer doesn't think there is any optional content. The easiest way is to delete the OCProperties dictionary from the Catalog. Once you have the catalog object, use "remove" passing the name of the OCPropreties dictionary.

catalog.remove(PdfName.OCPROPERTIES)

这篇关于iText 7-将PDF图层(OCG)与基本PDF合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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