POC doc88.com Downloader
This is a POC downloader of documents from doc88.com. It saves pages of a given document as PNGs or JPEGs. It doesn't have any dependencies — it's a bit of JavaScript that you paste into Developer Tools' Console. It was tested in Chrome and Firefox.
Then, having pages saved as images, a searchable PDF can be reconstructed from them.
Create a browser bookmark pasting content of this file (exactly as it is) in the URL field.
From now on, clicking it on a document page will download all pages as PNG images in a single ZIP file.
Don't interact with the page during the process until it finishes. Be patient for documents with many pages e.g 100+, it may take a while.
- Navigate to the desired document in your browser.
- Make sure browser's zoom level is set to 100% — based on some tests it seems that zoom levels lower than 100% can result in lower quality of captured pages.
- Open Developer Tools (e.g. press Ctrl+Shift+I).
- Switch to JavaScript Console.
- Paste this JavaScript in Console and confirm with Enter.
- There are two options for downloading. Choose one only.
- Option 1: Single zip file of PNG images - Type
downloadPagesZip()
in Console and hit Enter. - Option 2: Individual files - Type
downloadPages()
in Console and hit Enter. This will download all the pages. Pages will be automatically preloaded and saved one by one.
- ℹ️ See options section below for options.
⚠️ In case of Chrome, the first time you download pages you may see a popup stating that "This site is attempting to download multiple files". You have to allow it as each page is downloaded as a separate file.
- Option 1: Single zip file of PNG images - Type
- Don't interact with the page during the process.
Wait until it ends, printingFinished downloading pages
in the Console.
Make sure all desired pages were downloaded correctly.
downloadPages
function takes an optional options object:
downloadPages({fromPage: 2, toPage: 10, quality: 0.8, imageNamePrefix: 'temp_'})
Possible options are:
fromPage
– first page in range to be downloaded; number; default is1
toPage
– last page in range to be downloaded; number; default is total number of pages in the documentformat
– downloaded image format; string; either'jpg'
or'png'
; default is'jpg'
quality
– quality of images; applicable whenformat
is'jpg'
; number between0
and1
; default is0.9
imageNamePrefix
– prefix for names of downloaded images; string; default is'page'
(resulting in downloaded file names e.g.:page001.jpg
,page002.jpg
, etc. assumingformat
is'jpg'
)
Under Linux you can easily convert downloaded images back to a PDF.
- Install ImageMagick package:
sudo apt-get install imagemagick
- If you want the PDF to be OCRed (recognize the text in it and make it searchable), install the OCRmyPDF package:
sudo apt-get install ocrmypdf
- Use the convert-images-to-pdf.sh script to convert downloaded images back to a PDF, e.g.:
Run it with
./convert-images-to-pdf.sh image-directory output.pdf
-h
argument for help.
If you see errors from ImageMagick with the message "attempt to perform an operation not allowed by the security policy 'PDF'", see this StackOverflow question and answers for a likely quick fix.
- Run
build-bookmark.sh
to update minified bookmark code inbookmark.min.js
.