Giter VIP home page Giter VIP logo

pdf2jpg's People

Contributors

dependabot[bot] avatar wangsijie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

lham-ss tso2022

pdf2jpg's Issues

Allow SCALE to be a default parameter

Thanks for the library!

Can you allow the scale variable to be an optional, defaulted parameter?

I would submit a PR but others are blocked from creating branches.

index.js

const scale = 1; // Remove this line

.
.
.

async function app(pdfData, options = { scale: 1 }) { // Add parameter with same default value of 1
    const doc = await pdfjsLib.getDocument(pdfData).promise;
    const draw = new Draw();
    for (let i = 0; i < doc.numPages; i++) {
        const page = await doc.getPage(i + 1);
        const viewport = page.getViewport({ scale: options.scale }); // Use options
        .
        .
        .

When rendering a single page of a multiple (n) page pdf, the system renders a blank page and a small image (1/n of total size)

using https://commons.wikimedia.org/wiki/File:ABC_de_l%27%C3%89lecteur.pdf as an example,
when calling the API as follows

const jpgBuffer = await pdf2jpg(buffer, { scale: 1, page: 1 })

the generated image is mostly black. A small yellow square is at the bottom. (the first page).
This seems to come from index.js line 65:

height += Math.ceil(viewport.height);

which I think is supposed to be

height = Math.ceil(viewport.height);

feature request: 提供个逐页输出单页的api

{page: pages.length}

如果能自定义页码范围就更好了,如:

{page: [2, pages.length -1]}

我知道可以自己写循环,但需要直接引用 pdfjs-dist,提供个接口显然更方便。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.