GithubHelp home page GithubHelp logo

pdfff's Introduction

pdfff









A simple pdf font fix using Bash (linux/wsl) and Ghostscript. :)



Why

Sometimes the PDF generated doesn´t have embedded ttf fonts and you got issues when the file is sent to a printer. It causes bad behavior! I mean due to a failure in the font substitution process if you´re using a system without the required font or especially when the host is an Android device. So your hard copy will be printed with the wrong font :(



How Ghostscript works

This script creates a batch process to extends the ghostscript commands allowing repair (not)embedded font issues, compress to re-distribute



Base ghostscript command to embed fonts:

gs -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress original.pdf





Base ghostscript to embed and compress:

gs -q -o repaired.pdf -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/ebook -dAutoRotatePages=/None -dColorImageDownsampleType=/Bicubic -dColorImageResolution=72 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=72 -dMonoImageResolution=72 original.pdf





Check your PDF file using pdffonts (requires poppler app)

pdffonts your_pdf.pdf



Results:
image
If the results has "no" on "emb column" and you are gettings issues on your printing process, consider update the cidfmap and run pdfff to fix it.



Update cidfmap

So if your pdf file has a font that your system doesn´t, you could add the entry bellow on /var/lib/ghostscript/fonts/cidfmap

/Arial << /FileType /TrueType /Path (/usr/local/share/fonts/arial.ttf) /SubfontID 0 /CSI [(Identity) 0] >> ;

Arial on this sample, replace with font name that fits your needs



Path and fonts

Path:

  • If you´re using an installed font on your Microsoft Windows and running this script on WSL you could use "/mnt/c/Windows/Fonts/font.ttf" as a PATH
  • If you want to point directly to ttf file, copy that to "/usr/local/share/fonts/font.ttf" and use it as a PATH
  • You arelady got it!

Fonts:

  • You could install Microsoft fonts if you hasn´t, run "sudo apt install ttf-mscorefonts-installer"
  • You could download Microsoft fonts from https://www.w7df.com/ and manually install



Howto use pdfff

Get the script file, make it executable

sudo chmod +x pdfff.sh

Run

./pdfff.sh

Sample PDFs to test if you have no one to start:





References





Todo

  • Send your idea :P

pdfff's People

Contributors

saymoncoppi avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hujunyao

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.