首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pdfclown中的注释

pdfclown中的注释
EN

Stack Overflow用户
提问于 2012-12-20 18:43:15
回答 1查看 1.1K关注 0票数 3

我试着在x,y的某个位置放一张便签纸。为此,我使用了.net中的pdfclown注解类。下面是可用的内容。

代码语言:javascript
复制
    using files = org.pdfclown.files;
    public override bool Run()
    {
        files::File file = new files::File();
        Document document = file.Document;
        Populate(document);
        Serialize(file, false, "Annotations", "inserting annotations");
        return true;
    }

    private void Populate(Document document)
    {
        Page page = new Page(document);
        document.Pages.Add(page);
        PrimitiveComposer composer = new PrimitiveComposer(page);
        StandardType1Font font = new StandardType1Font(document, StandardType1Font.FamilyEnum.Courier, true, false);
        composer.SetFont(font, 12);
        annotations::Note note = new annotations::Note(page, new Point(78, 658), "this is my annotation...");
        note.IconType = annotations::Note.IconTypeEnum.Help;
        note.ModificationDate = new DateTime();
        note.IsOpen = true;
        composer.Flush();
    }

Link for annotation这是在一个空白的pdf中放置一个78,658个坐标的便条。

问题是,我想要有一些数据的特殊pdf格式的便签纸。如何修改帮助的it...thanks。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-25 01:28:03

我是的作者--这是将注释插入到现有页面的正确方法:

代码语言:javascript
复制
using org.pdfclown.documents;
using annotations = org.pdfclown.documents.interaction.annotations;
using files = org.pdfclown.files;
using System.Drawing;

. . .

// Open the PDF file!
using(files::File file = new files::File(@"C:\mypath\myfile.pdf"))
{
  // Get the document (high-level representation of the PDF file)!
  Document document = file.Document;
  // Get, e.g., the first page of the document!
  Page page = document.Pages[0];

  // Insert your sticky note into the page!
  annotations::Note note = new annotations::Note(page, new Point(78, 658), "this is my annotation...");
  note.IconType = annotations::Note.IconTypeEnum.Help;
  note.ModificationDate = new DateTime();
  note.IsOpen = true;

  // Save the PDF file!
  file.Save(files::SerializationModeEnum.Incremental);
}

请考虑到,关于保存文件的方式有很多选择(到输出(内存中)流,到不同的路径,作为压缩文件,作为附加文件...)。

如果您查看该库发行版附带的50+示例,以及它的文档,就会发现它的表现力和强大之处。它的架构严格遵循官方的Adobe PDF参考1.7。

享受吧!

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13970332

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档