C# - 为PDF文件中的所有书签设置继承缩放操作 [英] C# - Set inherit zoom action for all the bookmarks in the PDF file

查看:373
本文介绍了C# - 为PDF文件中的所有书签设置继承缩放操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含3种类型书签的PDF文件

I have a PDF file with 3 types of bookmark


  • 第一本书标记 - 100%缩放

  • 第二个书签 - 200%缩放

  • 第三个书签 - 300%缩放

我使用了以下代码,但它在注释行中失败。

I have used following code but its fails in the annotation line.

PdfArray annots = page.getAsArray(PdfName.ANNOTS); // fails
for (int i = 0; i < annots.size(); i++)
{
    PdfDictionary annotation = annots.getAsDict(i);
    if (PdfName.LINK.equals(annotation.getAsName(PdfName.SUBTYPE)))
    {
        PdfArray d = annotation.getAsArray(PdfName.DEST);
        if (d != null && d.size() == 5 && PdfName.XYZ.equals(d.getAsName(1)))
        {
            d.set(4, new PdfNumber(0)); //error-does not contain set method in pdfarray
        }
    }
}

我需要为PDF文件中的所有书签设置继承缩放操作。如何使用 iTextSharp 设置PDF文件的继承缩放操作。

I need to set inherit zoom action for all the bookmarks in the PDF file. How can I set the inherit zoom action for PDF file using iTextSharp.

推荐答案

您在iTextSharp中使用iText代码。

You are using iText code in iTextSharp.

替换:

d.set(4, new PdfNumber(0));

使用:

d[4] = new PdfNumber(0);

这篇关于C# - 为PDF文件中的所有书签设置继承缩放操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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