我试着在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();
}Link for annotation这是在一个空白的pdf中放置一个78,658个坐标的便条。
问题是,我想要有一些数据的特殊pdf格式的便签纸。如何修改帮助的it...thanks。
发布于 2012-12-25 01:28:03
我是的作者--这是将注释插入到现有页面的正确方法:
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。
享受吧!
https://stackoverflow.com/questions/13970332
复制相似问题