簡體   English   中英

pdfclown中的注釋

[英]Annotation in pdfclown

我試圖在某個x,y位置放一個便利貼。 為此我在.net中使用pdfclown注釋類。 以下是可用的。

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

注釋的鏈接這是一個粘滯便箋在78,658個坐標在一個空白的PDF格式。

問題是我想要特定pdf中的粘滯便箋,其中包含一些數據。 我怎么能修改它...謝謝你的幫助..

我是PDF Clown的作者 - 這是在現有頁面中插入粘滯便箋等注釋的正確方法:

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多個樣本,以及API文檔, 你就可以發現它的表現力和強大程度。 其架構嚴格遵循官方的Adobe PDF Reference 1.7。

請享用!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM