Skip to content

emacsomancer/pdffontetc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

PDF Fonts Etc.

Designed to show information about a Portable Document Format (PDF) document fonts and other metadata information.

Three basic commands:

  1. pdffontetc-display-metadata-org-style - Display PDF metadata in a separate buffer in Org-mode style.
  2. pdffontetc-display-font-information - Show information about the fonts used in a PDF. [Optionally includes explanatory information if called with prefix argument. I.e., if command is preceded by C-u.]
  3. pdffontetc-display-combined-metadata-and-font-info - Show both of the above in the same temp buffer. [Same optional prefix behaviour as 2.]

Some screenshots in action

PDF with lots of metadata & fonts0

images/pdffontetc-screenshot01.png

images/pdffontetc-screenshot02.png

PDF generated in some horrible way

images/pdffontsetc-screenshot03.jpg

Remarks, Requirements

Requires the pdffonts utility from Poppler, which is the same PDF toolsuite that the Emacs PDF Tools package uses. And you ideally are also using the PDF Tools package.

The metadata command is more or less functionally equivalent with the one already in PDF Tools (in pdf-misc.el), but displays using Org-mode styling.

The PDF Tools metadata functionality has been around for a while, and I often use it. I was frustrated because I wanted to be able to see information about fonts as well, and would always have to drop out to a terminal to get this information. Now I don’t have to anymore.

(I have submitted a pull request to merge this functionality into PDF Tools, but in case this doesn’t happen and/or in the meantime, it is here as a separate add-on package.)

Maybe shadow PDF Tools pdf-misc-minor-mode map in your init, or otherwise add convenient keybindings (maybe under :config in your use-package):

(defun pdffontetc-extra-keys ()
    "Set some additional keybindings in PDF-Tools for pdffontetc info functions."
    ;; `O' for `Org-style' Info, = pdf metadata in orgish display:
    (local-set-key (kbd "O") #'pdffontetc-display-metadata-org-style)
    ;; `T' for `Typeface', i.e., Font info [since `F' is already taken]:
    (local-set-key (kbd "T") #'pdffontetc-display-font-information)
    ;; `U' for `Unified' info, i.e., both Metadata and Font info:
    (local-set-key (kbd "U") #'pdffontetc-display-combined-metadata-and-font-info))

(add-hook 'pdf-view-mode-hook #'pdffontetc-extra-keys)

Installation

Easiest if you’re using Emacs 30 or above is the built-in vc-use-package. If you use an alternative/supplement package manager already, you probably know what you’re doing. Otherwise:

Manual

Clone this repo or copy the pdffontetc.el file somewhere and load it via init.el, e.g., copy to ~/.emacs.d/lisp/pdffontetc/ and put in your init.el:

(add-to-list 'load-path
             "~/.emacs.d/lisp/pdffontetc/")
  (require 'pdffontetc)

vc-use-package [built-in]

Included in Emacs 30+. Probably the easiest method:

(use-package pdffontetc
  :vc (pdffontetc :url "https://github.com/emacsomancer/pdffontetc"
                    :branch "main")
  :ensure t)

vc-use-package [separately packaged]

The non-built-in version of vc-use-package uses slightly different syntax:

(use-package pdffontetc
  :vc (:fetcher github :repo "emacsomancer/pdffontetc")
  :ensure t)

elpaca

With elpaca:

(use-package pdffontetc
  :ensure (:host github :repo "emacsomancer/pdffontetc"))

straight

With straight:

(use-package pdffontetc
  :straight (pdffontetc :type git :host github :repo "emacsomancer/pdffontetc")
  :ensure t)

quelpa

With quelpa:

(use-package pdffontetc
  :quelpa (pdffontetc :fetcher github :repo "emacsomancer/pdffontetc")
  :ensure t)

Miscellaneous Notes

The pdffonts help key (in pdffontetc-pdffonts-man-help):

The following information is listed for each font:

  • name: the font name, exactly as given in the PDF file (potentially including a subset prefix)
  • type: the font type – see below for details
  • emb: “yes” if the font is embedded in the PDF file
  • sub: “yes” if the font is a subset
  • uni: “yes” if there is an explicit ToUnicode map in the PDF file (the absence of a ToUnicode map doesn’t necessarily mean that the text can’t be converted to Unicode)
  • object ID: the font dictionary object ID (number and generation; given here in format Number.Generation)

PDF files can contain the following types of fonts:

  • Type 1
  • Type 1C [= Compact Font Format (CFF)]
  • Type 3
  • TrueType
  • CID Type 0 [= 16-bit font with no specified type]
  • CID Type 0C [= 16-bit PostScript CFF font]
  • CID TrueType [= 16-bit TrueType font]

[ adapted from man pdffonts ]

Related Packages

  • PDF Tools (obviously): viewing PDFs in Emacs
  • pdf-meta-edit: editing PDF metadata, labels, & bookmarks in Emacs

Notes

0 For the creator field, see the nascent Emacs System Information and Environs package, under the “encoding system details” section.

About

Emacs interface to pdffonts and other PDF metadata

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published