Coder Social home page Coder Social logo

pdf2image-py's Introduction

Descrição

Lib de conversão de PDFs para imagens, a conversão é feita com um script em  python. Para entender é bem simples eu crio um método no node que instancia um processo filho em paralelo com o processo principal, nesse novo processo filho então é executado o script em python que converte os PDFs.


Uso nos SOs

  • Linux
  • Windows

Dependências

Linux SO


Documentação dos Metodos

Metodo: convertPDFToImage: (props) => Promise<void>

  • pdfPath: string => Caminho do arquivo PDF
  • outPutFolder: string => Caminho da pasta de saída
  • outPutName?: string => Nome da pasta de saída com as imagens
  • dpi?: 100 | 150 | 200 | 250 | 300 => Densidade de pixels
  • fmt?: "jpeg" | "png" | "ppm" | "tif" => Formato da imagem de saída
  • timeout: number => Tempo de espera que o processo filho pode ficar em espera
  • threadCount: 1 | 2 | 3 | 4 => Número de encadeamentos a serem usados ​​ao converter o PDF. Limitado ao número real de páginas.
  • size: object => { width: number, height: number } => Tamanho da imagem de saída
  • jpegOptions?: object => { quality?: number; progressive?: boolean; optimize?: boolean; } => Opções de qualidade da imagem de saída somente se fmt = "jpeg"
  • thumbnail?: object => { outPath: string; outPutName?: string; width?: number | boolean; height?: number | boolean; fmt?: "jpeg" | "png" | "ppm"; } => Opçoes de thumbnail

Exemplos

Convertendo PDF para imagem simples

    
      import { convertPDFToImage } from 'pdf2image-py';
      
      convertPDFToImage({
        pdfPath: './path/to/file.pdf',
        outPutFolder: './path/to/outPutFolder',
      }).then(() => {
        console.log('Convertido com sucesso');
      }).catch((err) => {
        console.log(err);
      }
    
  

Converter pdfs e tambem gerar thumbnails

    
      import { convertPDFToImage } from 'pdf2image-py';

      convertPDFToImage({
        pdfPath: './path/to/file.pdf',
        outPutFolder: './path/to/outPutFolder',
        outPutName: 'outPutName',
        dpi: 300,
        fmt: 'png',
        timeout: 30000,
        threadCount: 2,
        size: { width: 100, height: 100 },
        jpegOptions: { quality: 100, progressive: true, optimize: true },
        thumbnail: {
          outPath: './path/to/outPutFolder',
          outPutName: 'outPutName',
          width: 100,
          height: 100,
          fmt: 'png',
        },
      }).then(() => {
        console.log('Convertido com sucesso');
      }).catch((err) => {
        console.log(err);
      }
    
  

Aviso de Criaçao de issues

  • Para criar uma issue informe o seguinte:
    • OS
    • Versão das dependencias
    • Versão do node
    • Versão do pdf2image-py

Testes

npm test

pdf2image-py's People

Contributors

devsergionunes avatar

Watchers

 avatar

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.