使用pdfium在数组中获取PDF图像进行编辑

发布于 2025-01-28 07:43:13 字数 367 浏览 1 评论 0原文

我正在尝试写下一种方法,以从fpdf_document对象中获取所有PDF图像,以便在它们上执行操作,然后返回fpdf_document,并更换图像。

应该是这样的:

  1. 对于输入fpdf_document document对每个(获取图像对象)的每个(获取图像对象)
  2. 对每个做事。
  3. 将原始对象替换回fpdf_document
  4. 返回fpdf_document

这很有意义吗?

由于没有文档,我迷失了我的pdfium源。指针将不胜感激。谢谢

I am trying to write down a method to get all PDF images from a FPDF_DOCUMENT object to perform actions on them and return back theFPDF_DOCUMENT with the images replaced.

It should be like this:

  1. For each (get image objects) for input FPDF_DOCUMENT document
  2. DO something to each.
  3. Replace the original objects back to the FPDF_DOCUMENT
  4. Return the FPDF_DOCUMENT

Does that make sense?

I am lost in PDFium source as there are no documentation. Pointers would be much appreciated. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伴梦长久 2025-02-04 07:43:13

您将必须使用以下方法/步骤:

  • 使用fpdf_loaddocument或等效的
  • 调用fpdf_getPageCount在文档上
  • 打开 文档
    • 呼叫fpdf_loadpage每个页面都有
    • 呼叫fpdfpage_countobjects获取对象的数量
    • 循环穿过所有对象
      • 呼叫fpdfpage_getObject在每个对象上
      • 呼叫fpdfpageObj_getType在每个加载对象上
      • 检查页面对象是否是类型fpdf_pageobj_image,然后继续,else skip
      • 您的魔术(可能fpdfimageObj_getBitMap/fpdfimageobj_setbitmap?)
    • 您可能必须调用fpdfpage_generatecontent以确保使用更改更新内部页面
    • 呼叫fpdf_closepage关闭页面
  • 呼叫fpdf_saveascopy保存新的PDF
  • 调用fpdf_closedocument以关闭原始文档。

You would have to use the following methods/steps:

  • Open document with FPDF_LoadDocument or equivalent
  • Call FPDF_GetPageCount on the document to get the amount of pages
  • Loop through the pages
    • Call FPDF_LoadPage for every page there is
    • Call FPDFPage_CountObjects to get the amount of objects
    • Loop through all the objects
      • Call FPDFPage_GetObject on every object
      • Call FPDFPageObj_GetType on every loaded object
      • Check if the page object is of type FPDF_PAGEOBJ_IMAGE, then continue, else skip
      • Do your magic (probably FPDFImageObj_GetBitmap / FPDFImageObj_SetBitmap?)
    • Possibly you have to call FPDFPage_GenerateContent to make sure the internal page is updated with the changes
    • Call FPDF_ClosePage to close the page
  • Call FPDF_SaveAsCopy to save the new PDF
  • Call FPDF_CloseDocument to close the original document.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文