Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/docs/examples/create-thumbnail.js @ 3:2c135c81b16c
MERGE: upstream PyMuPDF 1.26.4 with MuPDF 1.26.7
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:44:09 +0200 |
| parents | b50eed0cc0ef |
| children |
comparison
equal
deleted
inserted
replaced
| 0:6015a75abc2d | 3:2c135c81b16c |
|---|---|
| 1 // Create a PDF containing thumbnails of pages rendered from another PDF. | |
| 2 | |
| 3 import * as mupdf from "mupdf" | |
| 4 | |
| 5 var pdf = new mupdf.PDFDocument() | |
| 6 | |
| 7 var subdoc = mupdf.Document.openDocument("pdfref17.pdf") | |
| 8 | |
| 9 var resources = { XObject: {} } | |
| 10 | |
| 11 var contents = new mupdf.Buffer() | |
| 12 for (var i=0; i < 5; ++i) { | |
| 13 var pixmap = subdoc.loadPage(1140+i).toPixmap([0.2,0,0,0.2,0,0], mupdf.ColorSpace.DeviceRGB, true) | |
| 14 resources.XObject["Im" + i] = pdf.addImage(new Image(pixmap)) | |
| 15 contents.writeLine("q 100 0 0 150 " + (50+100*i) + " 50 cm /Im" + i + " Do Q") | |
| 16 } | |
| 17 | |
| 18 var page = pdf.addPage([0,0,100+i*100,250], 0, resources, contents) | |
| 19 pdf.insertPage(-1, page) | |
| 20 | |
| 21 pdf.save("out.pdf") |
