Comments (6)
you might want to limit the loop to a valid number of pages. see if this helps. i'm not sure that the method prepares for a case where i is irrelevant.
from hummusjs.
How can I get number of pages?
from hummusjs.
well, hummus does not currently provide this info.
it shouldn't, however, be overly complex to provide it. after all libtiff is part of the underlying C++ code.
let me know if you have alternates on how to get the number of pages, otherwise we'll figure out how to expose this info.
from hummusjs.
something like
for (var numberOfPages=0; true; numberOfPages++) {
var page = pdfWriter.createPage(0,0,595,842);
var cxt = pdfWriter.startPageContentContext(page);
cxt.drawImage(0,0,'multipage.tiff',{index:numberOfPages,transformation:{width:595, height:842, proportional:true}});
try {
pdfWriter.writePage(page);
} catch(e) {
break;
}
}
from hummusjs.
Thanks. this method should leave some unwanted objects in the page. i still prefer that you'll be able to predict the number of pages and avoid writing anything unwanted.
Checked in/published new version now. to get the number of pages for any image (this includes pdf) use the following new method getImagePagesCount
:
var pageCount = pdfWriter.getImagePagesCount('./TestMaterials/images/tiff/multipage.tif');
good luck,
Gal.
from hummusjs.
then segfault doesn't matter
Thanks a lot.
from hummusjs.
Related Issues (20)
- Is there a way to put an image inside a cell in the tables?
- Error library v1.0.109 HOT 1
- Text replace
- Annotation modification
- Remove or replace some text in PDF file
- Build failed after upgrading node from 14.x to 15.x (docker - ubuntu) HOT 1
- unable to append to page, make sure source file exists at merge
- How to remove Rectangle using position?
- Spelling Error: "parhaps" HOT 2
- Last commit has broken the instalation on CentOS7 HOT 6
- Invalid PDF input causes `SIGSEGV` crash HOT 15
- unable to append page, make sure it's fine HOT 2
- whitesource scan issues caused by minimist 0.0.8 HOT 1
- @galkahana @filmerjarred
- How to save the splitted pdf to another directory
- TypeError: Unable to create PDF file, make sure that output file target is available
- Build failed with v1.0.115 with node v12 HOT 2
- Typing correction HOT 1
- TypeError: Unable to write page when calling writePage HOT 5
- Delete object from pdf HOT 6
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 hummusjs.