1

我正在尝试放大 PDF 便签的图标。这是一张显示我在 PDF 第一页上标记的粘性图标的图像:

在此处输入图像描述

我的印象是图标是由一个可以操作的矩形引导的。这是我尚未生效的代码:

using (PdfStamper stamp = new PdfStamper(reader, fs))
{
    PdfWriter attachment = stamp.Writer;
    foreach (string file in files_to_attach)
    {
        PdfFileSpecification pdfAttch = PdfFileSpecification.FileEmbedded(attachment, file, file, null);
        stamp.AddFileAttachment(file, pdfAttch);
    }

    //Create Note for first page
    Rectangle rect = new Rectangle(850, 850, 650, 650);
    PdfAnnotation annotation = PdfAnnotation.CreateText(stamp.Writer, rect, "TITLE OF NOTE", "Body text of the note", false, "Comment");

    //Enlarge the Sticky Note icon
    PdfDictionary page = reader.GetPageN(1);
    PdfArray annots = page.GetAsArray(PdfName.ANNOTS);
    PdfDictionary sticky = annots.GetAsDict(0);
    PdfArray stickyRect = sticky.GetAsArray(PdfName.RECT);
    PdfRectangle stickyRectangle = new PdfRectangle(
        stickyRect.GetAsNumber(0).FloatValue - 50, stickyRect.GetAsNumber(1).FloatValue - 20,
        stickyRect.GetAsNumber(2).FloatValue, stickyRect.GetAsNumber(3).FloatValue - 30);
    sticky.Put(PdfName.RECT, stickyRectangle);

    //Apply the Note to the first page
    stamp.AddAnnotation(annotation, 1);

    stamp.Close();
}

我以为我可以更改浮点值,这会改变图标的​​形状,但到目前为止还没有影响到这一切。感谢您的任何建议。

4

1 回答 1

1

你不能。为“注释”注释显示的图标由查看器提供。rect 属性仅用于定义查看器在页面上放置图标的左下角。根据“文本”类型注释的 PDF 规范,“符合标准的阅读器应为至少以下标准名称提供预定义的图标外观:注释、键、注释、帮助、新段落、段落、插入。

但是,您可以创建自己的任意大小的图像,并将其用作“图章”注释的外观。它甚至可以看起来完全像一个“评论”图标,只是更大。对于最终用户,它最终将以相同的方式运行。

于 2017-04-07T14:49:37.507 回答