Designed to show information about a Portable Document Format (PDF) document fonts and other metadata information.
Three basic commands:
pdffontetc-display-metadata-org-style
- Display PDF metadata in a separate buffer in Org-mode style.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 byC-u
.]pdffontetc-display-combined-metadata-and-font-info
- Show both of the above in the same temp buffer. [Same optional prefix behaviour as 2.]
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:
(defvar pdf-misc-minor-mode-map
(let ((map (make-sparse-keymap)))
;; `I' for `Info', = pdf metadata:
(define-key map (kbd "I") #'pdf-misc-display-metadata)
;; `O' for `Org-style' Info, = pdf metadata in orgish display:
(define-key map (kbd "O") #'pdffontetc-display-metadata-org-style)
;; `T' for `Typeface', i.e., Font info [since `F' is already taken]:
(define-key map (kbd "T") #'pdffontetc-display-font-information)
;; `U' for `Unified' info, i.e., both Metadata and Font info:
(define-key map (kbd "U") #'pdffontetc-display-combined-metadata-and-font-info)
;; `c'ommand to `p'rint:
(define-key map (kbd "C-c C-p") #'pdf-misc-print-document)
map)
"Keymap used in `pdf-misc-minor-mode'.")
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:
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)
Included in Emacs 30+. Probably the easiest method:
(use-package pdffontetc
:vc (pdffontetc :url "https://github.com/emacsomancer/pdffontetc"
:branch "main")
:ensure t)
The non-built-in version of vc-use-package uses slightly different syntax:
(use-package pdffontetc
:vc (:fetcher github :repo "emacsomancer/pdffontetc")
:ensure t)
With elpaca:
(use-package pdffontetc
:ensure (:host github :repo "emacsomancer/pdffontetc"))
With straight:
(use-package pdffontetc
:straight (pdffontetc :type git :host github :repo "emacsomancer/pdffontetc")
:ensure t)
With quelpa:
(use-package pdffontetc
:quelpa (pdffontetc :fetcher github :repo "emacsomancer/pdffontetc")
:ensure t)
name
: the font name, exactly as given in the PDF file (potentially including a subset prefix)type
: the font type – see below for detailsemb
: “yes” if the font is embedded in the PDF filesub
: “yes” if the font is a subsetuni
: “yes” if there is an explicitToUnicode
map in the PDF file (the absence of aToUnicode
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 formatNumber.Generation
)
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
]