Coder Social home page Coder Social logo

tuablove / html2file Goto Github PK

View Code? Open in Web Editor NEW

This project forked from petterobam/html2file

0.0 0.0 0.0 77.21 MB

收集一系列html转文档的开源插件,做成html页面转文件的微服务集成Web应用,目前包含 html转PDF、html转图片、html转markdown、html转word、excel等等。

Shell 0.78% C++ 2.92% C 14.64% Java 79.80% Pawn 1.81% Batchfile 0.05%

html2file's Introduction

Build Status MIT Licence stable

html2file

自己用java写文档转化生成果然有很多弊端和不兼容的地方,而一些开源插件转这些东西还是效果蛮不错,于是心生收集各种插件(兼容windows和linux)并封装成服务的想法。

这里我将收集一系列html转文档的开源插件,做成html页面转文件的微服务集成Web应用,预计包含:

  1. 网页转PDF
  2. 网页转图片
  3. 网页转TEXT
  4. 网页转WORD
  5. 网页转markdown
  6. 网页转excel
  7. 网页转...

目前支持

wkhtmltopdf演示图片

1.网页转PDF(wkhtml2pdf插件

例如:http://localhost:7800/html2pdf?pageUrl=https://wkhtmltopdf.org

2.网页转图片(wkhtml2pdf插件

例如:http://localhost:7800/html2image?pageUrl=https://wkhtmltopdf.org&fileExt=[可为空|默认 .png]

jHTML2Md演示图片

3.网页转Markdown(参用jHTML2Md

例如:http://localhost:7800/html2markdown?pageUrl=http://jsoup.org

html2word演示图片

4.网页转WORD(参用Apache POI

例如:http://localhost:7800/html2word?pageUrl=http://poi.apache.org

html2word演示图片

5.网页转Excel(参用table-to-xls

例如:http://localhost:7800/html2excel?pageUrl=http://www.jjwxc.net/bookbase_slave.php?booktype=free

API 服务

  1. 服务入口:/html2file

  2. 请求方式:post

  3. 服务入参:

    {
        "pageUrl":"https://wkhtmltopdf.org",
        "fileType":"2",
        "fileExt":""
        "pageHtmlContent":""
    }
    • pageUrl:目标链接,带http的链接,无登陆权限验证
    • fileType:文件类型,1-img,2-pdf,3-markdown,4-word,5-excel
    • fileExt:文件扩展名,图片转化可以转化为不同后缀格式的图片
    • pageHtmlContent:目标页面Html内容,当不能提供pageUrl时,将html内容传入也可以转化,其中引用的css和js需要为带http的路径,不能为相对路径
  4. 服务出参:

    {
        "status"1,
        "result""/output/20180417/pdf/9c3fd3018bb041429bba702cd127be9e.pdf",
        "errorMsg"""
    }
    • status:状态,1-成功,-1-失败
    • result:结果,这里为转化后的文件路径
    • errorMsg:错误信息

服务部署

服务开箱即用,Maven已经配好发布过程,install后将 dist 内的文件夹复制到服务器,将进入到 bin/ 文件夹下面

  1. linux系统
chmod +x html2file.sh  #授权脚本
sh html2file.sh start  #启动服务
sh html2file.sh stop   #停止服务
sh html2file.sh reload #重启服务
sh html2file.sh status #状态查看
sh html2file.sh log    #日志查看

中文乱码或空白的话,将 resources/font/simsun.ttc 拷贝到linux服务器 /usr/share/fonts/ 目录下

  1. windows系统

直接双击 html2file.bat 文件即可,也可以将该文件注册成服务,在服务管理里面启动。

Star History

star-history-20231110

html2file's People

Contributors

petterobam avatar jzfuqian 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.