Comments (5)
Here's an example of how to rotate a page with our existing API:
const fs = require("fs")
const mupdf = require("mupdf")
var doc = mupdf.Document.openDocument(fs.readFileSync("input.pdf"), "application/pdf")
var page = doc.loadPage(0)
// Get the PDF object corresponding to the page
var page_obj = page.getObject()
// Look up the existing page rotation (inheritable from the page tree, see PDF reference for details)
var rotate = page_obj.getInheritable("Rotate")
if (!rotate)
rotate = 0
// Update the Rotate value
page_obj.put("Rotate", rotate + 90)
// Save the changes to a new file.
fs.writeFileSync("output.pdf", doc.saveToBuffer("incremental").asUint8Array())
from mupdf.js.
I get this - why can't we bundle the 4 lines which do the work into mupdf.js
as a method? So I just do e.g. page.rotate(90)
from mupdf.js.
@ccxvii When I try your code sample I get: TypeError: page.getObject is not a function
from mupdf.js.
Oh wait - I'm just appreciating the other recent commits - I'll have to package up a local mupdf node package
from mupdf.js.
@ccxvii Opening this again as in the sample code I think the rotate
variable is a pointer and not a rotation value as such.
i.e.
// Look up the existing page rotation (inheritable from the page tree, see PDF reference for details)
let rotate = page_obj.getInheritable("Rotate")
console.log("rotate="+rotate) // rotate=11845304
if (!rotate)
rotate = 0
// Update the Rotate value
page_obj.put("Rotate", rotate + 90)
from mupdf.js.
Related Issues (20)
- Annotation: Free Text Callout API
- Annotation: Leader Line API
- Annotation: Leader Line Extension API
- Annotation: Measure API
- Annotations: Add API for "DS"
- OCR HOT 1
- DocumentWriter.close WASM RuntimeError HOT 10
- "Error: invalid page number: 2" HOT 7
- Page: Draw as SVG API HOT 5
- REST server should cache open documents
- REST server should rate limit fetches to third party server
- REST server should check HTTP error codes from fetch
- REST server should catch exceptions from WASM
- simple-viewer search always skips results from the current page HOT 2
- Rearrange exception HOT 1
- Issue converting pdf to png containing a graph with mupdf-wasm but works in mutools HOT 1
- document.resolveLink returns only page index rather than link destination object HOT 6
- Journal does not work as expected
- Link for outline requires both x and y coordinates in XYZ mode HOT 1
- mupdf not working with Next.js RouteHandler HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mupdf.js.