在Windows 8.1上使用MuPDF创建pdf的图像注释
Create image annotation of pdf using MuPDF on Windows 8.1
我正在C++上开发一个WinRT应用程序,它应该可以帮助用户阅读和注释PDF文件。我正在使用MuPDF来解析PDF。我可以阅读PDF并添加行和自由文本注释,但无法在页面中插入图像。我找不到任何样品,也找不到解释我要找什么的手册。我正在使用以下代码创建图像,但图像没有出现:
std::string pathToOutputBook3 += "\testPDF.pdf";
std::string pathToImage3 = "Assets/hortitsa.jpg";
fz_point pts[4] = { { 0, 0 }, { 0, 0 }, { 600, 0 }, { 600, 499 } };
fz_rect rect = fz_empty_rect;
pdf_document *pdfDoc = (pdf_document *)this->mu_doc;
pdf_page *pdfPage = (pdf_page *)page;
image_document *imgDoc = (image_document *)fz_open_document(this->mu_ctx, pathToImage3.c_str());
fz_image *image = imgDoc->image;
fz_matrix page_ctm = { 1, 0, 0, 1, 0, 0 };
fz_include_point_in_rect(&rect, &pts[0]);
fz_include_point_in_rect(&rect, &pts[1]);
fz_include_point_in_rect(&rect, &pts[2]);
fz_include_point_in_rect(&rect, &pts[3]);
display_list = fz_new_display_list(this->mu_ctx);
dev = fz_new_list_device(this->mu_ctx, display_list);
auto annot = pdf_create_annot(pdfDoc, pdfPage, fz_annot_type::FZ_ANNOT_SQUARE);
fz_fill_image(dev, image, &page_ctm, 1.0f);
fz_transform_rect(&rect, &page_ctm);
pdf_set_annot_appearance(pdfDoc, annot, &rect, display_list);
fz_write_document(this->mu_doc, (char *)pathToOutputBook3.c_str(), nullptr);
没有"image"注释类型。有些注释类型可能被滥用以在外观中存储图像,但忽略外观流并从注释字典(如Adobe Acrobat)创建新的注释流的读者仍然不会显示图像。
如果你想在文档中添加图像,那么你需要这样做,而不是尝试使用注释。我相信现在可以使用MuPDF将图像添加到页面内容流中,但我自己不知道如何做到这一点。
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 使用std::multimap迭代器创建std::list
- 在全局变量中保存类的实例以重新创建类(创建"backup")
- 使用CMake创建QML插件
- 如何在c++中为模板函数实例创建快捷方式
- 在C++中,是否可以基于给定的标识符创建基类的新实例,反之亦然
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- 我们可以使用mfc应用程序创建pdf文件吗
- C++库,用于创建支持多种语言的 PDF
- 使用C 中的Haru库中的PDF创建表
- 在Windows 8.1上使用MuPDF创建pdf的图像注释
- 通过iTextSharp创建的pdf文件大小巨大
- Libharu pdf创建:如何知道打印文本的大小
- 创建并转换为 PDF 的..无工具包
- Qt创建pdf示例 - 无法使其工作
- 创建pdf文件时出现Doxygen和Latex错误
- 是否有一个(比较高级的)c++库来创建在iOS和Android上运行的pdf文档?
- 用c++创建处理RTL语言和复杂脚本的pdf
- 如何创建包含不同图层的 PDF 文件
- 创建pdf与可编辑的形式在Qt