Displaying PDFS on mobile is a major pain point for mobile developers

At present, there are many solutions to display PDF on PC, such as:

PC

Embed tags

<embed type="application/pdf" src="test.pdf" width="100%" height="100%"/>Copy the code

pdf.js

Here is no longer redundant use method, a lot of online

Then it becomes a problem to display PDF on mobile phone, especially on wechat. After some research, WE found pdf2htmlEX on GitHub!

The mobile terminal

pdf2htmlEX

GitHub link: github.com/coolwanglu/…

Demo again, pay attention to the URL, is xxx.html! Coolwanglu. Making. IO/pdf2htmlEX /…

Ok, I believe you have been surprised by the Demo. Let’s take a look at its use:

The installation

Official documentation: github.com/coolwanglu/…

Mac OS X can be installed using BREW

brew install pdf2htmlEXCopy the code

Windows has the download link at the bottom of the above link.

use

Official documentation: github.com/coolwanglu/…

After installing pdf2htmlEX, use the command line to switch to the PDF file directory.

Here are a few commands:

Convert it all to HTML

1.3 PDF pdf2htmlEX - zoom/test. PDFCopy the code
  • Zoom indicates that the number after the zoom is the zoom scale. The smaller the number is, the smaller the GENERATED HTML display screen is, but the size of bytes itself is not affected
  • PDF /test. PDF is the file path relative to the current directory
  • The generated HTML file is in the current directory with the same file name.

### Convert all to directories (HTML,CSS,IMGS,FONTS)

pdf2htmlEX --embed cfijo --dest-dir out pdf/test.pdfCopy the code
  • Embed Cfijo has no real meaning, is its own command, does not need to modify
  • Out is the name of the custom folder where all converted files are generated
  • PDF /test. PDF is the source PDF file

In addition to the above commands, there are many practical ways, such as interception, conversion, pixel modification, etc., not described here, interested can go to the official website to view.