如何更改通过iTextSharp放置的PDF便笺的图标大小?

时间:2017-04-07 14:03:36

标签: c# pdf itext pdfstamper pdf-annotations

我正在尝试放大PDF便笺的图标。这是一张图片,显示了我在PDF的第一页上标记的粘性图标,用于上下文:

enter image description here

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

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();
}

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

1 个答案:

答案 0 :(得分:1)

你不能。为"评论"显示的图标注释由观察者提供。 rect属性仅用于定义查看器将图标放置在页面上的左下角。根据带有" Text",&#34类型注释的PDF规范;符合性读者应至少为以下标准名称提供预定义的图标外观:注释,键,注释,帮助,NewParagraph,段落,插入

然而,您可以创建任意大小的自己的图像,并将其用作" Stamp"的外观。注解。它甚至可以看起来像一个"评论"图标,只是更大。它最终将以最终用户的相同方式运行。

相关问题