Mercurial > hgrepos > Python2 > PyMuPDF
view mupdf-source/docs/examples/create-thumbnail.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
// Create a PDF containing thumbnails of pages rendered from another PDF. import * as mupdf from "mupdf" var pdf = new mupdf.PDFDocument() var subdoc = mupdf.Document.openDocument("pdfref17.pdf") var resources = { XObject: {} } var contents = new mupdf.Buffer() for (var i=0; i < 5; ++i) { var pixmap = subdoc.loadPage(1140+i).toPixmap([0.2,0,0,0.2,0,0], mupdf.ColorSpace.DeviceRGB, true) resources.XObject["Im" + i] = pdf.addImage(new Image(pixmap)) contents.writeLine("q 100 0 0 150 " + (50+100*i) + " 50 cm /Im" + i + " Do Q") } var page = pdf.addPage([0,0,100+i*100,250], 0, resources, contents) pdf.insertPage(-1, page) pdf.save("out.pdf")
