Code Monkey home page Code Monkey logo

html-to-pdf's Introduction

html-to-pdf

预览

image.png

demo源码

root/app/view/index.html

教程

写了一下从头到尾实现的过程~ 有很多坑

掘金地址:Egg + Puppeteer 实现Html转PDF

个人博客:https://alexwjj.github.io/

Development

$ npm i
$ npm run dev

Deploy

$ npm start
$ npm stop

获取pdf文件流api

method: post,
url: /getPdf,
参数:
     // html文档
      htmlStr: {
        type: 'string',
        required: true,
        allowEmpty: false,
      },
      // 纸张
      format: {
        type: 'string',
        required: false,
        default: 'A4'
      },
      
      //  页面空白白边配置,默认是都为0
      margin: {
        type: 'object',
        required: false,
      },
      eg:margin: {
          top: '15px',
          right: '15px',
          bottom: '15px',
          left: '15px'
      }
      
      //  页面渲染的缩放。默认是1。缩放值必须介于0.1到2之间
      scale: {
        type: 'number',
        required: false,
      },
      
      // 是否显示页码 eg:1/4
      displayPageNumber: {
        type: 'boolean',
        required: false,
      },
      
      // 是否水平打印
      landscape: {
        type: 'boolean',
        required: false,
      },

html-to-pdf's People

Contributors

alexwjj 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.