Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 2.36 KB

README.md

File metadata and controls

33 lines (27 loc) · 2.36 KB

invert only the images (not text nor background)
[R,G,B]:255-[R,G,B]

node invert-pdf.mjs yourPDF.pdf

included demo:
node invert-pdf.mjs VyacheslavEgorov_BenchmarkingJavaScript.pdf

output folder tempWork\:
stage 1: decrypted.pdf
stage 2: uncompressed.pdf
stage 3: transformed.pdf
stage 4: fixed.pdf
stage 5: compressed.pdf
(compressed.pdf is what you should take, the rest is for those interested)

summary:

const ok=spawn(`${__dirname}/qpdf`,[pdfName,"--decrypt",`${__dirname}/tempWork/decrypted.pdf`])
const ok=spawn(`${__dirname}/pdftk`,[`${__dirname}/tempWork/decrypted.pdf`,"output",`${__dirname}/tempWork/uncompressed.pdf`,"uncompress"])
const ok=spawn(`${__dirname}/pdfimages`,["-all",`${__dirname}/tempWork/uncompressed.pdf`,"sure"],{cwd:`${__dirname}/tempWork`})
const ok=spawn(`${__dirname}/pdfimages`,["-list",`${__dirname}/tempWork/uncompressed.pdf`])
const ok=spawn(`${__dirname}/magick`,[`${__dirname}/tempWork/${v.basename}.${v.ext}`,"-channel","RGB","-negate",`${__dirname}/tempWork/${v.basename}_negate.${v.ext}`])
const ok=spawn(`${__dirname}/gswin64c`,["-o",`${__dirname}/tempWork/fixed.pdf`,"-sDEVICE=pdfwrite","-dPDFSETTINGS=/prepress",`${__dirname}/tempWork/transformed.pdf`])
const ok=spawn(`${__dirname}/pdftk`,[`${__dirname}/tempWork/fixed.pdf`,"output",`${__dirname}/tempWork/compressed.pdf`,"compress"])