├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── .mailmap
├── COPYING
├── Makefile
├── Makefile.dep
├── README.rst
├── acinclude.m4
├── autoconf.mk.in
├── config.cc
├── config.hh
├── configure.ac
├── const-adapter.hh
├── debug.cc
├── debug.hh
├── djvu-const.hh
├── djvu-outline.cc
├── djvu-outline.hh
├── doc
├── Makefile
├── README
├── changelog
├── credits
├── djvudigital
├── manpage.xml
└── po
│ ├── Makefile
│ ├── de.po
│ ├── fr.po
│ ├── pl.po
│ ├── pt.po
│ ├── ru.po
│ └── uk.po
├── i18n.cc
├── i18n.hh
├── image-filter.cc
├── image-filter.hh
├── main.cc
├── pdf-backend.cc
├── pdf-backend.hh
├── pdf-document-map.cc
├── pdf-document-map.hh
├── pdf-dpi.cc
├── pdf-dpi.hh
├── pdf-unicode.cc
├── pdf-unicode.hh
├── po
├── Makefile
├── de.po
├── pl.po
├── pt.po
├── ru.po
└── uk.po
├── private
├── announce-release
├── apt-install-build-reqs
├── autoclean
├── autogen
├── build-source-tarball
├── check-po
├── check-rst
├── clang-tidy
├── cppcheck
├── iwyu
├── request-translations
├── update-makefile-dep
└── update-version
├── rle.hh
├── sexpr.cc
├── sexpr.hh
├── string-format.cc
├── string-format.hh
├── string-printf.cc
├── string-printf.hh
├── string-utils.cc
├── string-utils.hh
├── sys-command-posix.cc
├── sys-command-win32.cc
├── sys-encoding.cc
├── sys-time.cc
├── sys-time.hh
├── sys-uuid.cc
├── sys-uuid.hh
├── system.cc
├── system.hh
├── tests
├── .pylintrc
├── Makefile
├── common.tex
├── test-1px-font.py
├── test-1px-font.tex
├── test-antialias-off.py
├── test-antialias-off.tex
├── test-antialias-on.py
├── test-antialias-on.tex
├── test-big-outline.py
├── test-big-outline.tex
├── test-broken-hyperlinks.py
├── test-broken-hyperlinks.tex
├── test-broken-outline.py
├── test-broken-outline.tex
├── test-crop-text.py
├── test-crop-text.tex
├── test-dpi-detection.jpeg.in
├── test-dpi-detection.py
├── test-dpi-detection.tex
├── test-duplicate-page-title.py
├── test-duplicate-page-title.tex
├── test-duplicate-pages.py
├── test-duplicate-pages.tex
├── test-empty-outline.py
├── test-empty-outline.tex
├── test-fg-colors-gm.py
├── test-fg-colors-gm.tex
├── test-fg-colors.py
├── test-fg-colors.tex
├── test-filter-text.py
├── test-filter-text.tex
├── test-hyperlinks.py
├── test-hyperlinks.tex
├── test-interpolation.png.in
├── test-interpolation.py
├── test-interpolation.tex
├── test-ja.py
├── test-ja.tex
├── test-jpeg2000.jp2
├── test-jpeg2000.py
├── test-jpeg2000.tex
├── test-labels-null.py
├── test-labels-null.tex
├── test-labels.py
├── test-labels.tex
├── test-miniexp-thread-safety.py
├── test-miniexp-thread-safety.tex
├── test-monochrome.jpeg.in
├── test-monochrome.py
├── test-monochrome.tex
├── test-multipage.py
├── test-multipage.tex
├── test-nfkc-apf.py
├── test-nfkc-apf.tex
├── test-nfkc.py
├── test-nfkc.tex
├── test-no-meta.py
├── test-no-meta.tex
├── test-nonascii.py
├── test-nonascii.tex
├── test-oom.py
├── test-oom.tex
├── test-outline.py
├── test-outline.tex
├── test-oversized-outline.py
├── test-oversized-outline.tex
├── test-overwrite.py
├── test-overwrite.tex
├── test-page-id.py
├── test-page-id.tex
├── test-rotated-page.jpeg.in
├── test-rotated-page.py
├── test-rotated-page.tex
├── test-solid-nonwhite-background.py
├── test-solid-nonwhite-background.tex
├── test-subsample.jpeg.in
├── test-subsample.py
├── test-subsample.tex
├── test-symbol.py
├── test-symbol.tex
├── test-title.py
├── test-title.tex
├── test-utf16-meta.py
├── test-utf16-meta.tex
├── test-vector-fg.py
├── test-vector-fg.tex
├── test-version.py
├── test-xmp-broken.py
├── test-xmp-broken.tex
├── test-xmp-mediatype.py
├── test-xmp-mediatype.tex
├── test-xmp-recreate.py
├── test-xmp-recreate.tex
└── tools.py
├── tools
├── build-manpage
├── generate-paths-hh
├── generate-po-template
├── install-manpages
├── install-mo
└── manpage.xsl
├── version.cc
├── version.hh
├── win32-version.rc
├── win32
├── Makefile
├── doc
│ ├── COPYING.fonts.txt
│ ├── COPYING.libs.txt
│ └── COPYING.poppler-data.txt
├── misc
│ ├── 30-urw-aliases.conf
│ └── dummy-mutex.hh
├── patches
│ ├── exiv2
│ │ ├── mutex.diff
│ │ └── series
│ ├── fontconfig
│ │ ├── disable-uuid-test.diff
│ │ ├── no-fc-templatedir.diff
│ │ ├── series
│ │ └── test-mkdir.diff
│ ├── graphicsmagick
│ │ ├── config-paths.diff
│ │ ├── no-gm-build.diff
│ │ ├── no-nt-feature.diff
│ │ └── series
│ ├── libjpeg
│ │ ├── automake-Wno-obsolete.diff
│ │ ├── basetsd.h-conflict.diff
│ │ └── series
│ ├── poppler
│ │ ├── disable-image-embedding.diff
│ │ ├── locale-open.diff
│ │ ├── mutex.diff
│ │ ├── poppler-data-path.diff
│ │ ├── series
│ │ └── strndup.diff
│ └── winiconv
│ │ ├── no-const.diff
│ │ └── series
└── tools
│ ├── enforce-relative-paths
│ └── wget
├── xmp.cc
└── xmp.hh
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | /aclocal.m4
3 | /autoconf.hh
4 | /autoconf.hh.in
5 | /autoconf.mk
6 | /autom4te.cache
7 | /config.cache
8 | /config.guess
9 | /config.log
10 | /config.rpath
11 | /config.status
12 | /config.sub
13 | /configure
14 | /dist
15 | /doc/*.1
16 | /doc/po/*.1
17 | /doc/po/*.pot
18 | /doc/po/*.xml
19 | /m4/*.m4
20 | /paths.hh
21 | /pdf2djvu
22 | /po/*.mo
23 | /po/*.pot
24 | /secret
25 | /tests/*.djvu
26 | /tests/*.jpeg
27 | /tests/*.log
28 | /tests/*.pdf
29 | /tests/*.png
30 | /tests/*.py[co]
31 | /tests/*.stamp
32 | /tests/__pycache__
33 | /tools/config.*
34 | /tools/install-sh
35 | /win32/bin
36 | /win32/src.tar
37 | /win32/dist
38 | /win32/etc
39 | /win32/include
40 | /win32/lib
41 | /win32/patches/*/*~
42 | /win32/share
43 | /win32/src
44 |
--------------------------------------------------------------------------------
/.mailmap:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright © 2007-2022 Jakub Wilk
2 | #
3 | # This file is part of pdf2djvu.
4 | #
5 | # pdf2djvu is free software; you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License version 2 as
7 | # published by the Free Software Foundation.
8 | #
9 | # pdf2djvu is distributed in the hope that it will be useful, but
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # General Public License for more details.
13 |
14 | srcdir = .
15 | include $(srcdir)/autoconf.mk
16 |
17 | exe = pdf2djvu$(EXEEXT)
18 |
19 | .PHONY: all
20 | all: $(exe)
21 |
22 | ifneq "$(WINDRES)" ""
23 | win32-version.o: win32-version.rc autoconf.hh
24 | $(WINDRES) -c 65001 -o $(@) $(<)
25 | $(exe): win32-version.o
26 | endif
27 |
28 | include Makefile.dep
29 |
30 | paths.hh: tools/generate-paths-hh
31 | $(<) $(foreach var,localedir djvulibre_bindir,$(var) $($(var)))
32 |
33 | $(exe): config.o
34 | $(exe): debug.o
35 | $(exe): djvu-outline.o
36 | $(exe): i18n.o
37 | $(exe): image-filter.o
38 | $(exe): main.o
39 | $(exe): pdf-backend.o
40 | $(exe): pdf-document-map.o
41 | $(exe): pdf-dpi.o
42 | $(exe): pdf-unicode.o
43 | $(exe): sexpr.o
44 | $(exe): string-format.o
45 | $(exe): string-printf.o
46 | $(exe): string-utils.o
47 | $(exe): sys-command-posix.o
48 | $(exe): sys-command-win32.o
49 | $(exe): sys-encoding.o
50 | $(exe): sys-time.o
51 | $(exe): sys-uuid.o
52 | $(exe): system.o
53 | $(exe): version.o
54 | $(exe): xmp.o
55 | $(exe):
56 | $(LINK.cc) $(^) $(LDLIBS) -o $(@)
57 |
58 | .PHONY: clean
59 | clean:
60 | rm -f $(exe) *.o paths.hh
61 | $(MAKE) -C tests/ clean
62 |
63 | .PHONY: distclean
64 | distclean: clean
65 | rm -f autoconf.hh autoconf.mk config.status config.log
66 |
67 | .PHONY: vcs-clean
68 | vcs-clean:
69 | $(MAKE) -C tests/ vcs-clean
70 | $(MAKE) -C po clean
71 | $(MAKE) -C doc clean
72 | $(MAKE) -C doc/po clean
73 | rm -rf autoconf.hh autoconf.hh.in config.log config.status configure
74 | rm -rf autom4te.cache
75 | rm -rf aclocal.m4 m4
76 | rm -f tools/config.* tools/install-sh
77 | $(MAKE) distclean
78 |
79 | .PHONY: test
80 | test: $(exe)
81 | $(MAKE) -C tests/
82 |
83 | .PHONY: test-installed
84 | test-installed: $(or $(shell command -v pdf2djvu;),$(bindir)/pdf2djvu)
85 | $(MAKE) -C tests/ pdf2djvu=$(exe)
86 |
87 | man_pages = $(wildcard doc/*.1 doc/po/*.1)
88 | mo_files = $(wildcard po/*.mo)
89 |
90 | .PHONY: install
91 | install: all
92 | $(INSTALL) -d $(DESTDIR)$(bindir)
93 | $(INSTALL) $(exe) $(DESTDIR)$(bindir)
94 | INSTALL='$(INSTALL)' tools/install-manpages $(DESTDIR)$(mandir) $(man_pages)
95 | INSTALL='$(INSTALL)' tools/install-mo $(DESTDIR)$(localedir) $(mo_files)
96 |
97 | .error = GNU make is required
98 |
99 | # vim:ts=4 sts=4 sw=4 noet
100 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | doc/README
--------------------------------------------------------------------------------
/autoconf.mk.in:
--------------------------------------------------------------------------------
1 | # Package information:
2 | PACKAGE_VERSION = @PACKAGE_VERSION@
3 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
4 |
5 | # Paths:
6 | prefix = @prefix@
7 | exec_prefix = @exec_prefix@
8 | bindir = @bindir@
9 | datarootdir = @datarootdir@
10 | mandir = @mandir@
11 | localedir = @localedir@
12 | djvulibre_bindir = @djvulibre_bindir@
13 |
14 | # Compiler, etc.:
15 | CXX = @CXX@
16 | CXXFLAGS = @OPENMP_CXXFLAGS@ @CXXFLAGS@ @DJVULIBRE_CFLAGS@ @POPPLER_CFLAGS@ @GRAPHICSMAGICK_CFLAGS@ @XMP_CFLAGS@
17 | CPPFLAGS = @CPPFLAGS@
18 | LDFLAGS = @LDFLAGS@
19 | LDLIBS = @DJVULIBRE_LIBS@ @POPPLER_LIBS@ @GRAPHICSMAGICK_LIBS@ @LIBINTL@ @LIBICONV@ @XMP_LIBS@ @TCMALLOC_LIBS@ @LIBS@
20 | EXEEXT = @EXEEXT@
21 |
22 | # Utilities:
23 | INSTALL = @INSTALL@
24 | WINDRES = @WINDRES@
25 | MSGMERGE = @MSGMERGE@
26 | MSGFMT = @MSGFMT@
27 | XGETTEXT_HELPER = $(srcdir)/tools/generate-po-template
28 | XGETTEXT = $(XGETTEXT_HELPER) @XGETTEXT@
29 |
30 |
--------------------------------------------------------------------------------
/const-adapter.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2015-2022 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | template
16 | class const_adapter
17 | {
18 | protected:
19 | ConstT x;
20 | public:
21 | explicit const_adapter(ConstT x)
22 | : x(x)
23 | { }
24 | operator T () const
25 | {
26 | return const_cast(x);
27 | }
28 | operator ConstT () const
29 | {
30 | return x;
31 | }
32 | };
33 |
34 | // vim:ts=4 sts=4 sw=4 et
35 |
--------------------------------------------------------------------------------
/debug.cc:
--------------------------------------------------------------------------------
1 | /* Copyright © 2007-2016 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #include "debug.hh"
16 |
17 | #include
18 |
19 | class DevNull : public std::ostream
20 | {
21 | public:
22 | DevNull()
23 | : std::ostream(nullptr)
24 | { }
25 | };
26 |
27 | static DevNull static_dev_null;
28 | std::ostream &dev_null = static_dev_null;
29 |
30 | DebugStream error_log(std::cerr);
31 | static DebugStream null_debug(dev_null);
32 | static DebugStream full_debug(std::clog);
33 |
34 | DebugStream &debug(int n, int threshold)
35 | {
36 | if (n <= threshold)
37 | return full_debug;
38 | else
39 | return null_debug;
40 | }
41 |
42 | void DebugStream::indent()
43 | {
44 | unsigned int level = this->level;
45 | if (level > 0)
46 | {
47 | while (level-- > 1)
48 | this->ostream << " ";
49 | this->ostream << "- ";
50 | }
51 | }
52 |
53 | DebugStream &operator<<(DebugStream &stream, std::ostream& (*pf)(std::ostream&))
54 | {
55 | if (pf == static_cast(std::endl))
56 | stream.started = false;
57 | stream.ostream << pf;
58 | return stream;
59 | }
60 |
61 | // vim:ts=2 sts=2 sw=2 et
62 |
--------------------------------------------------------------------------------
/debug.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2007-2015 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_DEBUG_H
16 | #define PDF2DJVU_DEBUG_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include "system.hh"
24 |
25 | class DebugStream;
26 |
27 | template
28 | static inline DebugStream &operator<<(DebugStream &, const tp &);
29 |
30 | class DebugStream
31 | {
32 | protected:
33 | unsigned int level;
34 | bool started;
35 | std::ostream &ostream;
36 | void indent();
37 | public:
38 | explicit DebugStream(std::ostream &ostream)
39 | : level(0), started(false), ostream(ostream)
40 | { }
41 | void operator ++(int) { this->level++; }
42 | void operator --(int) { this->level--; }
43 | template
44 | friend DebugStream &operator<<(DebugStream &, const tp &);
45 | friend DebugStream &operator<<(DebugStream &stream, std::ostream& (*)(std::ostream&));
46 | };
47 |
48 | DebugStream &debug(int n, int threshold);
49 | extern DebugStream error_log;
50 |
51 | extern std::ostream &dev_null;
52 |
53 | static inline std::ostream &operator<<(std::ostream &stream, const std::runtime_error &error)
54 | {
55 | stream << error.what();
56 | return stream;
57 | }
58 |
59 | template
60 | static inline DebugStream &operator<<(DebugStream &stream, const tp &object)
61 | {
62 | if (!stream.started)
63 | {
64 | stream.indent();
65 | stream.started = true;
66 | }
67 | std::ostringstream buffer;
68 | buffer.copyfmt(stream.ostream);
69 | buffer << object;
70 | std::string string = buffer.str();
71 | stream.ostream << encoding::proxy(string);
72 | return stream;
73 | }
74 |
75 | #endif
76 |
77 | // vim:ts=2 sts=2 sw=2 et
78 |
--------------------------------------------------------------------------------
/djvu-const.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2007-2019 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_DJVU_CONST_H
16 | #define PDF2DJVU_DJVU_CONST_H
17 |
18 | namespace djvu
19 | {
20 | static const int min_dpi = 72;
21 | static const int max_dpi = 6000;
22 | /* ``djvumake`` used to require dpi ≥ 72.
23 | * The library itself enforces dpi ≤ 6000.
24 | *
25 | * See https://sourceforge.net/p/djvu/bugs/103/ for details.
26 | */
27 |
28 | static const int max_fg_colors = 4080;
29 |
30 | static const int max_subsample_ratio = 12;
31 |
32 | static const char shared_ant_file_name[] = "shared_anno.iff";
33 |
34 | }
35 |
36 | #endif
37 |
38 | // vim:ts=2 sts=2 sw=2 et
39 |
--------------------------------------------------------------------------------
/djvu-outline.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2015-2022 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_DJVU_OUTLINE_H
16 | #define PDF2DJVU_DJVU_OUTLINE_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | namespace djvu
25 | {
26 |
27 | class OutlineError
28 | : public std::runtime_error
29 | {
30 | public:
31 | OutlineError();
32 | };
33 |
34 | class OutlineItem;
35 |
36 | class OutlineBase
37 | {
38 | public:
39 | virtual OutlineItem& add(std::string description, std::string url) = 0;
40 | OutlineBase() = default;
41 | OutlineBase(const OutlineBase &) = default;
42 | virtual ~OutlineBase()
43 | { }
44 | };
45 |
46 | class OutlineItem
47 | : public OutlineBase
48 | {
49 | public:
50 | OutlineItem(const std::string &description, const std::string &url)
51 | : description(description),
52 | url(url)
53 | { }
54 | OutlineItem& add(std::string description, std::string url);
55 | private:
56 | std::vector children;
57 | std::string description;
58 | std::string url;
59 | size_t size() const;
60 | friend std::ostream &operator<<(std::ostream &, const OutlineItem &);
61 | friend class Outline;
62 | };
63 |
64 | class Outline
65 | : public OutlineBase
66 | {
67 | private:
68 | std::vector items;
69 | size_t size() const;
70 | public:
71 | OutlineItem& add(std::string description, std::string url);
72 | operator bool() const;
73 | friend std::ostream &operator<<(std::ostream &, const Outline &);
74 | };
75 |
76 | std::ostream &operator<<(std::ostream &, const OutlineItem &);
77 | std::ostream &operator<<(std::ostream &, const Outline &);
78 |
79 | }
80 |
81 | #endif
82 |
83 | // vim:ts=4 sts=4 sw=4 et
84 |
--------------------------------------------------------------------------------
/doc/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright © 2007-2018 Jakub Wilk
2 | #
3 | # This file is part of pdf2djvu.
4 | #
5 | # pdf2djvu is free software; you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License version 2 as
7 | # published by the Free Software Foundation.
8 | #
9 | # pdf2djvu is distributed in the hope that it will be useful, but
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # General Public License for more details.
13 |
14 | srcdir = ..
15 |
16 | .PHONY: all
17 | all: pdf2djvu.1
18 |
19 | pdf2djvu.1: manpage.xml
20 | $(srcdir)/tools/build-manpage $(<) $(@)
21 |
22 | .PHONY: check
23 | check: check-docbook
24 |
25 | .PHONY: check-docbook
26 | check-docbook: manpage.xml
27 | xmllint --nonet --noout --valid $(<)
28 |
29 | .PHONY: clean
30 | clean:
31 | rm -f *.1
32 |
33 | .error = GNU make is required
34 |
35 | # vim:ts=4 sts=4 sw=4 noet
36 |
--------------------------------------------------------------------------------
/doc/README:
--------------------------------------------------------------------------------
1 | Overview
2 | ========
3 |
4 | **pdf2djvu** creates DjVu_ files from PDF files.
5 |
6 | It's able to extract:
7 |
8 | - graphics,
9 | - text layer,
10 | - hyperlinks,
11 | - document outline (bookmarks),
12 | - metadata (including XMP_ metadata).
13 |
14 | pdf2djvu is developed primarily for Unix-like systems,
15 | but a Windows distribution is available too.
16 |
17 | .. _DjVu:
18 | http://djvu.org/
19 | .. _XMP:
20 | https://www.adobe.com/products/xmp.html
21 |
22 | Prerequisites
23 | =============
24 |
25 | The following software is required to build pdf2djvu:
26 |
27 | * C++11 compiler;
28 | * GNU make;
29 | * DjVuLibre_ (≥ 3.5.25), both the library and the command line tools;
30 | * Poppler_ (≥ 0.62), including xpdf headers;
31 | * pkg-config_.
32 |
33 | The following software is recommended:
34 |
35 | * gettext_ for internationalization;
36 | * Exiv2_ (≥ 0.21) and libuuid (part of util-linux or e2fsprogs)
37 | for correctly dealing with XMP metadata;
38 | * GraphicsMagick_ for the ``--fg-colors=N`` option.
39 |
40 | For the ``-j``/``--jobs`` option, the compiler must support OpenMP_.
41 |
42 | To run the tests, the following software is needed:
43 |
44 | * Python 2.7;
45 | * nose_.
46 |
47 | To correctly convert some PDF files (mostly in Chinese, Japanese or
48 | Korean), the poppler-data_ package must be installed.
49 |
50 | .. ---------------------------------------------------------------------
51 |
52 | .. _DjVuLibre:
53 | https://djvu.sourceforge.net/
54 | .. _poppler:
55 | https://poppler.freedesktop.org/
56 | .. _pkg-config:
57 | https://www.freedesktop.org/wiki/Software/pkg-config/
58 | .. _gettext:
59 | https://www.gnu.org/software/gettext/
60 | .. _Exiv2:
61 | https://www.exiv2.org/
62 | .. _GraphicsMagick:
63 | http://www.graphicsmagick.org/
64 | .. _OpenMP:
65 | https://www.openmp.org/
66 | .. _nose:
67 | https://nose.readthedocs.io/
68 | .. _poppler-data:
69 | https://poppler.freedesktop.org/poppler-data-0.4.9.tar.gz
70 |
71 | .. vim:ft=rst ts=3 sts=3 sw=3 et tw=72
72 |
--------------------------------------------------------------------------------
/doc/credits:
--------------------------------------------------------------------------------
1 | pdf2djvu was supported by the Polish Ministry of Science
2 | and Higher Education's grant no. N N519 384036 (2009–2012,
3 | https://bitbucket.org/jsbien/ndt).
4 |
--------------------------------------------------------------------------------
/doc/djvudigital:
--------------------------------------------------------------------------------
1 | pdf2djvu vs djvudigital
2 | =======================
3 |
4 | djvudigital, a part of DjVuLibre_, is another PDF to DjVu converter.
5 | The list below outlines some differences between the converters.
6 |
7 | Superiorities of djvudigital
8 | ----------------------------
9 |
10 | - djvudigital uses a `sophisticated layer separation algorithm`_.
11 | pdf2djvu uses a simple one.
12 |
13 | - djvudigital is typically much faster than pdf2djvu.
14 |
15 | - djvudigital can convert PostScript files, too.
16 |
17 | Superiorities of pdf2djvu
18 | -------------------------
19 |
20 | - djvudigital internally relies on a `Ghostscript driver`_, which has a
21 | license incompatibility issue. pdf2djvu is not affected by any
22 | license problem.
23 |
24 | - djvudigital cannot extract hidden text.
25 |
26 | - djvudigital cannot extract document metadata.
27 |
28 | - For some documents, djvudigital cannot extract document outline.
29 | See the `bug report`_ for details.
30 |
31 | - djvudigital cannot produce indirect multi-page document by itself.
32 |
33 | - djvudigital always uses lossless compression for monochrome images.
34 |
35 | - With djvudigital, there is no obvious way to convert only some pages
36 | of a document.
37 |
38 | - With djvudigital, there is no way to customize page identifiers.
39 |
40 |
41 | .. _DjVuLibre:
42 | https://djvu.sourceforge.net/
43 |
44 | .. _sophisticated layer separation algorithm:
45 | https://leon.bottou.org/papers/bottou-2001
46 |
47 | .. _Ghostscript driver:
48 | https://djvu.sourceforge.net/gsdjvu.html
49 |
50 | .. _bug report:
51 | https://sourceforge.net/p/djvu/bugs/109/
52 |
53 | .. vim:ft=rst ts=3 sts=3 sw=3 et tw=72
54 |
--------------------------------------------------------------------------------
/doc/po/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright © 2009-2018 Jakub Wilk
2 | #
3 | # This file is part of pdf2djvu.
4 | #
5 | # pdf2djvu is free software; you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License version 2 as
7 | # published by the Free Software Foundation.
8 | #
9 | # pdf2djvu is distributed in the hope that it will be useful, but
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # General Public License for more details.
13 |
14 | srcdir = ../..
15 | include $(srcdir)/autoconf.mk
16 |
17 | po4a-common-options = \
18 | --format=docbook
19 |
20 | po4a-getext-options = \
21 | $(po4a-common-options) \
22 | --master-charset=UTF-8 \
23 | --package-name=pdf2djvu \
24 | --package-version=$(PACKAGE_VERSION) \
25 | --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
26 | --copyright-holder="Jakub Wilk "
27 |
28 | msgmerge_opts = \
29 | --no-location \
30 | --no-wrap \
31 |
32 | ifneq "$(wildcard $(srcdir)/.hg/)" ""
33 | msgmerge_opts += --backup=off
34 | endif
35 |
36 | po4a-update-po = po4a-updatepo \
37 | $(po4a-getext-options) \
38 | --msgmerge-opt="$(msgmerge_opts)"
39 |
40 | po4a-translate = po4a-translate \
41 | $(po4a-common-options)
42 |
43 | source = ../manpage.xml
44 | po_files = $(wildcard *.po)
45 | langs = $(po_files:.po=)
46 | xml_files = $(addsuffix .xml,$(langs))
47 | man_files = $(addsuffix .1,$(addprefix pdf2djvu.,$(langs)))
48 |
49 | .PHONY: all
50 | all: $(man_files)
51 |
52 | pdf2djvu.%.1: %.xml
53 | ! [ -s $(<) ] || $(srcdir)/tools/build-manpage -l $(<) $(@)
54 |
55 | .PHONY: xml
56 | xml: $(xml_files)
57 |
58 | manpage.pot: $(source)
59 | rm -f $(@)
60 | $(po4a-update-po) -m $(<) -p $(@)
61 | perl -pi -e 's/^([#][.])\s*(\S.*\S)\s*$$/$$1 $$2\n/' $(@)
62 |
63 | $(po_files): %.po: $(source)
64 | $(po4a-update-po) -m $(<) -p $(@)
65 | perl -pi -e 's/^([#][.])\s*(\S.*\S)\s*$$/$$1 $$2\n/' $(@)
66 | touch $(@)
67 |
68 | %.xml: %.po
69 | $(po4a-translate) -k 100 -m $(source) -p $(<) -l $(@)
70 |
71 | .PHONY: check
72 | check: $(po_files)
73 | $(srcdir)/private/check-po $(^)
74 |
75 | .PHONY: clean
76 | clean:
77 | rm -f *.1 *.xml *.pot
78 |
79 | .error = GNU make is required
80 |
81 | # vim:ts=4 sts=4 sw=4 noet
82 |
--------------------------------------------------------------------------------
/i18n.cc:
--------------------------------------------------------------------------------
1 | /* Copyright © 2009-2015 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #include "i18n.hh"
16 |
17 | #include
18 | #include
19 |
20 | #include "paths.hh"
21 | #include "system.hh"
22 |
23 | #if ENABLE_NLS
24 |
25 | void i18n::setup_locale()
26 | {
27 | std::setlocale(LC_ALL, "");
28 | /* Deliberately ignore errors. */
29 | }
30 |
31 | void i18n::setup()
32 | {
33 | #if WIN32
34 | std::string basedir(program_dir);
35 | #else
36 | std::string basedir("/");
37 | #endif
38 | std::string localedir = absolute_path(paths::localedir, basedir);
39 | i18n::setup_locale();
40 | bindtextdomain(PACKAGE_NAME, localedir.c_str());
41 | /* Deliberately ignore errors. */
42 | textdomain(PACKAGE_NAME);
43 | /* Deliberately ignore errors. */
44 | }
45 |
46 | #else
47 |
48 | void i18n::setup_locale()
49 | {
50 | std::setlocale(LC_CTYPE, "");
51 | /* Deliberately ignore errors. */
52 | }
53 |
54 | void i18n::setup()
55 | {
56 | i18n::setup_locale();
57 | }
58 |
59 | #endif
60 |
61 | // vim:ts=2 sts=2 sw=2 et
62 |
--------------------------------------------------------------------------------
/i18n.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2009-2015 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_I18N
16 | #define PDF2DJVU_I18N
17 |
18 | #include "autoconf.hh"
19 |
20 | namespace i18n
21 | {
22 |
23 | void setup_locale();
24 | void setup();
25 | }
26 |
27 | static inline void N_(const char *message_id)
28 | {
29 | return;
30 | }
31 |
32 | #ifdef ENABLE_NLS
33 |
34 | #include
35 |
36 | static inline const char * _(const char *message_id)
37 | {
38 | return gettext(message_id);
39 | }
40 |
41 | #else
42 |
43 | static inline const char * ngettext(const char *message_id, const char *message_id_plural, unsigned long int n)
44 | {
45 | return n == 1 ? message_id : message_id_plural;
46 | }
47 |
48 | static inline const char * _(const char *message_id)
49 | {
50 | return message_id;
51 | }
52 |
53 | #endif
54 |
55 | #endif
56 |
57 | // vim:ts=2 sts=2 sw=2 et
58 |
--------------------------------------------------------------------------------
/pdf-document-map.cc:
--------------------------------------------------------------------------------
1 | /* Copyright © 2015-2016 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #include "pdf-document-map.hh"
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | #include "autoconf.hh"
23 | #include "pdf-backend.hh"
24 | #include "pdf-unicode.hh"
25 |
26 | pdf::DocumentMap::DocumentMap(const std::vector &paths)
27 | : paths(paths)
28 | {
29 | int global_index = 0;
30 | this->byte_size = 0;
31 | for (const char *path : paths)
32 | {
33 | this->indices.push_back(global_index);
34 | {
35 | std::ifstream ifs(path, std::ifstream::in | std::ifstream::binary);
36 | ifs.seekg(0, std::ios::end);
37 | this->byte_size += ifs.tellg();
38 | ifs.close();
39 | }
40 | {
41 | std::unique_ptr doc(new pdf::Document(path));
42 | pdf::Catalog *catalog = doc->getCatalog();
43 | for (int i = 0; i < doc->getNumPages(); i++) {
44 | pdf::String s;
45 | if (catalog->indexToLabel(i, &s)) {
46 | std::string str = pdf::string_as_utf8(&s);
47 | this->labels.push_back(str);
48 | }
49 | else
50 | this->labels.push_back("");
51 | global_index++;
52 | }
53 | }
54 | }
55 | this->indices.push_back(global_index);
56 | }
57 |
58 | pdf::PageInfo pdf::DocumentMap::get(int global_pageno)
59 | {
60 | int global_index = global_pageno - 1;
61 | size_t doc_index = std::upper_bound(
62 | this->indices.begin(),
63 | this->indices.end(),
64 | global_index
65 | ) - this->indices.begin() - 1;
66 | return pdf::PageInfo(
67 | global_index + 1,
68 | /* path = */ this->paths.at(doc_index),
69 | /* local_index = */ global_pageno - this->indices.at(doc_index),
70 | /* label = */ this->labels.at(global_index)
71 | );
72 | }
73 |
74 | // vim:ts=4 sts=4 sw=4 et
75 |
--------------------------------------------------------------------------------
/pdf-document-map.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2015-2022 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_PDF_DOCUMENT_MAP_HH
16 | #define PDF2DJVU_PDF_DOCUMENT_MAP_HH
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | namespace pdf
23 | {
24 |
25 | class PageInfo
26 | {
27 | public:
28 | const int global_pageno;
29 | const char *path;
30 | const int local_pageno;
31 | const std::string &label;
32 | PageInfo(int global_pageno, const char *path, int local_pageno, const std::string &label)
33 | : global_pageno(global_pageno),
34 | path(path),
35 | local_pageno(local_pageno),
36 | label(label)
37 | { }
38 | };
39 |
40 | class DocumentMap
41 | {
42 | protected:
43 | intmax_t byte_size;
44 | const std::vector &paths;
45 | std::vector labels;
46 | std::vector indices;
47 | public:
48 | explicit DocumentMap(const std::vector &paths);
49 | intmax_t get_byte_size()
50 | {
51 | return this->byte_size;
52 | }
53 | int get_n_pages()
54 | {
55 | return this->indices.back();
56 | }
57 | PageInfo get(int global_index);
58 | };
59 |
60 | }
61 |
62 | #endif
63 |
64 | // vim:ts=4 sts=4 sw=4 et
65 |
--------------------------------------------------------------------------------
/pdf-dpi.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2009-2015 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_PDF_DPI_H
16 | #define PDF2DJVU_PDF_DPI_H
17 |
18 | #include "pdf-backend.hh"
19 | #include
20 |
21 | namespace pdf
22 | {
23 | namespace dpi
24 | {
25 |
26 | class Guess
27 | {
28 | protected:
29 | double min_, max_;
30 | public:
31 | explicit Guess(double min, double max)
32 | : min_(min), max_(max)
33 | { }
34 | double min() const { return this->min_; }
35 | double max() const { return this->max_; }
36 | };
37 |
38 | class NoGuess
39 | { };
40 |
41 | class Guesser
42 | {
43 | protected:
44 | void *magic;
45 | pdf::Document &document;
46 | public:
47 | explicit Guesser(pdf::Document &document);
48 | ~Guesser();
49 | Guess operator[](int n);
50 | };
51 |
52 | }
53 |
54 | }
55 |
56 | static inline std::ostream & operator <<(std::ostream &stream, const pdf::dpi::Guess &guess)
57 | {
58 | stream << guess.min();
59 | if (guess.min() < guess.max())
60 | stream << ".." << guess.max();
61 | return stream;
62 | }
63 |
64 | #endif
65 |
66 | // vim:ts=2 sts=2 sw=2 et
67 |
--------------------------------------------------------------------------------
/pdf-unicode.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2007-2019 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_PDF_UNICODE_H
16 | #define PDF2DJVU_PDF_UNICODE_H
17 |
18 | #include
19 | #include
20 |
21 | #include
22 |
23 | #include "pdf-backend.hh"
24 |
25 | namespace pdf
26 | {
27 |
28 | /* Unicode → UTF-8 conversion
29 | * ==========================
30 | */
31 |
32 | void write_as_utf8(std::ostream &stream, Unicode unicode_char);
33 |
34 | std::string string_as_utf8(const pdf::String *);
35 | std::string string_as_utf8(pdf::Object &);
36 |
37 | /* class pdf::NFKC
38 | * ===============
39 | */
40 |
41 | class NFKC
42 | {
43 | public:
44 | virtual int length() const = 0;
45 | virtual operator const Unicode*() const = 0;
46 | virtual ~NFKC()
47 | { }
48 | };
49 |
50 |
51 | /* class pdf::FullNFKC
52 | * ===================
53 | */
54 |
55 | class FullNFKC : public NFKC
56 | {
57 | protected:
58 | Unicode* data;
59 | int length_;
60 | public:
61 | explicit FullNFKC(const Unicode *, int length);
62 | ~FullNFKC();
63 | int length() const
64 | {
65 | return this->length_;
66 | }
67 | operator const Unicode*() const
68 | {
69 | return this->data;
70 | }
71 | };
72 |
73 | /* class pdf::MinimalNFKC
74 | * ======================
75 | */
76 |
77 | class MinimalNFKC : public NFKC
78 | {
79 | protected:
80 | std::basic_string string;
81 | public:
82 | explicit MinimalNFKC(const Unicode *, int length);
83 | int length() const;
84 | operator const Unicode*() const;
85 | };
86 | }
87 |
88 | #endif
89 |
90 | // vim:ts=4 sts=4 sw=4 et
91 |
--------------------------------------------------------------------------------
/po/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright © 2009-2018 Jakub Wilk
2 | #
3 | # This file is part of pdf2djvu.
4 | #
5 | # pdf2djvu is free software; you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License version 2 as
7 | # published by the Free Software Foundation.
8 | #
9 | # pdf2djvu is distributed in the hope that it will be useful, but
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # General Public License for more details.
13 |
14 | srcdir = ..
15 | include $(srcdir)/autoconf.mk
16 |
17 | po_files = $(wildcard *.po)
18 | mo_files = $(po_files:.po=.mo)
19 | source_files = $(wildcard $(srcdir)/*.cc $(srcdir)/*.hh)
20 |
21 | gettext-common-options = \
22 | --add-location=file \
23 | --sort-output \
24 | --no-wrap \
25 |
26 | xgettext = $(XGETTEXT) \
27 | $(gettext-common-options) \
28 | --from-code=UTF-8 \
29 | --language=C++ \
30 | --keyword=_ --keyword=N_ \
31 | --package-name=pdf2djvu \
32 | --package-version=$(PACKAGE_VERSION) \
33 | --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
34 | --add-comments=L10N: \
35 |
36 | msgmerge = $(MSGMERGE) \
37 | $(gettext-common-options) \
38 | --update \
39 | --verbose \
40 |
41 | ifneq "$(wildcard $(srcdir)/.hg/)" ""
42 | msgmerge += --backup=off
43 | endif
44 |
45 | msgfmt = $(MSGFMT) \
46 | --check \
47 | --verbose \
48 |
49 | .PHONY: all
50 | all: pdf2djvu.pot $(po_files) $(mo_files)
51 |
52 | pdf2djvu.pot: $(XGETTEXT_HELPER) $(source_files)
53 | $(xgettext) -D $(srcdir) $(sort $(notdir $(source_files))) > $(@)
54 |
55 | %.po: pdf2djvu.pot
56 | $(msgmerge) $(@) $(<)
57 | touch $(@)
58 |
59 | %.mo: %.po
60 | $(msgfmt) -o $(@) -c $(<)
61 |
62 | .PHONY: check
63 | check: $(po_files)
64 | $(srcdir)/private/check-po $(^)
65 |
66 | .PHONY: clean
67 | clean:
68 | rm -f *.mo pdf2djvu.pot
69 |
70 | .error = GNU make is required
71 |
72 | # vim:ts=4 sts=4 sw=4 noet
73 |
--------------------------------------------------------------------------------
/private/announce-release:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Copyright © 2016-2018 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | set -e -u
17 |
18 | export LC_ALL=C
19 |
20 | usage()
21 | {
22 | printf '%s [--no-changes]\n' "$0"
23 | }
24 |
25 | args=$(getopt -n "$0" -o 'h' --long 'help,no-changes' -- "$@") || {
26 | usage >&2
27 | exit 1
28 | }
29 | opt_changes=y
30 | eval set -- "$args"
31 | while true
32 | do
33 | case "$1" in
34 | -h|--help) usage; exit 0;;
35 | --no-changes) opt_changes=; shift;;
36 | --) shift; break;;
37 | *) printf '%s: internal error (%s)\n' "$0" "$1" >&2; exit 1;;
38 | esac
39 | done
40 |
41 | version=$(grep -m1 '^[^ ].*) [a-z]' doc/changelog | cut -d' ' -f2 | tr -d '()')
42 |
43 | if [ -n "$opt_changes" ]
44 | then
45 | changes=$'The most important end-user visible changes are:\n\n...'
46 | else
47 | changes='There are no end-user visible changes at this time.'
48 | fi
49 |
50 | base_url=https://github.com/jwilk/pdf2djvu
51 |
52 | cat <
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | pkgs_base='
17 | build-essential
18 | djvulibre-bin
19 | libdjvulibre-dev
20 | libexiv2-dev
21 | libgraphicsmagick++-dev
22 | libpoppler-dev
23 | libpoppler-private-dev
24 | pkg-config
25 | uuid-dev
26 | '
27 | pkgs_autotools='
28 | autoconf
29 | automake
30 | gettext
31 | libtool
32 | '
33 | pkgs_tests='
34 | python-nose
35 | '
36 | pkgs_prepare_tests='
37 | fonts-linuxlibertine
38 | python-pil
39 | texlive-fonts-recommended
40 | texlive-luatex
41 | '
42 | pkgs_man='
43 | docbook-xml
44 | docbook-xsl
45 | gettext
46 | libxml2-utils
47 | po4a
48 | xsltproc
49 | '
50 | pkgs="$pkgs_base"
51 |
52 | usage()
53 | {
54 | printf '%s [--vcs] [--tests] [--man]\n' "$0"
55 | }
56 |
57 | args=$(getopt -n "$0" -o 'h' --long 'help,vcs,man,tests' -- "$@")
58 | if [ $? -ne 0 ]
59 | then
60 | usage >&2
61 | exit 1
62 | fi
63 | opt_vcs=
64 | opt_tests=
65 | opt_man=
66 | eval set -- "$args"
67 | while true
68 | do
69 | case "$1" in
70 | -h|--help) usage; exit 0;;
71 | --vcs) opt_vcs=y; shift;;
72 | --tests) opt_tests=y ; shift;;
73 | --man) opt_man=y; shift;;
74 | --) shift; break;;
75 | *) printf '%s: internal error (%s)\n' "$0" "$1" >&2; exit 1;;
76 | esac
77 | done
78 |
79 | set -e -u
80 |
81 | [ "$opt_tests" ] && pkgs="$pkgs $pkgs_tests"
82 | [ "$opt_vcs" ] && pkgs="$pkgs $pkgs_autotools"
83 | [ "$opt_vcs" ] && [ "$opt_tests" ] && pkgs="$pkgs $pkgs_prepare_tests"
84 | [ "$opt_man" ] && pkgs="$pkgs $pkgs_man"
85 |
86 | PS4='# '
87 | (
88 | set -x
89 | apt-get install --no-install-recommends $pkgs
90 | )
91 |
92 | # vim:ts=4 sts=4 sw=4 et
93 |
--------------------------------------------------------------------------------
/private/autoclean:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e -u
3 | rm -rf *.cache
4 | rm -rf m4 aclocal.m4
5 | rm -f autoconf.hh.in
6 | rm -f configure
7 | cd tools
8 | rm -f config.guess config.sub config.rpath
9 | rm -f install-sh
10 |
--------------------------------------------------------------------------------
/private/autogen:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e -u
3 | stat configure.ac > /dev/null
4 | PS4='$ '
5 | set -x
6 | for lt_dir in /usr/local/share/libtool /usr/share/libtool
7 | do
8 | for subdir in config build-aux
9 | do
10 | build_aux="$lt_dir/$subdir"
11 | [ -d "$build_aux" ] && break 2
12 | done
13 | done
14 | for file in install-sh config.sub config.guess
15 | do
16 | rm -f tools/$file
17 | cp "$build_aux/$file" tools/
18 | done
19 | rm -f tools/config.rpath
20 | for gettext_dir in /usr/local/share/gettext /usr/share/gettext
21 | do
22 | [ -d "$gettext_dir" ] && break
23 | done
24 | cp "$gettext_dir/config.rpath" tools/
25 | mkdir -p m4
26 | ${ACLOCAL:-aclocal} -I m4 --install
27 | ${AUTOCONF:-autoconf}
28 | ${AUTOHEADER:-autoheader}
29 |
30 | # vim:ts=4 sts=4 sw=4 et
31 |
--------------------------------------------------------------------------------
/private/check-po:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2015-2018 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | color()
17 | {
18 | sed -e 's/^/ /' \
19 | | grep --color=auto '.*'
20 | }
21 |
22 | color_msgid()
23 | {
24 | sed -n -e '/^msgid/ { s/^/ /; p }' \
25 | | grep --color=auto ' "[^"].*'
26 | }
27 |
28 | set -e -u
29 | rc=0
30 | if [ $# -eq 0 ]
31 | then
32 | printf 'Usage: %s ...\n' "$0" >&2
33 | exit 1
34 | fi
35 | for po in "$@"
36 | do
37 | ok=yes
38 | m=$(msgfmt --check -o /dev/null "$po" 2>&1 || true)
39 | if [ -n "$m" ]
40 | then
41 | [ -z "$ok" ] || printf '%s:\n' "$po"
42 | printf '%s:\n' '- errors from msgfmt --check'
43 | printf '%s' "$m" | color
44 | ok=
45 | fi
46 | if command -v i18nspector > /dev/null
47 | then
48 | m=$(i18nspector "$po")
49 | if [ -n "$m" ]
50 | then
51 | [ -z "$ok" ] || printf '%s:\n' "$po"
52 | printf '%s:\n' '- warnings from i18nspector'
53 | printf '%s' "$m" | color
54 | ok=
55 | fi
56 | fi
57 | m=$(msgattrib --no-wrap --only-fuzzy "$po")
58 | if [ -n "$m" ]
59 | then
60 | [ -z "$ok" ] || printf '%s:\n' "$po"
61 | printf '%s:\n' '- fuzzy messages'
62 | printf '%s' "$m" | color_msgid
63 | ok=
64 | fi
65 | m=$(msgattrib --no-wrap --untranslated "$po")
66 | if [ -n "$m" ]
67 | then
68 | [ -z "$ok" ] || printf '%s:\n' "$po"
69 | printf '%s:\n' '- untranslated messages'
70 | printf '%s' "$m" | color_msgid
71 | ok=
72 | fi
73 | if [ -z "$ok" ]
74 | then
75 | printf '\n'
76 | rc=1
77 | fi
78 | done
79 | exit $rc
80 |
81 | # vim:ts=4 sts=4 sw=4 et
82 |
--------------------------------------------------------------------------------
/private/check-rst:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2016-2022 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | here=${0%/*}
17 | here=${here#./}
18 | root="$here/../"
19 | root=${root#private/../}
20 | rst2xml=$(command -v rst2xml) \
21 | || rst2xml=$(command -v rst2xml.py) \
22 | || { printf 'rst2xml not found\n' >&2; exit 1; }
23 | rst2xml=${rst2xml##*/}
24 | options='--input-encoding=UTF-8 --strict'
25 | if [ $# -eq 0 ]
26 | then
27 | grep -r -w -l 'ft[=]rst' "${root:-.}"
28 | else
29 | printf '%s\n' "$@"
30 | fi |
31 | xargs -t -I{} "$rst2xml" $options {} /dev/null
32 |
33 | # vim:ts=4 sts=4 sw=4 et
34 |
--------------------------------------------------------------------------------
/private/clang-tidy:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2015-2016 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | srcdir=$(dirname "$0")/..
17 | cxxflags=$(
18 | grep '^CXXFLAGS\s=' "$srcdir/autoconf.mk" \
19 | | grep -E -o -- '-I\S+'
20 | )
21 | PS4='$ '
22 | (
23 | set -x
24 | clang-tidy "$@" -- -std=gnu++11 $cxxflags
25 | )
26 |
27 | # vim:ts=4 sts=4 sw=4 et
28 |
--------------------------------------------------------------------------------
/private/cppcheck:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2018-2022 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | here=${0%/*}
17 | here=${here#./}
18 | root="$here/../"
19 | root=${root#private/../}
20 |
21 | if [ $# -eq 0 ]
22 | then
23 | set -- "${root:-.}/"*.cc
24 | fi
25 |
26 | exec cppcheck \
27 | --enable=warning \
28 | --error-exitcode=1 \
29 | --suppress='uninitvar:sys-encoding.cc:143' \
30 | --suppress='syntaxError:string-format.cc:211' \
31 | "$@"
32 |
33 | # vim:ts=4 sts=4 sw=4 et
34 |
--------------------------------------------------------------------------------
/private/iwyu:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2015 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | srcdir=$(dirname "$0")/..
17 | cxxflags=$(
18 | grep '^CXXFLAGS\s=' "$srcdir/autoconf.mk" \
19 | | grep -E -o -- '-I\S+'
20 | )
21 | PS4='$ '
22 | for file in "$@"
23 | do
24 | (
25 | set -x
26 | iwyu $cxxflags "$file"
27 | )
28 | done
29 |
30 | # vim:ts=4 sts=4 sw=4 et
31 |
--------------------------------------------------------------------------------
/private/request-translations:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2015-2022 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | set -e -u
17 |
18 | srcdir=$(dirname "$0")/..
19 | pofiles=''
20 | translators=''
21 | if [ $# -eq 0 ]
22 | then
23 | printf 'Usage: %s PO-FILE...\n' "$0" >&2
24 | exit 1
25 | fi
26 | for po in "$@"
27 | do
28 | m1=$(msgattrib --only-fuzzy "$po")
29 | m2=$(msgattrib --untranslated "$po")
30 | if [ "$m1$m2" ]
31 | then
32 | pofiles="$pofiles;$po"
33 | translator=$(sed -n -e '/^"Last-Translator: \(.\+\)\\n"/ s//\1/p' "$po")
34 | translators="$translators;$translator"
35 | fi
36 | done
37 | IFS='()' read _ version _ < "$srcdir/doc/changelog"
38 | printf '%s' "$translators" \
39 | | tr ';' '\n' \
40 | | LC_ALL=C sort -u \
41 | | xargs -d '\n' printf '%s, ' \
42 | | sed -e 's/^, /To: /; s/, $//'
43 | printf '\n'
44 | printf 'Subject: %s\n' "pdf2djvu $version: call for translations"
45 | cat <
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | _colordiff()
17 | {
18 | if command -v colordiff >/dev/null
19 | then
20 | colordiff
21 | else
22 | cat
23 | fi
24 | }
25 |
26 | make paths.hh || exit 1
27 | : "${CXX:=g++}"
28 | "$CXX" -MM *.cc \
29 | | while read line
30 | do
31 | target=$(printf '%s' "$line" | cut -d: -f1)
32 | deps=$(printf '%s' "$line" | cut -d: -f2 | tr ' ' '\n' | sort)
33 | for dep in $deps
34 | do
35 | echo "$target: $dep"
36 | done
37 | done \
38 | | sort > Makefile.dep.new
39 | diff -u Makefile.dep Makefile.dep.new | _colordiff
40 | mv Makefile.dep.new Makefile.dep
41 |
42 | # vim:ts=2 sts=2 sw=2 et
43 |
--------------------------------------------------------------------------------
/private/update-version:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2009-2018 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | set -e -u
17 | version=${1:?"no version number provided"}
18 | windows_version=$(IFS=.; printf '%d,%d,%d,%d' $version)
19 | po_files=$(ls po/*.po po/*.pot 2>/dev/null || true)
20 | doc_po_files=$(ls doc/po/*.po doc/po/*.pot 2>/dev/null || true)
21 | PS4='$ '
22 | set -x
23 | dch -m -v "$version" -u low -c doc/changelog
24 | export version windows_version
25 | perl -pi -e 's/^AC_INIT[(]\[\S+\], \[\K[0-9.]+/$ENV{version}/' configure.ac
26 | perl -pi -e 's/VERSION \K[0-9,]+/$ENV{windows_version}/' win32-version.rc
27 | perl -pi -e 's/
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_RLE_H
16 | #define PDF2DJVU_RLE_H
17 |
18 | #include
19 | #include
20 |
21 | /* Support for RLE formats.
22 | * Please refer to csepdjvu(1) for the format specification.
23 | */
24 |
25 | namespace rle
26 | {
27 | class R4
28 | {
29 | protected:
30 | std::ostream &stream;
31 | unsigned int x, width, height;
32 | unsigned int run_length;
33 | int last_pixel;
34 | public:
35 | template R4(std::ostream &, T width, T height);
36 | void operator <<(int pixel);
37 | template void output_run(T);
38 | };
39 | }
40 |
41 | template
42 | rle::R4::R4(std::ostream &stream, T width_, T height_)
43 | : stream(stream),
44 | x(0), width(width_), height(height_),
45 | run_length(0),
46 | last_pixel(0)
47 | {
48 | assert(width_ > 0);
49 | assert(height_ > 0);
50 | assert(static_cast(this->width) == width_);
51 | assert(static_cast(this->height) == height_);
52 | this->stream << "R4 " << this->width << " " << this->height << " ";
53 | }
54 |
55 | void rle::R4::operator <<(int pixel)
56 | {
57 | pixel = !!pixel;
58 | this->x++;
59 | assert(this->x > 0);
60 | if (this->last_pixel != pixel)
61 | {
62 | this->output_run(this->run_length);
63 | this->run_length = 1;
64 | this->last_pixel = pixel;
65 | }
66 | else
67 | this->run_length++;
68 | if (this->x == this->width)
69 | {
70 | this->output_run(this->run_length);
71 | this->last_pixel = 0;
72 | this->x = 0;
73 | this->run_length = 0;
74 | }
75 | }
76 |
77 | template
78 | void rle::R4::output_run(T length_)
79 | {
80 | unsigned int length = length_;
81 | static const unsigned int max_length = 0x3FFF;
82 | assert(length_ >= 0);
83 | assert(static_cast(length) == length_);
84 | assert(length <= this->width);
85 | while (length > max_length)
86 | {
87 | this->stream.write("\xFF\xFF", 3);
88 | length -= max_length;
89 | }
90 | if (length >= 192)
91 | {
92 | this->stream
93 | << static_cast(0xC0 + (length >> 8))
94 | << static_cast(length & 0xFF);
95 | }
96 | else
97 | this->stream << static_cast(length);
98 | }
99 |
100 | #endif
101 |
102 | // vim:ts=2 sts=2 sw=2 et
103 |
--------------------------------------------------------------------------------
/sexpr.cc:
--------------------------------------------------------------------------------
1 | /* Copyright © 2008-2018 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #include "sexpr.hh"
16 |
17 | #include
18 |
19 | #include
20 | #include
21 |
22 | static int my_puts(miniexp_io_t* io, const char *s)
23 | {
24 | std::ostream *puts_stream = reinterpret_cast(io->data[0]);
25 | *puts_stream << s;
26 | return puts_stream->good() ? 0 : EOF;
27 | }
28 |
29 | namespace sexpr
30 | {
31 | std::ostream &operator<<(std::ostream &stream, const sexpr::Ref &expr)
32 | {
33 | miniexp_io_t io;
34 | miniexp_io_init(&io);
35 | io.fputs = my_puts;
36 | io.data[0] = &stream;
37 | miniexp_prin_r(&io, expr);
38 | return stream;
39 | }
40 | }
41 |
42 | #if _OPENMP && DDJVUAPI_VERSION < 23
43 |
44 | #include
45 |
46 | class OmpLock
47 | {
48 | private:
49 | omp_lock_t m_lock;
50 | public:
51 | OmpLock()
52 | {
53 | omp_init_lock(&this->m_lock);
54 | }
55 | void lock()
56 | {
57 | omp_set_lock(&this->m_lock);
58 | }
59 | void unlock()
60 | {
61 | omp_unset_lock(&this->m_lock);
62 | }
63 | ~OmpLock()
64 | {
65 | omp_destroy_lock(&this->m_lock);
66 | }
67 | };
68 |
69 | static OmpLock omp_lock;
70 |
71 | sexpr::Guard::Guard()
72 | {
73 | omp_lock.lock();
74 | }
75 |
76 | sexpr::Guard::~Guard()
77 | {
78 | omp_lock.unlock();
79 | }
80 |
81 | #else
82 |
83 | sexpr::Guard::Guard() { }
84 | sexpr::Guard::~Guard() { }
85 |
86 | #endif
87 |
88 | // vim:ts=4 sts=4 sw=4 et
89 |
--------------------------------------------------------------------------------
/sexpr.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2008-2018 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_SEXPR_H
16 | #define PDF2DJVU_SEXPR_H
17 |
18 | #include
19 | #include
20 |
21 | #include
22 |
23 | namespace sexpr
24 | {
25 | typedef miniexp_t Expr;
26 | class Ref
27 | {
28 | minivar_t var;
29 | public:
30 | Ref() : var(miniexp_nil) { }
31 | Ref(const Ref &ref) : var(ref.var) { }
32 | Ref(miniexp_t expr) : var(expr) { }
33 | Ref& operator =(miniexp_t expr) { this->var = expr; return *this; }
34 | operator Expr&() const { return const_cast[(this)->var; }
35 | inline void reverse()
36 | {
37 | this->var = miniexp_reverse(this->var);
38 | }
39 | friend std::ostream &operator<<(std::ostream &, const Ref &);
40 | };
41 | static inline Expr cons(Expr car, Expr cdr) { return miniexp_cons(car, cdr); }
42 | static inline Expr symbol(const char *name) { return miniexp_symbol(name); }
43 | static inline Expr symbol(const std::string &name) { return miniexp_symbol(name.c_str()); }
44 | static inline Expr string(const char *value) { return miniexp_string(value); }
45 | static inline Expr string(const std::string &value) { return miniexp_string(value.c_str()); }
46 | static inline Expr integer(int n) { return miniexp_number(n); }
47 | static const Expr nil = miniexp_nil;
48 | static const Ref &empty_string = string("");
49 |
50 | class Guard
51 | {
52 | public:
53 | Guard();
54 | ~Guard();
55 | };
56 |
57 | }
58 |
59 | #endif
60 |
61 | // vim:ts=2 sts=2 sw=2 et
62 |
--------------------------------------------------------------------------------
/string-format.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2009-2022 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_STRING_FORMAT_HH
16 | #define PDF2DJVU_STRING_FORMAT_HH
17 |
18 | #include ]
>>2<>3<>]>>}
25 |
26 | \end
27 |
28 | % vim:ts=4 sts=4 sw=4 et
29 |
--------------------------------------------------------------------------------
/tests/test-miniexp-thread-safety.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2018 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | from tools import (
17 | case,
18 | )
19 |
20 | class test(case):
21 | def test(self):
22 | # Bug: https://github.com/jwilk/pdf2djvu/issues/131
23 | # + fixed in 0.9.10 [1359ec9def9173d33a5eaca19ab08ce11d2a1306]
24 | self.pdf2djvu('--no-render', '--dpi=72', '-j', '8').assert_()
25 |
26 | # vim:ts=4 sts=4 sw=4 et
27 |
--------------------------------------------------------------------------------
/tests/test-miniexp-thread-safety.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2018 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth210mm
17 | \pdfpageheight146mm
18 | \hsize\pdfpagewidth
19 | \vsize\pdfpageheight
20 |
21 | \leavevmode
22 | \newcount\n
23 | \n=0
24 | \loop
25 | \pdfstartlink
26 | user{/Subtype/Link/A<>}
27 | \the\n
28 | \pdfendlink
29 | \space
30 | \advance \n by 1
31 | \ifnum\n<5661
32 | \repeat
33 | \end
34 |
35 | % vim:ts=4 sts=4 sw=4 et
36 |
--------------------------------------------------------------------------------
/tests/test-monochrome.jpeg.in:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # encoding=UTF-8
3 |
4 | # Copyright © 2009 Jakub Wilk
5 | #
6 | # This file is part of pdf2djvu.
7 | #
8 | # pdf2djvu is free software; you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License version 2 as
10 | # published by the Free Software Foundation.
11 | #
12 | # pdf2djvu is distributed in the hope that it will be useful, but
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 |
17 | from tools import rainbow
18 |
19 | image = rainbow(100, 100)
20 | image.save('test-monochrome.jpeg')
21 |
22 | # vim:ts=4 sts=4 sw=4 et
23 |
--------------------------------------------------------------------------------
/tests/test-monochrome.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2011-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | case,
20 | )
21 |
22 | class test(case):
23 | # Bug: https://github.com/jwilk/pdf2djvu/issues/59
24 | # + fixed in 0.7.10 [da7cd2524b329a80581b939037f4d42801f3755d]
25 |
26 | def test(self):
27 | self.pdf2djvu('--monochrome').assert_()
28 | r = self.djvudump()
29 | r.assert_(stdout=re.compile(r'Sjbz \[[0-9]{4,}\]'))
30 |
31 | # vim:ts=4 sts=4 sw=4 et
32 |
--------------------------------------------------------------------------------
/tests/test-monochrome.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009-2011 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth=1in
17 | \pdfpageheight=1in
18 |
19 | \pdfximage width \pdfpagewidth height \pdfpageheight {test-monochrome.jpeg}
20 | \pdfrefximage\pdflastximage
21 |
22 | \end
23 |
24 | % vim:ts=4 sts=4 sw=4 et
25 |
--------------------------------------------------------------------------------
/tests/test-multipage.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2010-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | case,
20 | )
21 |
22 | class test(case):
23 | # Bug: https://github.com/jwilk/pdf2djvu/issues/50
24 | # + fixed in 0.7.4 [1c373918e0152d452c24936818591d32df0ff7fc]
25 |
26 | def test(self):
27 | self.pdf2djvu('--pages=2').assert_()
28 | r = self.print_text()
29 | r.assert_(stdout=re.compile('^ipsum *\n'))
30 |
31 | # vim:ts=4 sts=4 sw=4 et
32 |
--------------------------------------------------------------------------------
/tests/test-multipage.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2010-2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 33pt
17 | \pdfpageheight 13pt
18 |
19 | Lorem
20 | \vfil\break
21 | ipsum
22 |
23 | \end
24 |
25 | % vim:ts=4 sts=4 sw=4 et
26 |
--------------------------------------------------------------------------------
/tests/test-nfkc-apf.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 | import unicodedata
18 |
19 | from tools import (
20 | case,
21 | )
22 |
23 | class test(case):
24 | # Bug: https://github.com/jwilk/pdf2djvu/issues/90
25 | # + fixed in 0.8
26 |
27 | text = u'\N{LATIN SMALL LIGATURE FL}uorogra\N{LATIN SMALL LIGATURE FI}a'
28 | text_nfkc = unicodedata.normalize('NFKC', text).encode('UTF-8')
29 | text_no_nfkc = text.encode('UTF-8')
30 |
31 | def test_nfkc(self):
32 | self.pdf2djvu().assert_()
33 | r = self.print_text()
34 | r.assert_(stdout=re.compile('^{s} *$'.format(s=self.text_nfkc), re.M))
35 |
36 | def test_no_nfkc(self):
37 | self.pdf2djvu('--no-nfkc').assert_()
38 | r = self.print_text()
39 | r.assert_(stdout=re.compile('^{s} *$'.format(s=self.text_nfkc), re.M))
40 |
41 | # vim:ts=4 sts=4 sw=4 et
42 |
--------------------------------------------------------------------------------
/tests/test-nfkc-apf.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009-2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 57pt
17 | \pdfpageheight 13pt
18 |
19 | % Ligatures from the Alphabetic Presentation Forms block:
20 |
21 | fluorografia
22 |
23 | \end
24 |
25 | % vim:ts=4 sts=4 sw=4 et
26 |
--------------------------------------------------------------------------------
/tests/test-nfkc.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | case,
20 | )
21 |
22 | class test(case):
23 | # + fixed in 0.4.9 [8af81b21de1d8c43bb7585b5318938cde52e30a2]
24 | # + fixed in 0.4.11 [670a11dc9680cb4dac088d269f08f16f8ec0da7c]
25 |
26 | text = u'¾'
27 | text_nfkc = '3⁄4'
28 | text_no_nfkc = text.encode('UTF-8')
29 |
30 | def test_nfkc(self):
31 | self.pdf2djvu().assert_()
32 | r = self.print_text()
33 | r.assert_(stdout=re.compile('^{s} *$'.format(s=self.text_nfkc), re.M))
34 |
35 | def test_no_nfkc(self):
36 | self.pdf2djvu('--no-nfkc').assert_()
37 | r = self.print_text()
38 | r.assert_(stdout=re.compile('^{s} *$'.format(s=self.text_no_nfkc), re.M))
39 |
40 | # vim:ts=4 sts=4 sw=4 et
41 |
--------------------------------------------------------------------------------
/tests/test-nfkc.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 9pt
17 | \pdfpageheight 12pt
18 |
19 | \char190
20 |
21 | \end
22 |
23 | % vim:ts=4 sts=4 sw=4 et
24 |
--------------------------------------------------------------------------------
/tests/test-no-meta.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2016 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | from tools import (
17 | case,
18 | )
19 |
20 | class test(case):
21 | # + fixed in 0.7.10 [b888a6035c600bb12855685389c488b35e4c868e]
22 |
23 | def test(self):
24 | self.pdf2djvu('--no-metadata', '--dpi=72').assert_()
25 | self.print_meta().assert_()
26 |
27 | # vim:ts=4 sts=4 sw=4 et
28 |
--------------------------------------------------------------------------------
/tests/test-no-meta.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009-2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | \null
20 |
21 | \end
22 |
23 | % vim:ts=4 sts=4 sw=4 et
24 |
--------------------------------------------------------------------------------
/tests/test-nonascii.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2019 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import locale
17 | import os
18 | import shutil
19 | import tempfile
20 |
21 | from tools import (
22 | case,
23 | SkipTest,
24 | )
25 |
26 | class test(case):
27 | # Bug: https://github.com/jwilk/pdf2djvu/issues/138
28 |
29 | def test_nonascii(self):
30 | locale_encoding = locale.getpreferredencoding()
31 | try:
32 | curr_sign = u'\xA4'.encode(locale_encoding)
33 | except UnicodeError:
34 | raise SkipTest('locale that can encode U+00A4 CURRENCY SIGN is required')
35 | tmpdir = tempfile.mkdtemp(prefix='pdf2djvu.test.')
36 | try:
37 | djvu_path = os.path.join(tmpdir, curr_sign + '.djvu')
38 | pdf_path = os.path.join(tmpdir, curr_sign + '.pdf')
39 | shutil.copy(self.get_pdf_path(), pdf_path)
40 | cmdline = (self.get_pdf2djvu_command() + (
41 | '-q',
42 | pdf_path,
43 | '-o', djvu_path
44 | ))
45 | r = self.run(*cmdline)
46 | r.assert_()
47 | finally:
48 | shutil.rmtree(tmpdir)
49 |
50 | # vim:ts=4 sts=4 sw=4 et
51 |
--------------------------------------------------------------------------------
/tests/test-nonascii.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009-2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | \null
20 |
21 | \end
22 |
23 | % vim:ts=4 sts=4 sw=4 et
24 |
--------------------------------------------------------------------------------
/tests/test-oom.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2016-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import contextlib
17 | import re
18 | import resource
19 | import string
20 | import sys
21 |
22 | from tools import (
23 | SkipTest,
24 | case,
25 | )
26 |
27 | @contextlib.contextmanager
28 | def vm_limit(limit):
29 | code = 'import resource\nfor n in resource.getrlimit(resource.RLIMIT_AS):\n print(n)'
30 | try:
31 | RLIMIT_AS = resource.RLIMIT_AS
32 | except AttributeError:
33 | # OpenBSD doesn't have RLIMIT_AS;
34 | # RLIMIT_DATA is good enough.
35 | RLIMIT_AS = resource.RLIMIT_DATA
36 | code = re.sub(r'_AS\b', '_DATA', code)
37 | [lim_soft, lim_hard] = resource.getrlimit(RLIMIT_AS)
38 | if lim_hard != resource.RLIM_INFINITY and lim_hard < limit:
39 | limit = lim_hard
40 | resource.setrlimit(RLIMIT_AS, (limit, lim_hard))
41 | try:
42 | r = case().run(sys.executable, '-c', code)
43 | r.assert_(stdout=re.compile(''))
44 | (cld_soft_lim, cld_hard_lim) = map(int, r.stdout.splitlines())
45 | if cld_soft_lim != limit or cld_hard_lim != lim_hard:
46 | message = 'virtual memory limit did not propagate to subprocess'
47 | if sys.platform.rstrip(string.digits) == 'gnu':
48 | raise SkipTest(message + ': https://savannah.gnu.org/bugs/?43320')
49 | raise RuntimeError(message)
50 | yield
51 | finally:
52 | resource.setrlimit(RLIMIT_AS, (lim_soft, lim_hard))
53 |
54 | class test(case):
55 | # Bug: https://github.com/jwilk/pdf2djvu/issues/107
56 | # + fixed in 0.9.4 [fb1dcf60c77dfc39de80d60288449caf767d8b54]
57 |
58 | def test(self):
59 | with vm_limit(1 << 30): # 1 GiB virtual memory limit
60 | r = self.pdf2djvu()
61 | r.assert_(stderr=re.compile(
62 | 'Out of memory\n'
63 | '|AddressSanitizer failed to allocate '
64 | ), rc=1)
65 |
66 | # vim:ts=4 sts=4 sw=4 et
67 |
--------------------------------------------------------------------------------
/tests/test-oom.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2016-2018 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 72in
17 | \pdfpageheight 72in
18 |
19 | \null
20 | \vfil\break
21 | \null
22 | \end
23 |
24 | % vim:ts=4 sts=4 sw=4 et
25 |
--------------------------------------------------------------------------------
/tests/test-outline.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2015-2016 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | from tools import (
17 | case,
18 | )
19 |
20 | expected_outline_sexpr = '''\
21 | (bookmarks
22 | ("Lorem"
23 | "#p0001.djvu"
24 | ("ipsum"
25 | "#p0002.djvu"
26 | ("dolor"
27 | "#p0001.djvu" )
28 | ("sit"
29 | "#p0002.djvu" ) )
30 | ("amet"
31 | "#p0001.djvu" )
32 | ("consectetur adipisci"
33 | "#p0002.djvu" ) )
34 | ("velit"
35 | "#p0001.djvu" ) )
36 | '''
37 |
38 | class test(case):
39 |
40 | def test_multi_page(self):
41 | self.pdf2djvu().assert_()
42 | self.print_outline().assert_(stdout=expected_outline_sexpr)
43 |
44 | def test_single_page(self):
45 | # Make sure that outline is preserved in single-page documents without
46 | # shared annotation chunk.
47 | self.pdf2djvu('-p1', '--no-metadata').assert_()
48 | self.print_outline().assert_(stdout=expected_outline_sexpr)
49 |
50 | def test_iff_corruption(self):
51 | # Make sure that the NAVM chunk begins on an even byte.
52 | #
53 | # Bug: https://github.com/jwilk/pdf2djvu/issues/110
54 | # + introduced in 0.7.20
55 | # + fixed in 0.8.2 [cef7b917bf1cde70884d444a4187fcebeec10ba8]
56 | #
57 | # This particular choice of options seems to trigger odd-sized DIRM chunk:
58 | self.pdf2djvu('-p1', '--no-metadata', '--page-title-template', 'xx').assert_()
59 | self.print_outline().assert_(stdout=expected_outline_sexpr)
60 |
61 | # vim:ts=4 sts=4 sw=4 et
62 |
--------------------------------------------------------------------------------
/tests/test-outline.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | \pdfdest num 1 fit
20 | \pdfdest name {D1} fit
21 |
22 | \null
23 | \vfil\break
24 | \null
25 |
26 | \pdfdest num 2 fit
27 | \pdfdest name {D2} fit
28 |
29 | \pdfoutline goto num 1 count 3 {Lorem}
30 | \pdfoutline goto num 2 count -2 {ipsum}
31 | \pdfoutline goto name {D1} {dolor}
32 | \pdfoutline goto name {D2} {sit}
33 | \pdfoutline goto page 1 {/Fit} {amet}
34 | \pdfoutline goto page 2 {/Fit} {consectetur adipisci}
35 | \pdfoutline goto num 1 {velit}
36 |
37 | \end
38 |
39 | % vim:ts=4 sts=4 sw=4 et
40 |
--------------------------------------------------------------------------------
/tests/test-oversized-outline.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2016-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | case,
20 | )
21 |
22 | class test(case):
23 |
24 | def test(self):
25 | r = self.pdf2djvu()
26 | r.assert_(stderr=re.compile('Document outline too large\n'), rc=1)
27 |
28 | # vim:ts=4 sts=4 sw=4 et
29 |
--------------------------------------------------------------------------------
/tests/test-oversized-outline.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2015-2016 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | \edef\text{ipsum}
20 | \edef\sp{ }
21 | \edef\tlen{5}
22 | \loop
23 | \edef\text{\text\sp\text}
24 | \edef\tlen{\the\numexpr \tlen * 2 + 1}
25 | \ifnum\tlen<65530
26 | \repeat
27 |
28 | \pdfoutline goto page 1 {/Fit} {Lorem \text}
29 |
30 | \null
31 |
32 | \end
33 |
34 | % vim:ts=4 sts=4 sw=4 et
35 |
--------------------------------------------------------------------------------
/tests/test-overwrite.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2015-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | assert_equal,
20 | case,
21 | )
22 |
23 | class test(case):
24 | # Bug: https://github.com/jwilk/pdf2djvu/issues/98
25 | # + fixed in 0.8 [ec2d2e6f7101f7693dac8d102c0dce1fa879f346]
26 |
27 | def test_overwrite(self):
28 | pdf_path = self.get_pdf_path()
29 | with open(pdf_path, 'rb') as pdf_file:
30 | pdf_before = pdf_file.read()
31 | cmdline = (self.get_pdf2djvu_command() + (
32 | '-q',
33 | self.get_pdf_path(),
34 | '-o', self.get_pdf_path()
35 | ))
36 | r = self.run(*cmdline)
37 | r.assert_(stderr=re.compile('Input file is the same as output file:'), rc=1)
38 | with open(pdf_path, 'rb') as pdf_file:
39 | pdf_after = pdf_file.read()
40 | assert_equal(pdf_before, pdf_after)
41 |
42 | # vim:ts=4 sts=4 sw=4 et
43 |
--------------------------------------------------------------------------------
/tests/test-overwrite.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009-2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | \null
20 |
21 | \end
22 |
23 | % vim:ts=4 sts=4 sw=4 et
24 |
--------------------------------------------------------------------------------
/tests/test-page-id.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2015-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | case,
20 | )
21 |
22 | class test(case):
23 |
24 | def test_default(self):
25 | self.pdf2djvu().assert_()
26 | r = self.ls()
27 | r.assert_(stdout=re.compile(
28 | r'\n'
29 | r'\s*1\s+P\s+\d+\s+p0001[.]djvu\s+T=1\n'
30 | r'\s*2\s+P\s+\d+\s+p0002[.]djvu\s+T=2\n'
31 | ))
32 | self.pdf2djvu('--pages', '2').assert_()
33 | r = self.ls()
34 | r.assert_(stdout=re.compile(
35 | r'\n'
36 | r'\s*1\s+P\s+\d+\s+p0002[.]djvu\s+T=2\n'
37 | ))
38 |
39 | def test_spage(self):
40 | def t(tmpl):
41 | self.pdf2djvu('--pages', '2', '--page-id-template', tmpl).assert_()
42 | r = self.ls()
43 | r.assert_(stdout=re.compile(
44 | r'\n'
45 | r'\s*1\s+P\s+\d+\s+p2[.]djvu\sT=2\n'
46 | ))
47 | t('p{page}.djvu')
48 | t('p{spage}.djvu')
49 |
50 | def test_dpage(self):
51 | self.pdf2djvu('--pages', '2', '--page-id-template', 'p{dpage}.djvu').assert_()
52 | r = self.ls()
53 | r.assert_(stdout=re.compile(
54 | r'\n'
55 | r'\s*1\s+P\s+\d+\s+p1[.]djvu\s+T=2\n'
56 | ))
57 |
58 | def test_minus(self):
59 | self.pdf2djvu('--page-id-template', 'p{page-1}.djvu').assert_()
60 | r = self.ls()
61 | r.assert_(stdout=re.compile(
62 | r'\n'
63 | r'\s*1\s+P\s+\d+\s+p0[.]djvu\s+T=1\n'
64 | r'\s*2\s+P\s+\d+\s+p1[.]djvu\s+T=2\n'
65 | ))
66 |
67 | def test_plus(self):
68 | self.pdf2djvu('--page-id-template', 'p{page+7}.djvu').assert_()
69 | r = self.ls()
70 | r.assert_(stdout=re.compile(
71 | r'\n'
72 | r'\s*1\s+P\s+\d+\s+p8[.]djvu\s+T=1\n'
73 | r'\s*2\s+P\s+\d+\s+p9[.]djvu\s+T=2\n'
74 | ))
75 |
76 | # vim:ts=4 sts=4 sw=4 et
77 |
--------------------------------------------------------------------------------
/tests/test-page-id.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | \null
20 | \vfil\break
21 | \null
22 |
23 | \end
24 |
25 | % vim:ts=4 sts=4 sw=4 et
26 |
--------------------------------------------------------------------------------
/tests/test-rotated-page.jpeg.in:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # encoding=UTF-8
3 |
4 | # Copyright © 2009 Jakub Wilk
5 | #
6 | # This file is part of pdf2djvu.
7 | #
8 | # pdf2djvu is free software; you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License version 2 as
10 | # published by the Free Software Foundation.
11 | #
12 | # pdf2djvu is distributed in the hope that it will be useful, but
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 |
17 | from tools import rainbow
18 |
19 | image = rainbow(255, 100)
20 | image.save('test-rotated-page.jpeg')
21 |
22 | # vim:ts=4 sts=4 sw=4 et
23 |
--------------------------------------------------------------------------------
/tests/test-rotated-page.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2016 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | from tools import (
17 | case,
18 | )
19 |
20 | class test(case):
21 | # Bug: https://github.com/jwilk/pdf2djvu/issues/4
22 | # + fixed in 0.4.10 [5227290f2bcf4916dff7c4e6be7ea1de559c9151]
23 |
24 | def test(self):
25 | self.pdf2djvu().assert_()
26 |
27 | # vim:ts=4 sts=4 sw=4 et
28 |
--------------------------------------------------------------------------------
/tests/test-rotated-page.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagesattr{/Rotate 90}
17 |
18 | \pdfpageimage{test-rotated-page.jpeg}
19 |
20 | \end
21 |
22 | % vim:ts=4 sts=4 sw=4 et
23 |
--------------------------------------------------------------------------------
/tests/test-solid-nonwhite-background.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | case,
20 | )
21 |
22 | class test(case):
23 | # + fixed in 0.3.6 [79779eea4fccc83d126ba27408de16a1c5f35d11]
24 |
25 | def test(self):
26 | self.pdf2djvu().assert_()
27 | r = self.djvudump()
28 | r.assert_(stdout=re.compile(r'BG44 \[[0-9][0-9]\] .* 75x75'))
29 |
30 | # vim:ts=4 sts=4 sw=4 et
31 |
--------------------------------------------------------------------------------
/tests/test-solid-nonwhite-background.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009-2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 3in
17 | \pdfpageheight 3in
18 |
19 | \pdfliteral direct{q 1 0 0 rg 0 0 216 216 re f Q}
20 |
21 | Lorem ipsum
22 |
23 | \end
24 |
25 | % vim:ts=4 sts=4 sw=4 et
26 |
--------------------------------------------------------------------------------
/tests/test-subsample.jpeg.in:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # encoding=UTF-8
3 |
4 | # Copyright © 2009 Jakub Wilk
5 | #
6 | # This file is part of pdf2djvu.
7 | #
8 | # pdf2djvu is free software; you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License version 2 as
10 | # published by the Free Software Foundation.
11 | #
12 | # pdf2djvu is distributed in the hope that it will be useful, but
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 |
17 | from tools import rainbow
18 |
19 | image = rainbow(100, 101)
20 | image.save('test-subsample.jpeg')
21 |
22 | # vim:ts=4 sts=4 sw=4 et
23 |
--------------------------------------------------------------------------------
/tests/test-subsample.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | case,
20 | )
21 |
22 | class test(case):
23 |
24 | def test_11(self):
25 | # Bug: https://sourceforge.net/p/djvu/bugs/106/
26 | # + fixed in 0.4.11 [25f63fdcee01a93df16fcd56ebd7587165f4ee52]
27 | self.pdf2djvu('--bg-subsample=11', '--dpi=72').assert_()
28 | r = self.djvudump()
29 | r.assert_(stdout=re.compile('BG44.* 10x11$', re.M))
30 |
31 | def test_12(self):
32 | # Bug: https://bugs.debian.org/458211
33 | #
34 | # Prior to pdf2djvu 0.5.0, subsample ratio 12 was not allowed.
35 | # Now we require a fixed version of DjVuLibre.
36 | self.pdf2djvu('--bg-subsample=12', '--dpi=72').assert_()
37 | r = self.djvudump()
38 | r.assert_(stdout=re.compile('BG44.* 9x9$', re.M))
39 |
40 | # vim:ts=4 sts=4 sw=4 et
41 |
--------------------------------------------------------------------------------
/tests/test-subsample.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpageimage{test-subsample.jpeg}
17 |
18 | \end
19 |
20 | % vim:ts=4 sts=4 sw=4 et
21 |
--------------------------------------------------------------------------------
/tests/test-symbol.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2022 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | from __future__ import print_function
17 |
18 | import itertools
19 |
20 | from tools import (
21 | assert_fail,
22 | case,
23 | )
24 |
25 | def print_pgm(image):
26 | width = len(image[0])
27 | print('+', '-' * (2 * width), '+', sep='')
28 | for line in image:
29 | print('|', end='')
30 | for px in line:
31 | if px == '\xFF':
32 | print(' ', end='')
33 | elif px == '\0':
34 | print('[]', end='')
35 | else:
36 | print('()', end='')
37 | print('|')
38 | print('+', '-' * (2 * width), '+', sep='')
39 |
40 | class test(case):
41 | # Bug: https://github.com/jwilk/pdf2djvu/issues/154
42 |
43 | def test(self):
44 | self.pdf2djvu('--dpi=150')
45 | image = self.decode(fmt='pgm')
46 | print_pgm(image)
47 | for line in image:
48 | sig = str.join('', (pixel for (pixel, _) in itertools.groupby(line)))
49 | if sig not in {'\xFF', '\xFF\x00\xFF', '\xFF\x00\xFF\x00\xFF'}:
50 | assert_fail('image does not look like uppercase delta')
51 |
52 | # vim:ts=4 sts=4 sw=4 et
53 |
--------------------------------------------------------------------------------
/tests/test-symbol.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2022 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 | \input common
16 |
17 | \pdfpagewidth 12pt
18 | \pdfpageheight 12pt
19 |
20 | \pdfmapline{psyr Symbol}
21 | \font\symbol=psyr at 12pt
22 | \symbol
23 |
24 | \hskip1pt\relax
25 | D
26 |
27 | \end
28 |
29 | % vim:ts=4 sts=4 sw=4 et
30 |
--------------------------------------------------------------------------------
/tests/test-title.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2015-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | case,
20 | )
21 |
22 | class test(case):
23 |
24 | def test_no_title(self):
25 | def t(*args):
26 | self.pdf2djvu(*args).assert_()
27 | r = self.ls()
28 | r.assert_(stdout=re.compile(
29 | r'\n'
30 | r'\s*1\s+P\s+\d+\s+[\w.]+\n'
31 | r'\s*2\s+P\s+\d+\s+[\w.]+\n'
32 | ))
33 | t('--page-title-template', '')
34 | t('--no-page-titles')
35 |
36 | def test_ascii(self):
37 | template = '#{page}'
38 | self.pdf2djvu('--page-title-template', template).assert_()
39 | r = self.ls()
40 | r.assert_(stdout=re.compile(
41 | r'\n'
42 | r'\s*1\s+P\s+\d+\s+[\w.]+\s+T=#1\n'
43 | r'\s*2\s+P\s+\d+\s+[\w.]+\s+T=#2\n'
44 | ))
45 |
46 | def test_utf8(self):
47 | self.require_feature('POSIX')
48 | template = '№{page}'
49 | self.pdf2djvu('--page-title-template', template, encoding='UTF-8').assert_()
50 | r = self.ls()
51 | r.assert_(stdout=re.compile(
52 | r'\n'
53 | r'\s*1\s+P\s+\d+\s+[\w.]+\s+T=№1\n'
54 | r'\s*2\s+P\s+\d+\s+[\w.]+\s+T=№2\n'
55 | ))
56 |
57 | def test_bad_encoding(self):
58 | self.require_feature('POSIX')
59 | template = '{page}\xBA'
60 | r = self.pdf2djvu('--page-title-template', template, encoding='UTF-8')
61 | r.assert_(stderr=re.compile('^Unable to convert page title to UTF-8:'), rc=1)
62 |
63 | def test_iso8859_1(self):
64 | template = '{page}\xBA'
65 | self.pdf2djvu('--page-title-template', template, encoding='ISO8859-1').assert_()
66 | r = self.ls()
67 | r.assert_(stdout=re.compile(
68 | r'\n'
69 | r'\s*1\s+P\s+\d+\s+[\w.]+\s+T=1º\n'
70 | r'\s*2\s+P\s+\d+\s+[\w.]+\s+T=2º\n'
71 | ))
72 |
73 | # vim:ts=4 sts=4 sw=4 et
74 |
--------------------------------------------------------------------------------
/tests/test-title.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | \null
20 | \vfil\break
21 | \null
22 |
23 | \end
24 |
25 | % vim:ts=4 sts=4 sw=4 et
26 |
--------------------------------------------------------------------------------
/tests/test-utf16-meta.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2017 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | case,
20 | )
21 |
22 | class test(case):
23 | # + fixed in 0.3.3 [0d4169e1bdffb34ebcef51f29abc744ade9c1556]
24 |
25 | def test(self):
26 | title = (
27 | r'\316\232\317\211\316\264\316\271\316\272\316\277\317\200\316\277\316\257\316\267\317\203\316\267 '
28 | r'\317\207\316\261\317\201\316\261\316\272\317\204\316\256\317\201\317\211\316\275'
29 | )
30 | self.pdf2djvu('--dpi=72').assert_()
31 | r = self.print_meta()
32 | r.assert_(stdout=re.compile('Title\t"{s}"'.format(s=title.replace('\\', '\\\\'))))
33 |
34 | # vim:ts=4 sts=4 sw=4 et
35 |
--------------------------------------------------------------------------------
/tests/test-utf16-meta.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009-2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | \pdfinfo{%
20 | /Title (\376\377\003\232\003\311\003\264\003\271\003\272\003\277\003\300\003\277\003\257\003\267\003\303\003\267\000\040\003\307\003\261\003\301\003\261\003\272\003\304\003\256\003\301\003\311\003\275)
21 | }
22 |
23 | \null
24 |
25 | \end
26 |
27 | % vim:ts=4 sts=4 sw=4 et
28 |
--------------------------------------------------------------------------------
/tests/test-vector-fg.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2015-2022 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | from tools import (
17 | case,
18 | assert_greater,
19 | count_colors,
20 | )
21 |
22 | class test(case):
23 | # Bug: https://github.com/jwilk/pdf2djvu/issues/115
24 | # + introduced in 0.7.1 [a9440040faf697bc11370e8012ba586e88e4dca4]
25 | # + introduced in 0.7.10 [da7cd2524b329a80581b939037f4d42801f3755d]
26 | # + fixed in 0.9.3 [93f9032d99b75145a03ce64de9c3ae3e25314541]
27 |
28 | def test(self):
29 | self.pdf2djvu()
30 | image = self.decode()
31 | image = self.decode(mode='foreground')
32 | colors = count_colors(image)
33 | assert_greater(colors.get('\xFF\0\0', 0), 5000)
34 |
35 | # vim:ts=4 sts=4 sw=4 et
36 |
--------------------------------------------------------------------------------
/tests/test-vector-fg.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1in
17 | \pdfpageheight 1in
18 |
19 | \pdfliteral direct{q 1 0 0 rg 0 0 4 72 re f Q}
20 |
21 | \end
22 |
23 | % vim:ts=4 sts=4 sw=4 et
24 |
--------------------------------------------------------------------------------
/tests/test-version.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2015-2018 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import os
17 | import re
18 | import xml.etree.cElementTree as etree
19 |
20 | from tools import (
21 | assert_equal,
22 | assert_fail,
23 | case,
24 | )
25 |
26 | here = os.path.dirname(__file__)
27 | srcdir = os.path.join(here, os.pardir)
28 |
29 | class test(case):
30 |
31 | def __init__(self):
32 | path = os.path.join(srcdir, 'doc', 'changelog')
33 | with open(path) as fp:
34 | line = fp.readline()
35 | self.changelog_version = line.split()[1].strip('()')
36 |
37 | def test_manpage(self):
38 | path = os.path.join(srcdir, 'doc', 'manpage.xml')
39 | for dummy_event, elem in etree.iterparse(path):
40 | if elem.tag == 'refmiscinfo' and elem.get('class') == 'version':
41 | assert_equal(elem.text, self.changelog_version)
42 | break
43 | else:
44 | assert_fail("missing ")
45 |
46 | def test_executable(self):
47 | r = self.pdf2djvu('--version')
48 | r.assert_(stdout=re.compile(r'^pdf2djvu [0-9.]+\r?\n', re.M), rc=0)
49 | exec_version = r.stdout.splitlines()[0]
50 | _, exec_version = exec_version.split()
51 | assert_equal(exec_version, self.changelog_version)
52 |
53 | # vim:ts=4 sts=4 sw=4 et
54 |
--------------------------------------------------------------------------------
/tests/test-xmp-broken.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2021 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import re
17 |
18 | from tools import (
19 | assert_regex,
20 | case,
21 | )
22 |
23 | class test(case):
24 | def test_verbatim(self):
25 | self.pdf2djvu('--verbatim-metadata').assert_()
26 | xmp = self.extract_xmp()
27 | assert_regex(xmp, '
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | % dummy stream to fool Poppler: https://bugs.debian.org/668777
20 | \immediate\pdfobj stream {}
21 |
22 | \immediate\pdfobj stream attr
23 | {/Type /Metadata /Subtype /XML}
24 | {%
25 |
26 |
27 |
29 |
30 | }
31 | \pdfcatalog{/Metadata \the\pdflastobj\space 0 R}
32 |
33 | \null
34 |
35 | \end
36 |
37 | % vim:ts=4 sts=4 sw=4 et
38 |
--------------------------------------------------------------------------------
/tests/test-xmp-mediatype.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2016 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import xml.etree.cElementTree as etree
17 |
18 | from tools import (
19 | assert_equal,
20 | assert_not_equal,
21 | assert_uuid_urn,
22 | case,
23 | xml_find_text,
24 | )
25 |
26 | class test(case):
27 | # Bug: https://github.com/jwilk/pdf2djvu/issues/12
28 | # + fixed in 0.6.0 [1368c73c027d798bdbfe0ac61c26339206e747bc]
29 |
30 | def test_verbatim(self):
31 | self.pdf2djvu('--verbatim-metadata').assert_()
32 | xmp = self.extract_xmp()
33 | xmp = etree.fromstring(xmp)
34 | dcformat = xml_find_text(xmp, 'dc:format')
35 | assert_equal(dcformat, 'application/pdf')
36 |
37 | def test_no_verbatim(self):
38 | self.require_feature('Exiv2')
39 | self.pdf2djvu().assert_()
40 | xmp = self.extract_xmp()
41 | xmp = etree.fromstring(xmp)
42 | dcformat = xml_find_text(xmp, 'dc:format')
43 | assert_equal(dcformat, 'image/vnd.djvu')
44 | instance_id = xml_find_text(xmp, 'xmpMM:InstanceID')
45 | document_id = xml_find_text(xmp, 'xmpMM:DocumentID')
46 | assert_not_equal(instance_id, document_id)
47 | assert_uuid_urn(instance_id)
48 | assert_uuid_urn(document_id)
49 |
50 | # vim:ts=4 sts=4 sw=4 et
51 |
--------------------------------------------------------------------------------
/tests/test-xmp-mediatype.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009-2018 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | % dummy stream to fool Poppler: https://bugs.debian.org/668777
20 | \immediate\pdfobj stream {}
21 |
22 | \immediate\pdfobj stream attr
23 | {/Type /Metadata /Subtype /XML}
24 | {%
25 |
26 |
27 |
28 |
29 | application/pdf
30 |
31 |
32 |
33 |
34 | }
35 | \pdfcatalog{/Metadata \the\pdflastobj\space 0 R}
36 |
37 | \null
38 |
39 | \end
40 |
41 | % vim:ts=4 sts=4 sw=4 et
42 |
--------------------------------------------------------------------------------
/tests/test-xmp-recreate.py:
--------------------------------------------------------------------------------
1 | # encoding=UTF-8
2 |
3 | # Copyright © 2009-2016 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | import xml.etree.cElementTree as etree
17 |
18 | from tools import (
19 | assert_equal,
20 | assert_is_none,
21 | assert_not_equal,
22 | assert_uuid_urn,
23 | case,
24 | xml_find_text,
25 | )
26 |
27 | class test(case):
28 | # + fixed in 0.6.0 [79d56ebabd600e44f7aa97634d44d471249e74f2]
29 |
30 | def test_verbatim(self):
31 | self.pdf2djvu('--verbatim-metadata').assert_()
32 | xmp = self.extract_xmp()
33 | assert_is_none(xmp)
34 |
35 | def test_no_verbatim(self):
36 | self.require_feature('Exiv2')
37 | self.pdf2djvu().assert_()
38 | xmp = self.extract_xmp()
39 | xmp = etree.fromstring(xmp)
40 | dcformat = xml_find_text(xmp, 'dc:format')
41 | assert_equal(dcformat, 'image/vnd.djvu')
42 | instance_id = xml_find_text(xmp, 'xmpMM:InstanceID')
43 | document_id = xml_find_text(xmp, 'xmpMM:DocumentID')
44 | assert_not_equal(instance_id, document_id)
45 | assert_uuid_urn(instance_id)
46 | assert_uuid_urn(document_id)
47 |
48 | # vim:ts=4 sts=4 sw=4 et
49 |
--------------------------------------------------------------------------------
/tests/test-xmp-recreate.tex:
--------------------------------------------------------------------------------
1 | % Copyright © 2009-2015 Jakub Wilk
2 | %
3 | % This file is part of pdf2djvu.
4 | %
5 | % pdf2djvu is free software; you can redistribute it and/or modify
6 | % it under the terms of the GNU General Public License version 2 as
7 | % published by the Free Software Foundation.
8 | %
9 | % pdf2djvu is distributed in the hope that it will be useful, but
10 | % WITHOUT ANY WARRANTY; without even the implied warranty of
11 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | % General Public License for more details.
13 |
14 | \input common
15 |
16 | \pdfpagewidth 1pt
17 | \pdfpageheight 1pt
18 |
19 | \null
20 |
21 | \end
22 |
23 | % vim:ts=4 sts=4 sw=4 et
24 |
--------------------------------------------------------------------------------
/tools/build-manpage:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2014-2022 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | set -e -u
17 |
18 | usage()
19 | {
20 | printf 'Usage: %s [-l] \n' "$0"
21 | }
22 |
23 | here=$(dirname "$0")
24 | opt_lang=
25 | while getopts 'hl' opt
26 | do
27 | case "$opt" in
28 | l) opt_lang=y;;
29 | h) usage; exit 0;;
30 | *) usage >&2; exit 1;;
31 | esac
32 | done
33 | shift $((OPTIND - 1))
34 | [ $# -eq 2 ] || { usage; exit 1; }
35 | src="$1"
36 | dst="$2"
37 | xsl="$here/manpage.xsl"
38 | xmllint='xmllint --valid --noout --nonet'
39 | xsltproc='xsltproc --nonet'
40 | [ -n "$opt_lang" ] && xsltproc="$xsltproc --param man.output.lang.in.name.enabled 1"
41 | PS4='$ '
42 | set -x
43 | $xmllint "$src"
44 | $xsltproc "$xsl" "$src"
45 | perl -pi -e '
46 | if (/^[.]SH /) {
47 | # work-arounds for DocBook XSL capitalization bugs
48 | s/(\\[(][,~\x27][a-z])/\U$1/g; # https://bugs.debian.org/758262#20
49 | s/\\[(]ss/SS/g; # https://bugs.debian.org/773444
50 | }
51 | '"# prefer ' to \(aq when used as an apostrophe"'
52 | s/([a-z])\\[*][(]Aq([a-z])/$1\x27$2/gi;
53 | s#^\\%(https?://.*)#.UR $1\n.UE#g;
54 | ' "$dst"
55 |
56 | # vim:ts=4 sts=4 sw=4 et
57 |
--------------------------------------------------------------------------------
/tools/generate-paths-hh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2009-2018 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | set -e -u
17 |
18 | exec > paths.hh
19 | cat <
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | if ! command -v "$1" >/dev/null
17 | then
18 | printf 'Usage: %s xgettext [xgettext-option]...\n' "$0" >&2
19 | exit 1
20 | fi
21 | options=$(cat <
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | usage()
17 | {
18 | printf '%s MAN-DIR MAN-PAGE...\n' "$0"
19 | }
20 |
21 | set -e -u
22 | : "${INSTALL:=install}"
23 | [ $# -ge 1 ] || { usage >&2; exit 1; }
24 | mandir="$1"
25 | shift
26 | for manpage in "$@"
27 | do
28 | basename=${manpage##*/}
29 | suffix=${basename#*.}
30 | locale=${suffix%.*}
31 | if [ "$locale" = "$suffix" ]
32 | then
33 | locale=
34 | else
35 | locale=${locale}/
36 | fi
37 | section=${suffix#*.}
38 | basename=${basename%%.*}
39 | (
40 | PS4='$ '
41 | set -x
42 | $INSTALL -d "$mandir/${locale}man$section"
43 | $INSTALL -m 644 "$manpage" "$mandir/${locale}man$section/$basename.$section"
44 | )
45 | done
46 |
47 | # vim:ts=4 sts=4 sw=4 et
48 |
--------------------------------------------------------------------------------
/tools/install-mo:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2015-2022 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | usage()
17 | {
18 | printf '%s LOCALE-DIR MO-FILE...\n' "$0"
19 | }
20 |
21 | set -e -u
22 | : "${INSTALL:=install}"
23 | [ $# -ge 1 ] || { usage >&2; exit 1; }
24 | localedir="$1"
25 | shift
26 | for mofile in "$@"
27 | do
28 | basename=${mofile##*/}
29 | locale=${basename%.*}
30 | (
31 | PS4='$ '
32 | set -x
33 | $INSTALL -d "$localedir/$locale/LC_MESSAGES"
34 | $INSTALL -m 644 "$mofile" "$localedir/$locale/LC_MESSAGES/pdf2djvu.mo"
35 | )
36 | done
37 |
38 | # vim:ts=4 sts=4 sw=4 et
39 |
--------------------------------------------------------------------------------
/tools/manpage.xsl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/version.cc:
--------------------------------------------------------------------------------
1 | /* Copyright © 2015 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #include "version.hh"
16 |
17 | #include
18 |
19 | #include
20 |
21 | #include "autoconf.hh"
22 |
23 | static std::string get_djvulibre_version()
24 | {
25 | #if DDJVUAPI_VERSION >= 20
26 | std::string v = ddjvu_get_version_string();
27 | if (v.compare(0, 10, "DjVuLibre-") == 0)
28 | v.erase(0, 10);
29 | return v;
30 | #else
31 | return DJVULIBRE_VERSION_STRING;
32 | #endif
33 | }
34 |
35 | #if HAVE_XMP
36 | #include
37 | #endif
38 |
39 | #if HAVE_GRAPHICSMAGICK
40 |
41 | #include
42 |
43 | static std::string get_gm_version()
44 | {
45 | unsigned long n;
46 | std::stringstream stream(
47 | MagickLib::GetMagickVersion(&n)
48 | );
49 | std::string junk, result;
50 | stream >> junk >> result;
51 | return result;
52 | }
53 |
54 | #endif
55 |
56 | const std::string get_version()
57 | {
58 | std::ostringstream stream;
59 | stream << PACKAGE_STRING;
60 | stream << " (DjVuLibre " << get_djvulibre_version();
61 | stream << ", Poppler " POPPLER_VERSION_STRING;
62 | #if HAVE_GRAPHICSMAGICK
63 | stream << ", GraphicsMagick++ " << get_gm_version();
64 | #endif
65 | #if HAVE_XMP
66 | stream << ", Exiv2 " << Exiv2::version();
67 | #endif
68 | stream << ")";
69 | return stream.str();
70 | }
71 |
72 | const std::string get_multiline_version()
73 | {
74 | std::ostringstream stream;
75 | stream << PACKAGE_STRING << "\n";
76 | stream << "+ DjVuLibre " << get_djvulibre_version() << "\n";
77 | stream << "+ Poppler " POPPLER_VERSION_STRING << "\n";
78 | #if HAVE_GRAPHICSMAGICK
79 | stream << "+ GraphicsMagick++ " << get_gm_version() << " (Q" << QuantumDepth << ")\n";
80 | #endif
81 | #if HAVE_XMP
82 | stream << "+ Exiv2 " << Exiv2::version() << "\n";
83 | #endif
84 | return stream.str();
85 | }
86 |
87 | // vim:ts=4 sts=4 sw=4 et
88 |
--------------------------------------------------------------------------------
/version.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2015 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_VERSION_H
16 | #define PDF2DJVU_VERSION_H
17 |
18 | #include
19 |
20 | const std::string get_version();
21 | const std::string get_multiline_version();
22 |
23 | #endif
24 |
25 | // vim:ts=4 sts=4 sw=4 et
26 |
--------------------------------------------------------------------------------
/win32-version.rc:
--------------------------------------------------------------------------------
1 | #include
2 | #include "autoconf.hh"
3 |
4 | VS_VERSION_INFO VERSIONINFO
5 | FILEVERSION 0,9,19,0
6 | PRODUCTVERSION 0,9,19,0
7 | BEGIN
8 | BLOCK "StringFileInfo"
9 | BEGIN
10 | BLOCK "04090000"
11 | BEGIN
12 | VALUE "ProductName", PACKAGE_STRING
13 | VALUE "FileDescription", "PDF to DjVu converter\0"
14 | VALUE "FileVersion", PACKAGE_VERSION
15 | VALUE "LegalCopyright", "Copyright © 2007-2022 Jakub Wilk \0"
16 | VALUE "Comments", "pdf2djvu is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.\0"
17 | END
18 | END
19 | END
20 |
21 | // vim:ts=4 sts=4 sw=4 et
22 |
--------------------------------------------------------------------------------
/win32/doc/COPYING.fonts.txt:
--------------------------------------------------------------------------------
1 | URW Type 1 fonts
2 | ================
3 | Copyright © 1999 (URW)++ Design & Development
4 | Copyright © 2001-2005 Valek Filippov
5 |
6 | The font files are distributed under the GNU General Public License.
7 |
8 | As a special exception, permission is granted to include this font program in a
9 | Postscript or PDF file that consists of a document that contains text to be
10 | displayed or printed using this font, regardless of the conditions or license
11 | applying to the document itself.
12 |
13 | .. vim:ft=rst
14 |
--------------------------------------------------------------------------------
/win32/doc/COPYING.poppler-data.txt:
--------------------------------------------------------------------------------
1 | Poppler data
2 | ============
3 |
4 | The cMap data files are under the following license:
5 |
6 | Copyright 1990-2009 Adobe Systems Incorporated.
7 | All rights reserved.
8 |
9 | Redistribution and use in source and binary forms, with or
10 | without modification, are permitted provided that the
11 | following conditions are met:
12 |
13 | Redistributions of source code must retain the above
14 | copyright notice, this list of conditions and the following
15 | disclaimer.
16 |
17 | Redistributions in binary form must reproduce the above
18 | copyright notice, this list of conditions and the following
19 | disclaimer in the documentation and/or other materials
20 | provided with the distribution.
21 |
22 | Neither the name of Adobe Systems Incorporated nor the names
23 | of its contributors may be used to endorse or promote
24 | products derived from this software without specific prior
25 | written permission.
26 |
27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
28 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
34 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
38 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 |
41 | The cidToUnicode, nameToUnicode and unicodeMap data files
42 | are Copyright Glyph & Cog, LLC and are under the GPLv2 license.
43 |
44 | .. vim:ft=rst
45 |
--------------------------------------------------------------------------------
/win32/misc/30-urw-aliases.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 | Zapf Dingbats
12 |
13 | Dingbats
14 |
15 |
16 |
17 |
18 | Symbol
19 |
20 | Standard Symbols L
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/win32/misc/dummy-mutex.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2018-2020 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_DUMMY_MUTEX
16 | #define PDF2DJVU_DUMMY_MUTEX
17 |
18 | #include
19 |
20 | #if !defined(_GLIBCXX_HAS_GTHREADS)
21 |
22 | namespace std {
23 |
24 | class recursive_mutex {
25 | public:
26 | void lock() { }
27 | void unlock() { }
28 | bool try_lock() {
29 | return true;
30 | }
31 | };
32 |
33 | class mutex {
34 | public:
35 | void lock() { }
36 | void unlock() { }
37 | bool try_lock() {
38 | return true;
39 | }
40 | };
41 |
42 | }
43 |
44 | #endif
45 |
46 | #endif
47 |
48 | // vim:ts=4 sts=4 sw=4 et
49 |
--------------------------------------------------------------------------------
/win32/patches/exiv2/mutex.diff:
--------------------------------------------------------------------------------
1 | Use Windows synchronization API.
2 |
3 | Last-Update; 2021-05-04
4 |
5 | --- a/include/exiv2/rwlock.hpp
6 | +++ b/include/exiv2/rwlock.hpp
7 | @@ -21,14 +21,14 @@
8 | #ifndef RW_LOCK_HPP
9 | #define RW_LOCK_HPP
10 |
11 | -#ifdef _MSC_VER
12 | +#ifdef _WIN32
13 | #include
14 | #else
15 | #include
16 | #endif
17 |
18 | namespace Exiv2 {
19 | -#ifdef _MSC_VER
20 | +#ifdef _WIN32
21 | /*!
22 | @brief Class to provide a Read-Write Lock
23 | */
24 |
--------------------------------------------------------------------------------
/win32/patches/exiv2/series:
--------------------------------------------------------------------------------
1 | mutex.diff
2 |
--------------------------------------------------------------------------------
/win32/patches/fontconfig/disable-uuid-test.diff:
--------------------------------------------------------------------------------
1 | Disable the uuid test.
2 |
3 | Last-Update: 2022-08-08
4 |
5 | --- a/test/test-hash.c
6 | +++ b/test/test-hash.c
7 | @@ -47,6 +47,7 @@ fini (Test *test)
8 | static FcBool
9 | test_add (Test *test, FcChar8 *key, FcBool replace)
10 | {
11 | +#if 0
12 | uuid_t uuid;
13 | void *u;
14 | FcBool (*hash_add) (FcHashTable *, void *, void *);
15 | @@ -65,11 +66,15 @@ test_add (Test *test, FcChar8 *key, FcBo
16 | FcHashUuidFree (u);
17 |
18 | return ret;
19 | +#endif
20 | +
21 | + return FcTrue;
22 | }
23 |
24 | static FcBool
25 | test_remove (Test *test, FcChar8 *key)
26 | {
27 | +#if 0
28 | void *u;
29 |
30 | if (!FcHashTableFind (test->table, key, &u))
31 | @@ -79,6 +84,7 @@ test_remove (Test *test, FcChar8 *key)
32 | return FcFalse;
33 | if (FcHashTableFind (test->table, key, &u))
34 | return FcFalse;
35 | +#endif
36 |
37 | return FcTrue;
38 | }
39 | @@ -86,6 +92,7 @@ test_remove (Test *test, FcChar8 *key)
40 | int
41 | main (void)
42 | {
43 | +#if 0
44 | Test *test;
45 | uuid_t uuid;
46 | int ret = 0;
47 | @@ -184,4 +191,6 @@ bail:
48 | fini (test);
49 |
50 | return ret;
51 | +#endif
52 | + return 0;
53 | }
54 |
--------------------------------------------------------------------------------
/win32/patches/fontconfig/no-fc-templatedir.diff:
--------------------------------------------------------------------------------
1 | Don't load config from (build-time hardcoded) FC_TEMPLATEDIR.
2 |
3 | Last-Update: 2022-08-08
4 |
5 | --- a/src/fcinit.c
6 | +++ b/src/fcinit.c
7 | @@ -94,7 +94,6 @@ FcInitLoadOwnConfig (FcConfig *config)
8 |
9 | return fallback;
10 | }
11 | - (void) FcConfigParseOnly (config, (const FcChar8 *)FC_TEMPLATEDIR, FcFalse);
12 |
13 | if (config->cacheDirs && config->cacheDirs->num == 0)
14 | {
15 |
--------------------------------------------------------------------------------
/win32/patches/fontconfig/series:
--------------------------------------------------------------------------------
1 | disable-uuid-test.diff
2 | test-mkdir.diff
3 | no-fc-templatedir.diff
4 |
--------------------------------------------------------------------------------
/win32/patches/fontconfig/test-mkdir.diff:
--------------------------------------------------------------------------------
1 | tests: provide mktemp() implementation.
2 |
3 | Last-Update: 2022-08-08
4 |
5 | --- a/test/test-bz106632.c
6 | +++ b/test/test-bz106632.c
7 | @@ -44,6 +44,11 @@
8 | #undef FcPatternDestroy
9 | #include
10 |
11 | +#ifdef _WIN32
12 | +#include
13 | +#define mkdir(path,mode) _mkdir(path)
14 | +#endif
15 | +
16 | #ifdef HAVE_MKDTEMP
17 | #define fc_mkdtemp mkdtemp
18 | #else
19 |
--------------------------------------------------------------------------------
/win32/patches/graphicsmagick/config-paths.diff:
--------------------------------------------------------------------------------
1 | Adjust configuration paths.
2 |
3 | Load configuration from /share/GraphicsMagick/.
4 | Don't load it from the current working directory.
5 |
6 | Last-Update: 2018-12-17
7 |
8 | --- a/magick/blob.c
9 | +++ b/magick/blob.c
10 | @@ -1999,6 +1999,7 @@
11 |
12 | #else /* !defined(UseInstalledMagick) */
13 |
14 | +#if 0
15 | {
16 | const char
17 | *magick_home;
18 | @@ -2024,6 +2025,7 @@
19 | #endif /* defined(POSIX) */
20 | }
21 | }
22 | +
23 |
24 | if (getenv("HOME") != (char *) NULL)
25 | {
26 | @@ -2034,6 +2036,7 @@
27 | *getenv("HOME") == '/' ? "/.magick" : "",DirectorySeparator);
28 | AddConfigurePath(path_map,&path_index,path,exception);
29 | }
30 | +#endif
31 |
32 | if (*SetClientPath((char *) NULL) != '\0')
33 | {
34 | @@ -2053,16 +2056,18 @@
35 | FormatString(path,"%.1024s/share/%s/",prefix,MagickShareConfigSubDir);
36 | AddConfigurePath(path_map,&path_index,path,exception);
37 | #else /* defined(POSIX) */
38 | - FormatString(path,"%.1024s%s",SetClientPath((char *) NULL),
39 | + FormatString(path,"%.1024s/share/GraphicsMagick/%s",SetClientPath((char *) NULL),
40 | DirectorySeparator);
41 | AddConfigurePath(path_map,&path_index,path,exception);
42 | #endif /* !defined(POSIX) */
43 | }
44 |
45 | +#if 0
46 | /*
47 | Search current directory.
48 | */
49 | AddConfigurePath(path_map,&path_index,"",exception);
50 | +#endif
51 | #endif /* !defined(UseInstalledMagick) */
52 |
53 | path_map_iterator=MagickMapAllocateIterator(path_map);
54 |
--------------------------------------------------------------------------------
/win32/patches/graphicsmagick/no-gm-build.diff:
--------------------------------------------------------------------------------
1 | Don't use the GM_BUILD_* macros.
2 |
3 | Last-Update: 2015-08-21
4 |
5 | --- a/magick/command.c
6 | +++ b/magick/command.c
7 | @@ -17126,6 +17126,7 @@ static MagickPassFail VersionCommand(Ima
8 | #endif /* defined(HasZLIB) */
9 | PrintFeature("ZLIB", supported);
10 |
11 | +#if 0
12 | #if defined(GM_BUILD_HOST)
13 | (void) fprintf(stdout,"\nHost type: %.1024s\n", GM_BUILD_HOST);
14 | #endif /* defined(GM_BUILD_HOST) */
15 | @@ -17163,6 +17164,7 @@ static MagickPassFail VersionCommand(Ima
16 | #if defined(GM_BUILD_LIBS)
17 | (void) fprintf(stdout," LIBS = %.1024s\n", GM_BUILD_LIBS);
18 | #endif /* defined(GM_BUILD_LIBS) */
19 | +#endif
20 |
21 | #if defined(_VISUALC_)
22 |
23 |
--------------------------------------------------------------------------------
/win32/patches/graphicsmagick/no-nt-feature.diff:
--------------------------------------------------------------------------------
1 | Disable some Windows-specific features.
2 |
3 | Last-Update: 2021-05-04
4 | --- a/magick/nt_feature.c
5 | +++ b/magick/nt_feature.c
6 | @@ -33,7 +33,7 @@
7 | */
8 |
9 | #include "magick/studio.h"
10 | -#if defined(MSWINDOWS) || defined(__CYGWIN__)
11 | +#if 0
12 | /*
13 | Include declarations.
14 | */
15 | --- a/magick/magick.c
16 | +++ b/magick/magick.c
17 | @@ -1378,7 +1378,7 @@ MagickExport MagickBool
18 | IsMagickConflict(const char *magick)
19 | {
20 | assert(magick != (char *) NULL);
21 | -#if defined(MSWINDOWS) || defined(__CYGWIN__)
22 | +#if 0
23 | return(NTIsMagickConflict(magick));
24 | #endif
25 | return(MagickFalse);
26 | --- a/magick/type.c
27 | +++ b/magick/type.c
28 | @@ -172,7 +172,7 @@ MagickExport const TypeInfo *GetTypeInfo
29 | if (type_list == (TypeInfo *) NULL)
30 | {
31 | (void) ReadTypeConfigureFile(TypeFilename,0,exception);
32 | -#if defined(MSWINDOWS) || defined(__CYGWIN__)
33 | +#if 0
34 | {
35 | TypeInfo
36 | *type_info;
37 | @@ -633,7 +633,7 @@ static unsigned int ReadTypeConfigureFil
38 | (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
39 | "File path=\"%.1024s\", recursion depth=%lu",basename,depth);
40 | (void) strlcpy(path,basename,sizeof(path));
41 | -#if defined(MSWINDOWS)
42 | +#if 0
43 | /*
44 | For Windows, cache the location of the Ghostscript fonts.
45 | */
46 |
--------------------------------------------------------------------------------
/win32/patches/graphicsmagick/series:
--------------------------------------------------------------------------------
1 | no-gm-build.diff
2 | no-nt-feature.diff
3 | config-paths.diff
4 |
--------------------------------------------------------------------------------
/win32/patches/libjpeg/automake-Wno-obsolete.diff:
--------------------------------------------------------------------------------
1 | Pass -Wno-obsolete to automake.
2 |
3 | Lat-Update: 2015-08-13
4 |
5 | --- a/configure.ac
6 | +++ b/configure.ac
7 | @@ -21,7 +21,7 @@
8 |
9 | # Initialize Automake
10 | # Don't require all the GNU mandated files
11 | -AM_INIT_AUTOMAKE([-Wall -Werror ansi2knr no-dist foreign])
12 | +AM_INIT_AUTOMAKE([-Wall -Werror -Wno-obsolete ansi2knr no-dist foreign])
13 |
14 | # Make --enable-silent-rules the default.
15 | # To get verbose build output you may configure
16 |
--------------------------------------------------------------------------------
/win32/patches/libjpeg/basetsd.h-conflict.diff:
--------------------------------------------------------------------------------
1 | Fix conflict between jmorecfg.h and MinGW32's basetsd.h.
2 |
3 | Fixes:
4 |
5 | .../pdf2djvu/win32/include/jmorecfg.h:161:14: error: conflicting declaration ‘typedef long int INT32’
6 | /usr/share/mingw-w64/include/basetsd.h:31:22: note: previous declaration as ‘typedef int INT32’
7 |
8 | Last-Update: 2017-12-10
9 |
10 | --- a/jmorecfg.h
11 | +++ b/jmorecfg.h
12 | @@ -129,6 +129,8 @@
13 | * typedefs live at a different point on the speed/space tradeoff curve.)
14 | */
15 |
16 | +#ifndef _BASETSD_H_
17 | +
18 | /* UINT8 must hold at least the values 0..255. */
19 |
20 | #ifdef HAVE_UNSIGNED_CHAR
21 | @@ -161,6 +163,8 @@
22 | typedef long INT32;
23 | #endif
24 |
25 | +#endif
26 | +
27 | /* Datatype used for image dimensions. The JPEG standard only supports
28 | * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
29 | * "unsigned int" is sufficient on all machines. However, if you need to
30 |
--------------------------------------------------------------------------------
/win32/patches/libjpeg/series:
--------------------------------------------------------------------------------
1 | automake-Wno-obsolete.diff
2 | basetsd.h-conflict.diff
3 |
--------------------------------------------------------------------------------
/win32/patches/poppler/disable-image-embedding.diff:
--------------------------------------------------------------------------------
1 | Disable ImageEmbeddingUtils.
2 |
3 | Last-Update: 2022-08-02
4 |
5 | --- a/poppler/ImageEmbeddingUtils.cc
6 | +++ b/poppler/ImageEmbeddingUtils.cc
7 | @@ -10,6 +10,8 @@
8 | //
9 | //========================================================================
10 |
11 | +#if 0
12 | +
13 | #include
14 |
15 | #include
16 | @@ -422,3 +424,5 @@ Ref embed(XRef *xref, const std::string
17 | }
18 |
19 | }
20 | +
21 | +#endif
22 | --- a/poppler/ImageEmbeddingUtils.h
23 | +++ b/poppler/ImageEmbeddingUtils.h
24 | @@ -8,6 +8,8 @@
25 | //
26 | //========================================================================
27 |
28 | +#if 0
29 | +
30 | #ifndef IMAGE_EMBEDDING_UTILS_H
31 | #define IMAGE_EMBEDDING_UTILS_H
32 |
33 | @@ -34,3 +36,5 @@ Ref POPPLER_PRIVATE_EXPORT embed(XRef *x
34 |
35 | }
36 | #endif
37 | +
38 | +#endif
39 | --- a/poppler/PDFDoc.cc
40 | +++ b/poppler/PDFDoc.cc
41 | @@ -2159,10 +2159,7 @@ bool PDFDoc::sign(const char *saveFilena
42 | }
43 | Ref imageResourceRef = Ref::INVALID();
44 | if (!imagePath.empty()) {
45 | - imageResourceRef = ImageEmbeddingUtils::embed(xref, imagePath);
46 | - if (imageResourceRef == Ref::INVALID()) {
47 | - return false;
48 | - }
49 | + abort();
50 | }
51 |
52 | Form *form = catalog->getCreateForm();
53 |
--------------------------------------------------------------------------------
/win32/patches/poppler/locale-open.diff:
--------------------------------------------------------------------------------
1 | Don't use Unicode API for opening files.
2 |
3 | Last-Update: 2022-08-02
4 |
5 | --- a/poppler/PDFDoc.cc
6 | +++ b/poppler/PDFDoc.cc
7 | @@ -127,7 +127,7 @@ PDFDoc::PDFDoc() { }
8 | PDFDoc::PDFDoc(std::unique_ptr &&fileNameA, const std::optional &ownerPassword, const std::optional &userPassword, void *guiDataA, const std::function &xrefReconstructedCallback)
9 | : fileName(std::move(fileNameA)), guiData(guiDataA)
10 | {
11 | -#ifdef _WIN32
12 | +#if 0
13 | const int n = fileName->getLength();
14 | fileNameU = (wchar_t *)gmallocn(n + 1, sizeof(wchar_t));
15 | for (int i = 0; i < n; ++i) {
16 |
--------------------------------------------------------------------------------
/win32/patches/poppler/mutex.diff:
--------------------------------------------------------------------------------
1 | Use dummy implementation of mutexes.
2 |
3 | Last-Update: 2022-08-02
4 |
5 | --- a/poppler/Annot.h
6 | +++ b/poppler/Annot.h
7 | @@ -53,7 +53,7 @@
8 |
9 | #include
10 | #include
11 | -#include
12 | +#include
13 | #include
14 |
15 | #include "AnnotStampImageHelper.h"
16 | --- a/poppler/Array.h
17 | +++ b/poppler/Array.h
18 | @@ -29,7 +29,7 @@
19 | #define ARRAY_H
20 |
21 | #include
22 | -#include
23 | +#include
24 | #include
25 |
26 | #include "poppler-config.h"
27 | --- a/poppler/CairoFontEngine.h
28 | +++ b/poppler/CairoFontEngine.h
29 | @@ -32,7 +32,7 @@
30 | #define CAIROFONTENGINE_H
31 |
32 | #include
33 | -#include
34 | +#include
35 | #include
36 | #include
37 |
38 | --- a/poppler/Dict.h
39 | +++ b/poppler/Dict.h
40 | @@ -31,7 +31,7 @@
41 | #define DICT_H
42 |
43 | #include
44 | -#include
45 | +#include
46 | #include
47 | #include
48 | #include
49 | --- a/poppler/GlobalParams.h
50 | +++ b/poppler/GlobalParams.h
51 | @@ -47,7 +47,7 @@
52 | #include
53 | #include
54 | #include
55 | -#include
56 | +#include
57 | #include
58 |
59 | class GooString;
60 | --- a/poppler/PDFDoc.h
61 | +++ b/poppler/PDFDoc.h
62 | @@ -49,7 +49,7 @@
63 |
64 | #include
65 | #include
66 | -#include
67 | +#include
68 |
69 | #include "poppler-config.h"
70 |
71 | --- a/poppler/Page.h
72 | +++ b/poppler/Page.h
73 | @@ -36,7 +36,7 @@
74 | #define PAGE_H
75 |
76 | #include
77 | -#include
78 | +#include
79 |
80 | #include "poppler-config.h"
81 | #include "Object.h"
82 |
--------------------------------------------------------------------------------
/win32/patches/poppler/poppler-data-path.diff:
--------------------------------------------------------------------------------
1 | Adapt get_poppler_datadir() to pdf2djvu needs.
2 |
3 | Last-Update: 2022-08-02
4 |
5 | --- a/poppler/GlobalParams.cc
6 | +++ b/poppler/GlobalParams.cc
7 | @@ -126,11 +126,11 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,
8 |
9 | static std::string get_poppler_localdir(const std::string &suffix)
10 | {
11 | - const std::string binSuffix("\\bin");
12 | + const std::string binSuffix("");
13 | std::string retval(MAX_PATH, '\0');
14 |
15 | if (!GetModuleFileNameA(hmodule, retval.data(), retval.size())) {
16 | - return POPPLER_DATADIR;
17 | + abort();
18 | }
19 |
20 | const std::string::size_type p = retval.rfind('\\');
21 |
--------------------------------------------------------------------------------
/win32/patches/poppler/series:
--------------------------------------------------------------------------------
1 | poppler-data-path.diff
2 | strndup.diff
3 | mutex.diff
4 | locale-open.diff
5 | disable-image-embedding.diff
6 |
--------------------------------------------------------------------------------
/win32/patches/poppler/strndup.diff:
--------------------------------------------------------------------------------
1 | Add strndup(3) implementation.
2 |
3 | Last-Update: 2022-08-02
4 |
5 | --- a/poppler/GlobalParams.cc
6 | +++ b/poppler/GlobalParams.cc
7 | @@ -715,6 +715,17 @@ static const char *getFontLang(const Gfx
8 | return lang;
9 | }
10 |
11 | +static char *strndup(const char *s, size_t n)
12 | +{
13 | + size_t len = strnlen(s, n);
14 | + char *ds = (char*) malloc(len + 1);
15 | + if (ds == NULL)
16 | + return NULL;
17 | + memcpy(ds, s, len);
18 | + ds[len] = '\0';
19 | + return ds;
20 | +}
21 | +
22 | static FcPattern *buildFcPattern(const GfxFont *font, const GooString *base14Name)
23 | {
24 | int weight = -1, slant = -1, width = -1, spacing = -1;
25 |
--------------------------------------------------------------------------------
/win32/patches/winiconv/no-const.diff:
--------------------------------------------------------------------------------
1 | Don't use const in the prototype.
2 |
3 | Last-Update: 2021-05-04
4 |
5 | --- a/iconv.h
6 | +++ b/iconv.h
7 | @@ -1,6 +1,7 @@
8 | #ifndef _LIBICONV_H
9 | #define _LIBICONV_H
10 | #include
11 | +#define WINICONV_CONST
12 | #ifndef WINICONV_CONST
13 | # ifdef ICONV_CONST
14 | # define WINICONV_CONST ICONV_CONST
15 |
--------------------------------------------------------------------------------
/win32/patches/winiconv/series:
--------------------------------------------------------------------------------
1 | no-const.diff
2 |
--------------------------------------------------------------------------------
/win32/tools/enforce-relative-paths:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 |
3 | # Copyright © 2017-2022 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | use strict;
17 | use warnings;
18 |
19 | use Cwd qw(getcwd realpath);
20 | use File::Spec qw();
21 | use FindBin qw();
22 |
23 | my $here = $FindBin::Bin;
24 | my $root = realpath("$here/..");
25 |
26 | sub relativize
27 | {
28 | my ($path) = @_;
29 | if ($path =~ m{\A\Q$root\E/}) {
30 | $path = File::Spec->abs2rel($path)
31 | } elsif ($path =~ /\A@/) {
32 | $path = substr($path, 1);
33 | my $tmppath = "$path.tmp";
34 | open(my $fh, '<', $path) or die "$path: $!";
35 | {
36 | local $/ = undef;
37 | $_ = <$fh>;
38 | s{(?:\A|[\s"'])(?:-I)?\K(\Q$root\E)(?=/|\s|\z)}{File::Spec->abs2rel($1)}eg;
39 | }
40 | close($fh);
41 | open($fh, '>', "$path.tmp") or die "$path.tmp: $!";
42 | print {$fh} $_;
43 | close($fh);
44 | rename("$path.tmp", "$path.rel") or die "$path.rel: $!";
45 | $path = "\@$path.rel";
46 | }
47 | return $path;
48 | }
49 |
50 | my @argv = map { relativize($_); } @ARGV;
51 | exec { $argv[0] } @argv or die;
52 |
53 | # vim:ts=4 sts=4 sw=4 et
54 |
--------------------------------------------------------------------------------
/win32/tools/wget:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright © 2015-2020 Jakub Wilk
4 | #
5 | # This file is part of pdf2djvu.
6 | #
7 | # pdf2djvu is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License version 2 as
9 | # published by the Free Software Foundation.
10 | #
11 | # pdf2djvu is distributed in the hope that it will be useful, but
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 |
16 | usage()
17 | {
18 | printf '%s [-n NAME] URL SHA256SUM\n' "$0"
19 | }
20 |
21 | set -e -u
22 |
23 | args=$(getopt -n "$0" -o 'hn:' --long 'help' -- "$@") || {
24 | usage >&2
25 | exit 1
26 | }
27 | name=
28 | eval set -- "$args"
29 | while true
30 | do
31 | case "$1" in
32 | -h|--help) usage; exit 0;;
33 | -n) name="$2"; shift 2;;
34 | --) shift; break;;
35 | *) printf '%s: internal error (%s)\n' "$0" "$1" >&2; exit 1;;
36 | esac
37 | done
38 | if [ $# -ne 2 ]
39 | then
40 | usage >&2
41 | exit 1
42 | fi
43 | url="$1"
44 | sha256sum="$2"
45 | [ -n "$name" ] || name=${url##*/}
46 |
47 | set -e
48 |
49 | here=${0%/*}
50 | mkdir -p "$here/../src.tar"
51 | cd "$here/../src.tar"
52 |
53 | if [ -e "$name" ] && echo "$sha256sum $name" | sha256sum --strict -c
54 | then
55 | exit 0
56 | fi
57 |
58 | if [ -z "${PDF2DJVU_DOWNLOAD-}" ]
59 | then
60 | printf 'src.tar/%s is missing.\n' "$name" >&2
61 | printf 'Set PDF2DJVU_DOWNLOAD=1 to download it automatically.\n' >&2
62 | exit 1
63 | fi
64 |
65 | wget -c "$url" -O "$name"
66 |
67 | echo "$sha256sum $name" | sha256sum --strict -c
68 |
69 | # vim:ts=4 sts=4 sw=4 et
70 |
--------------------------------------------------------------------------------
/xmp.hh:
--------------------------------------------------------------------------------
1 | /* Copyright © 2009-2022 Jakub Wilk
2 | *
3 | * This file is part of pdf2djvu.
4 | *
5 | * pdf2djvu is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | *
9 | * pdf2djvu is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | */
14 |
15 | #ifndef PDF2DJVU_XMP_H
16 | #define PDF2DJVU_XMP_H
17 |
18 | #include
19 | #include
20 |
21 | #include "pdf-backend.hh"
22 |
23 | namespace xmp
24 | {
25 | std::string transform(const std::string &data, const pdf::Metadata &metadata);
26 |
27 | class Error : public std::runtime_error
28 | {
29 | public:
30 | explicit Error(const std::string &message)
31 | : std::runtime_error(message)
32 | { }
33 | };
34 | }
35 |
36 | #endif
37 |
38 | // vim:ts=4 sts=4 sw=4 et
39 |
--------------------------------------------------------------------------------