Mercurial > hgrepos > Python2 > PyMuPDF
view mupdf-source/docs/examples/import-fdf.js @ 38:8934ac156ef5
Allow to build with the PyPI package "clang" instead of "libclang".
1. It seems to be maintained.
2. In the FreeBSD base system there is no pre-built libclang.so. If you
need this library you have to install llvm from ports additionally.
2. On FreeBSD there is no pre-built wheel "libclang" with a packaged
libclang.so.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 23 Sep 2025 10:27:15 +0200 |
| parents | b50eed0cc0ef |
| children |
line wrap: on
line source
// usage: mutool run import-fdf.js input.pdf data.fdf output.pdf // // Import annotations from FDF into PDF file. // // TODO: import form data! "use strict" if (scriptArgs.length != 3) { print("usage: mutool run import-fdf.js file.pdf data.fdf output.pdf") quit() } var doc = mupdf.Document.openDocument(scriptArgs[0]) var data = mupdf.Document.openDocument(scriptArgs[1]) var map = doc.newGraftMap() var annots = data.getTrailer().Root.FDF.Annots if (annots) { annots.forEach( function (annot) { var ref = map.graftObject(annot) var page = doc.findPage(ref.Page) if (!page.Annots) page.Annots = [] page.Annots.push(ref) ref.P = page ref.delete("Page") } ) } doc.save(scriptArgs[2], "incremental")
