npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

html-camera

v1.1.4

Published

print html images camera html转base64

Downloads

2

Readme

html-camera

兼容性

  • 依赖html2canvas(https://github.com/niklasvh/html2canvas),且该依赖需要手动安装,其官方文档:
  • http://html2canvas.hertzen.com/documentation
  • 兼容性:
  • Firefox 3.5+
  • Google Chrome
  • Opera 12+
  • IE9+
  • Edge
  • Safari 6+

不支持iframe
不能在浏览器插件中使用
不支持Flash
不支持古代浏览器

项目介绍

局部打印HTML 分页打印 分页组合打印 HTML转图片、转base64

安装教程

  1. npm i html-camera html2canvas
  2. 直接在页面中引用:<script src="html-camera.js"></script> 或 使用模块化加载:var htmlCamera = require('html-camera.js');
  • tips:

处理跨域图片:canvas对于图片资源有同源限制,需要图片资源响应头设置 Access-Control-Allow-Origin,且设置参数html2canvasOptions : {useCORS: true} 需要引入html2canvas,并保证window.Promise可用,不存在时,var htmlCamera = require('html-camera')(Promise); 在支持的打印内容中,打印效果“所见即所打”,无法根据打印纸的大小,自适应打印效果
常用样式中,border-style只支持solid,由html2canvas决定

htmlCamera(doms, opt) 使用方法

  • @param {dom元素} doms

{var} 支持dom,一维dom数组,二维dom数组,三维dom数组
传dom或一维数组时,直接打印;
传二维数组时,数组的第二维度会组合成在一起,以保证其不会分开打印;
传三维数组时,数组的第三维度中的元素,会尽量显示在一行

  • @param {obj} opt

{fn} getImgs dom转图片后回调 return false时,中断后续
{fn} getDataURLs dom转图片base64后回调 return false时,中断后续
{array} split 插入打印分页符的一维dom数组的索引集合
{obj} html2canvasOptions 传html2canvas的参数,详情参考 http://html2canvas.hertzen.com/configuration
{bool} isPrint 是否打印 default: true
{bool} isDebug 是否进入调试模式 defualt: false 是否保留中间过程在页面中生成的元素
{bool} error异常时回调