1
//========================================================================
5
// Copyright 2001-2007 Glyph & Cog, LLC
7
//========================================================================
9
//========================================================================
11
// Modified under the Poppler project - http://poppler.freedesktop.org
13
// All changes made under the Poppler project to this file are licensed
14
// under GPL version 2 or later
16
// Copyright (C) 2006 Dominic Lachowicz <cinamod@hotmail.com>
17
// Copyright (C) 2007-2008, 2010 Albert Astals Cid <aacid@kde.org>
18
// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
20
// To see a description of the changes please see the Changelog file that
21
// came with your tarball or type make ChangeLog if you are building from git
23
//========================================================================
26
#include <poppler-config.h>
32
#include "parseargs.h"
33
#include "goo/GooString.h"
35
#include "GlobalParams.h"
38
#include "PDFDocFactory.h"
41
static char *fontTypeNames[] = {
56
static int firstPage = 1;
57
static int lastPage = 0;
58
static char ownerPassword[33] = "\001";
59
static char userPassword[33] = "\001";
60
static GBool printVersion = gFalse;
61
static GBool printHelp = gFalse;
63
static const ArgDesc argDesc[] = {
64
{"-f", argInt, &firstPage, 0,
65
"first page to examine"},
66
{"-l", argInt, &lastPage, 0,
67
"last page to examine"},
68
{"-opw", argString, ownerPassword, sizeof(ownerPassword),
69
"owner password (for encrypted files)"},
70
{"-upw", argString, userPassword, sizeof(userPassword),
71
"user password (for encrypted files)"},
72
{"-v", argFlag, &printVersion, 0,
73
"print copyright and version info"},
74
{"-h", argFlag, &printHelp, 0,
75
"print usage information"},
76
{"-help", argFlag, &printHelp, 0,
77
"print usage information"},
78
{"--help", argFlag, &printHelp, 0,
79
"print usage information"},
80
{"-?", argFlag, &printHelp, 0,
81
"print usage information"},
85
int main(int argc, char *argv[]) {
88
GooString *ownerPW, *userPW;
95
ok = parseArgs(argDesc, &argc, argv);
96
if (!ok || argc != 2 || printVersion || printHelp) {
97
fprintf(stderr, "pdffonts version %s\n", PACKAGE_VERSION);
98
fprintf(stderr, "%s\n", popplerCopyright);
99
fprintf(stderr, "%s\n", xpdfCopyright);
101
printUsage("pdffonts", "<PDF-file>", argDesc);
103
if (printVersion || printHelp)
107
fileName = new GooString(argv[1]);
110
globalParams = new GlobalParams();
113
if (ownerPassword[0] != '\001') {
114
ownerPW = new GooString(ownerPassword);
118
if (userPassword[0] != '\001') {
119
userPW = new GooString(userPassword);
123
if (fileName->cmp("-") == 0) {
125
fileName = new GooString("fd://0");
128
doc = PDFDocFactory().createPDFDoc(*fileName, ownerPW, userPW);
146
if (lastPage < 1 || lastPage > doc->getNumPages()) {
147
lastPage = doc->getNumPages();
152
FontInfoScanner scanner(doc, firstPage - 1);
153
GooList *fonts = scanner.scan(lastPage - firstPage + 1);
155
// print the font info
156
printf("name type emb sub uni object ID\n");
157
printf("------------------------------------ ----------------- --- --- --- ---------\n");
159
for (int i = 0; i < fonts->getLength(); ++i) {
160
FontInfo *font = (FontInfo *)fonts->get(i);
161
printf("%-36s %-17s %-3s %-3s %-3s",
162
font->getName() ? font->getName()->getCString() : "[none]",
163
fontTypeNames[font->getType()],
164
font->getEmbedded() ? "yes" : "no",
165
font->getSubset() ? "yes" : "no",
166
font->getToUnicode() ? "yes" : "no");
167
const Ref fontRef = font->getRef();
168
if (fontRef.gen >= 100000) {
171
printf(" %6d %2d\n", fontRef.num, fontRef.gen);
186
// check for memory leaks
187
Object::memCheck(stderr);