pkg update and first config fix
org-brain not working, add org-roam
This commit is contained in:
@@ -11,209 +11,173 @@
|
||||
|
||||
The ~pdf-tools~ Wiki is maintained at https://pdftools.wiki. Head to the site if you find it easier to navigate a website for reading a manual. All the topics on the site are listed at https://pdftools.wiki/impulse.
|
||||
|
||||
* Table of Contents :noexport:TOC_3_org:
|
||||
- [[About PDF Tools][About PDF Tools]]
|
||||
- [[Installing pdf-tools][Installing pdf-tools]]
|
||||
- [[Installing the epdfinfo server][Installing the epdfinfo server]]
|
||||
- [[Installing the epdfinfo server from package managers][Installing the epdfinfo server from package managers]]
|
||||
- [[Installing the epdfinfo server from source on Windows (+ Gotchas)][Installing the epdfinfo server from source on Windows (+ Gotchas)]]
|
||||
- [[Installing the epdfinfo server from source on macOS (+ Gotchas)][Installing the epdfinfo server from source on macOS (+ Gotchas)]]
|
||||
- [[Common installation gotchas][Common installation gotchas]]
|
||||
- [[Installing optional features][Installing optional features]]
|
||||
- [[Installing pdf-tools elisp code][Installing pdf-tools elisp code]]
|
||||
- [[Updating pdf-tools][Updating pdf-tools]]
|
||||
- [[Features][Features]]
|
||||
- [[View and Navigate PDFs][View and Navigate PDFs]]
|
||||
- [[Keybindings for navigating PDF documents][Keybindings for navigating PDF documents]]
|
||||
- [[Keybindings for manipulating display of PDF][Keybindings for manipulating display of PDF]]
|
||||
- [[Annotations][Annotations]]
|
||||
- [[Keybindings for working with Annotations][Keybindings for working with Annotations]]
|
||||
- [[Working with AUCTeX][Working with AUCTeX]]
|
||||
- [[Keybindings for working with AUCTeX][Keybindings for working with AUCTeX]]
|
||||
- [[Miscellaneous features][Miscellaneous features]]
|
||||
- [[Keybindings for miscellaneous features in PDF tools][Keybindings for miscellaneous features in PDF tools]]
|
||||
- [[Easy Help for PDF Tools features][Easy Help for PDF Tools features]]
|
||||
- [[Configuring PDF Tools features][Configuring PDF Tools features]]
|
||||
- [[Known problems][Known problems]]
|
||||
- [[linum-mode][linum-mode]]
|
||||
- [[display-line-numbers-mode][display-line-numbers-mode]]
|
||||
- [[auto-revert][auto-revert]]
|
||||
- [[sublimity][sublimity]]
|
||||
- [[Text selection is not transparent in PDFs OCRed with Tesseract][Text selection is not transparent in PDFs OCRed with Tesseract]]
|
||||
- [[Key-bindings in PDF Tools][Key-bindings in PDF Tools]]
|
||||
- [[Tips and Tricks for Developers][Tips and Tricks for Developers]]
|
||||
- [[Turn on debug mode][Turn on debug mode]]
|
||||
- [[Run Emacs lisp tests locally][Run Emacs lisp tests locally]]
|
||||
- [[Run server compilation tests locally][Run server compilation tests locally]]
|
||||
- [[Add a Dockerfile to automate server compilation testing][Add a Dockerfile to automate server compilation testing]]
|
||||
- [[FAQs][FAQs]]
|
||||
- [[PDFs are not rendering well!][PDFs are not rendering well!]]
|
||||
- [[What Emacs versions does pdf-tools support?][What Emacs versions does pdf-tools support?]]
|
||||
- [[I want to add support for pdf-tools on "My Fav OS". How do I do that?][I want to add support for pdf-tools on "My Fav OS". How do I do that?]]
|
||||
- [[I am on a Macbook M1 and pdf-tools installation fails with a stack-trace][I am on a Macbook M1 and pdf-tools installation fails with a stack-trace]]
|
||||
- [[I am a developer, making changes to the pdf-tools source code][I am a developer, making changes to the pdf-tools source code]]
|
||||
|
||||
* About PDF Tools
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: 5a884389-6aec-498a-90d5-f37168809b4f
|
||||
:EXPORT_FILE_NAME: index
|
||||
:END:
|
||||
PDF Tools is, among other things, a replacement of DocView for PDF files. The key difference is that pages are not pre-rendered by e.g. ghostscript and stored in the file-system, but rather created on-demand and stored in memory.
|
||||
PDF Tools is, among other things, a replacement of DocView for PDF files. The key difference is that pages are not pre-rendered by, say, ~ghostscript~ and stored in the file-system, but rather created on-demand and stored in memory.
|
||||
|
||||
This rendering is performed by a special library named, for whatever reason, ~poppler~, running inside a server program. This program is called ~epdfinfo~ and its job is to successively read requests from Emacs and produce the proper results, i.e. the PNG image of a PDF page.
|
||||
|
||||
Actually, displaying PDF files is just one part of ~pdf-tools~. Since ~poppler~ can provide us with all kinds of information about a document and is also able to modify it, there is a lot more we can do with it. [[http://www.dailymotion.com/video/x2bc1is_pdf-tools-tourdeforce_tech?forcedQuality%3Dhd720][Watch this video for a detailed demo!]]
|
||||
Actually, displaying PDF files is just one part of ~pdf-tools~. Since ~poppler~ can provide us with all kinds of information about a document and is also able to modify it, there is a lot more we can do with it. [[https://www.dailymotion.com/video/x2bc1is][Watch this video for a detailed demo!]]
|
||||
|
||||
* Installing ~pdf-tools~
|
||||
* Installing pdf-tools
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: 6ceea50c-cbaa-4d8a-b450-8067c5e8c9da
|
||||
:NEURON_DIRTREE_DISPLAY: false
|
||||
:END:
|
||||
Installing this package via NonGNU ELPA or MELPA or any of the other package managers is straightforward and should just work.
|
||||
~pdf-tools~ requires a server ~epdfinfo~ to run against, which it will try to compile and build when it is activated for the first time.
|
||||
Installing this package via NonGNU ELPA or MELPA or any of the other package managers is straightforward and should just work! You should not require any manual changes. The documentation below is *only if you are installing from source*, or for troubleshooting / debugging purposes.
|
||||
|
||||
You should not require any manual changes. The documentation below is if you are installing from source, or for troubleshooting / debugging purposes.
|
||||
~pdf-tools~ requires a server ~epdfinfo~ to run against, which it will try to compile and build when it is activated for the first time. The following steps need to be followed *in this order*, to install ~pdf-tools~ and ~epdfinfo~ correctly:
|
||||
|
||||
- [[brain-child:8ce3cf4e-d186-4de1-a40e-f41063068ab0][Installing ~epdfinfo~ server prerequisites]]
|
||||
- [[brain-child:e305cd0a-e798-4c2b-af27-21bcd936c1c9][Compiling and Installing the ~epdfinfo~ server]]
|
||||
- [[brain-child:3d4e6b6b-f015-475d-8ea2-84988efd6c22][Installing ~pdf-tools~ elisp prerequisites]]
|
||||
- [[brain-child:32c4fc3b-b4ea-43bd-b92c-bdf2d3831fcf][Installing ~pdf-tools~ elisp code]]
|
||||
- [[brain-child:e305cd0a-e798-4c2b-af27-21bcd936c1c9][Installing the epdfinfo server]]
|
||||
- [[brain-child:32c4fc3b-b4ea-43bd-b92c-bdf2d3831fcf][Installing pdf-tools elisp code]]
|
||||
|
||||
** Installing ~epdfinfo~ server prerequisites
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: 8ce3cf4e-d186-4de1-a40e-f41063068ab0
|
||||
:END:
|
||||
You'll need GNU Emacs \ge 24.3 and some form of a GNU/Linux OS. Other operating systems are not officially supported, but ~pdf-tools~ is known to work on many of them. See links below for more details. The following instructions assume a Debian-based system.
|
||||
|
||||
First make sure a suitable build-system is installed. We need at least a C/C++ compiler (both ~gcc~ and ~g++~), ~make~, ~automake~ and ~autoconf~.
|
||||
|
||||
Next we need to install a few libraries ~pdf-tools~ depends on, some of which are probably already on your system.
|
||||
#+begin_src sh
|
||||
$ sudo apt install libpng-dev zlib1g-dev libpoppler-glib-dev libpoppler-private-dev
|
||||
#+end_src
|
||||
|
||||
On some older Ubuntu systems, the final command will possibly give an error. This should be no problem, since in some versions this package was contained in the main package ~libpoppler-dev~. Also note, that ~zlib1g-dev~ was for a long time called ~libz-dev~, which it still may be on your system.
|
||||
|
||||
Debian wheezy comes with ~libpoppler~ version ~0.18~, which is pretty old. The minimally required version is ~0.16~, but some features of ~pdf-tools~ depend on a more recent version of this library. See the following table for what they are and what version they require.
|
||||
|
||||
| You want to ... | Required version |
|
||||
|-------------------------------------------+------------------|
|
||||
| ... create and modify text annotations. | \ge 0.19.4 |
|
||||
| ... search case-sensitive. | \ge 0.22 |
|
||||
| ... create and modify markup annotations. | \ge 0.26 |
|
||||
|-------------------------------------------+------------------|
|
||||
|
||||
In case you decide to install ~libpoppler~ from source, make sure to run its configure script with the ~--enable-xpdf-headers~ option.
|
||||
|
||||
Finally there is one feature (following links of a PDF document by plain keystrokes) which requires imagemagick's convert utility. This requirement is optional and you may install it like so:
|
||||
#+begin_src sh
|
||||
$ sudo apt install imagemagick
|
||||
#+end_src
|
||||
*** Installing Server Prerequisites On macOS
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: f10e9d94-bdec-44dc-8d3c-1816d62ef1c4
|
||||
:END:
|
||||
Although macOS is not officially supported, it has been reported that ~pdf-tools~ works well on macOS. You will need to install ~poppler~ which you can get with Homebrew via
|
||||
#+BEGIN_SRC sh
|
||||
$ brew install poppler automake
|
||||
#+END_SRC
|
||||
|
||||
You will also have to help ~pkg-config~ find some libraries by setting ~PKG_CONFIG_PATH~, e.g.
|
||||
#+BEGIN_SRC sh
|
||||
$ export PKG_CONFIG_PATH=/usr/local/Cellar/zlib/1.2.8/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
|
||||
#+END_SRC
|
||||
or likewise within Emacs using ~setenv~.
|
||||
|
||||
After that, compilation should proceed as normal.
|
||||
*** Installing Server Prerequisites On FreeBSD
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: 00faf3e3-6d09-4cf7-9373-838f3d231504
|
||||
:END:
|
||||
Although not officially supported, it has been reported that ~pdf-tools~ work well on FreeBSD. Instead of building ~pdf-tools~, you can install one of the OS packages with e.g.
|
||||
#+BEGIN_SRC sh
|
||||
$ pkg install pdf-tools-emacs26
|
||||
#+END_SRC
|
||||
|
||||
To see the current list of ~pdf-tools~ packages for FreeBSD visit [[https://repology.org/metapackages/?search=pdf-tools&inrepo=freebsd][the Repology list]].
|
||||
|
||||
To build ~pdf-tools~ from either MELPA or directly from the source repository, install the dependencies with
|
||||
#+BEGIN_SRC sh
|
||||
$ pkg install autotools gmake poppler-glib
|
||||
#+END_SRC
|
||||
|
||||
If you choose not to install from MELPA, you must substitute ~gmake~ for ~make~ in the instructions below.
|
||||
*** Installing Server Prerequisites On CentOS
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: e39946d0-3a28-405d-bb23-337120412dac
|
||||
:END:
|
||||
#+BEGIN_SRC sh
|
||||
$ yum install poppler-devel poppler-glib-devel
|
||||
#+END_SRC
|
||||
|
||||
*** Installing Server Prerequisites On Fedora
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: d0013822-f4d0-4354-b3db-c54ffe41ce58
|
||||
:END:
|
||||
#+BEGIN_SRC sh
|
||||
$ sudo dnf install make automake autoconf gcc gcc-c++ ImageMagick libpng-devel zlib-devel poppler-glib-devel
|
||||
#+END_SRC
|
||||
|
||||
*** Installing Server Prerequisites On Alpine Linux
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: 443d9b18-096e-4770-b59c-4e472a5d4b0e
|
||||
:END:
|
||||
#+BEGIN_SRC sh
|
||||
$ apk add build-base g++ gcc automake autoconf libpng-dev glib-dev poppler-dev
|
||||
#+END_SRC
|
||||
|
||||
*** Installing Server Prerequisites On Windows
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: 005243cb-1557-4f94-a73d-e647e0d4b53d
|
||||
:END:
|
||||
~pdf-tools~ can be built and used on Windows using the MSYS2 compiler. This will work with native (not cygwin) Windows builds of Emacs. This includes the standard binaries provided by the GNU project, those available as MSYS2 packages and numerous third-party binaries. It has been tested with Emacs 25.1. Instructions are provided under [[id:d14e01ff-9bd5-47ee-86fc-859b4499d5d7][Compilation and installation on Window]] below. ~pdf-tools~ will successfully compile using Cygwin, but it will not be able to open PDFs properly due to the way binaries compiled with Cygwin handle file paths.
|
||||
|
||||
** Compiling and Installing the ~epdfinfo~ server
|
||||
** Installing the epdfinfo server
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: e305cd0a-e798-4c2b-af27-21bcd936c1c9
|
||||
:END:
|
||||
If you install ~pdf-tools~ via NonGNU ELPA or MELPA, *you don't need to worry about this separate server installation at all*.
|
||||
|
||||
Note: You'll need GNU Emacs \ge 26.3 and some form of a GNU/Linux OS. Other operating systems are not officially supported, but ~pdf-tools~ is known to work on many of them.
|
||||
|
||||
The ~epdfinfo~ install script takes care of installing all the necessary pre-requisites on supported operating systems (see list below). See the section on [[id:A34704B9-1B51-4614-8806-C4059F7B42D5][I want to add support for ~pdf-tools~ on =My Fav OS=. How do I do that?]] to learn how to add your favorite Operating System to this list.
|
||||
|
||||
Similarly, package-managers are not officially supported, but ~pdf-tools~ is known to be available on some of them. See the section on [[id:fb5cef15-fed4-4dec-a443-52f7c00c7831][Installing the ~epdfinfo~ server from package managers]] to avoid manual installation of server / server prerequisites.
|
||||
|
||||
Installation Instructions for ~epdfinfo~:
|
||||
#+begin_src sh
|
||||
$ cd /path/to/pdf-tools
|
||||
$ make -s
|
||||
$ git clone https://github.com/vedang/pdf-tools
|
||||
$ cd /path/to/pdf-tools
|
||||
$ make -s # If you don't have make installed, run ./server/autobuild and it will install make
|
||||
#+end_src
|
||||
|
||||
This should compile the source code and create a Emacs Lisp Package in the root directory of the project. The configure script also tells you at the very end, which features, depending on the libpoppler version, will be available. These commands should give no error, otherwise you are in trouble.
|
||||
*** On Windows
|
||||
This should give you no error and should compile the ~epdfinfo~ server. If you face a problem, please report on the issue tracker!
|
||||
|
||||
The following Operating Systems / package managers are supported. *Note*: The package manager used to install pre-requisites should be installed on your OS for the script to work:
|
||||
|
||||
- Debian-based systems (~debian~, ~ubuntu~): ~apt-get~
|
||||
- Fedora: ~dnf~
|
||||
- macOS: ~brew~
|
||||
- Windows (MSYS2/ MingW): ~pacman~
|
||||
- NixOS: ~nix-shell~
|
||||
- openSUSE (Tumbleweed and Leap): ~zypper~
|
||||
- Void Linux: ~xbps-install~
|
||||
- Apline Linux: ~apk~
|
||||
- FreeBSD: ~pkg~
|
||||
- OpenBSD: ~pkg_add~
|
||||
- NetBSD: ~pkgin~
|
||||
- Arch Linux: ~pacman~
|
||||
- Gentoo: ~emerge~
|
||||
- CentOS: ~yum~
|
||||
|
||||
*** Installing the epdfinfo server from package managers
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-02-13 Sun 23:10]
|
||||
:ID: fb5cef15-fed4-4dec-a443-52f7c00c7831
|
||||
:END:
|
||||
~pdf-tools~ can be directly installed from the package manager on some operating systems. Note that the packages available on these package managers are not maintained by the author and might be outdated.
|
||||
|
||||
- Debian: https://packages.debian.org/buster/elpa-pdf-tools-server
|
||||
- Ubuntu: https://packages.ubuntu.com/impish/elpa-pdf-tools-server
|
||||
- MSYS2 / MINGW (Windows): https://packages.msys2.org/package/mingw-w64-x86_64-emacs-pdf-tools-server?repo=mingw64
|
||||
- FreeBSD: https://repology.org/metapackages/?search=pdf-tools&inrepo=freebsd
|
||||
|
||||
*** Installing the epdfinfo server from source on Windows (+ Gotchas)
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: d14e01ff-9bd5-47ee-86fc-859b4499d5d7
|
||||
:END:
|
||||
If using the GNU binaries for Windows, support for PNG and ~zlib~ must first be installed by copying the appropriate dlls into emacs' ~bin/~ directory. Most third-party binaries come with this already done.
|
||||
|
||||
First, install [[http://www.msys2.org/][install MSYS2]] and update the package database and core packages using the instructions provided. Then, to compile ~pdf-tools~ itself:
|
||||
1. [[https://www.msys2.org/][install MSYS2]] and update the package database and core packages using the instructions provided.
|
||||
2. Open ~mingw64~ shell (*Note:* You must use ~mingw64.exe~ and not ~msys2.exe~)
|
||||
3. Compile the ~epdfinfo~ server using Installation steps described in [[id:e305cd0a-e798-4c2b-af27-21bcd936c1c9][Installing the ~epdfinfo~ server]]
|
||||
4. This should produce a file ~server/epdfinfo.exe~. Copy this file into the ~pdf-tools/~ installation directory in your Emacs.
|
||||
5. Make sure Emacs can find ~epdfinfo.exe~. Either add the MINGW install location (e.g. ~C:/msys2/mingw64/bin~) to the system path with ~setx PATH "C:\msys2\mingw64\bin;%PATH%"~ or set Emacs's path with ~(setenv "PATH" (concat "C:\\msys64\\mingw64\\bin;" (getenv "PATH")))~. Note that libraries from other GNU utilities, such as Git for Windows, may interfere with those needed by ~pdf-tools~. ~pdf-info-check-epdinfo~ will succeed, but errors occur when trying to view a PDF file. This can be fixed by ensuring that the MSYS libraries are always preferred.
|
||||
6. ~pdf-tools~ will successfully compile using Cygwin, but it will not be able to open PDFs properly due to the way binaries compiled with Cygwin handle file paths. Please use MSYS2.
|
||||
|
||||
1. Open msys2 shell
|
||||
2. Update and install dependencies, skipping any you already have
|
||||
#+BEGIN_SRC sh
|
||||
$ pacman -Syu
|
||||
$ pacman -S base-devel
|
||||
$ pacman -S mingw-w64-x86_64-toolchain
|
||||
$ pacman -S mingw-w64-x86_64-zlib
|
||||
$ pacman -S mingw-w64-x86_64-libpng
|
||||
$ pacman -S mingw-w64-x86_64-poppler
|
||||
$ pacman -S mingw-w64-x86_64-imagemagick
|
||||
#+END_SRC
|
||||
3. Install ~pdf-tools~ in Emacs, but do not try to compile the server. Instead, get a separate copy of the source somewhere else.
|
||||
#+BEGIN_SRC sh
|
||||
$ git clone https://github.com/vedang/pdf-tools
|
||||
#+END_SRC
|
||||
4. Open ~mingw64~ shell (*Note:* You must use ~mingw64.exe~ and not ~msys2.exe~)
|
||||
5. Compile pdf-tools
|
||||
#+BEGIN_SRC sh
|
||||
$ cd /path/to/pdf-tools
|
||||
$ make -s
|
||||
#+END_SRC
|
||||
6. This should produce a file ~server/epdfinfo.exe~. Copy this file into the ~pdf-tools/~ installation directory in your Emacs.
|
||||
7. Start Emacs and activate the package.
|
||||
#+BEGIN_SRC
|
||||
M-x pdf-tools-install RET
|
||||
#+END_SRC
|
||||
8. Test.
|
||||
#+BEGIN_SRC
|
||||
M-x pdf-info-check-epdfinfo RET
|
||||
#+END_SRC
|
||||
|
||||
If this is successful, ~(pdf-tools-install)~ can be added to Emacs' config. Note that libraries from other GNU utilities, such as Git for Windows, may interfere with those needed by ~pdf-tools~. ~pdf-info-check-epdinfo~ will succeed, but errors occur when trying to view a PDF file. This can be fixed by ensuring that the MSYS libraries are always preferred in Emacs:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setenv "PATH" (concat "C:\\msys64\\mingw64\\bin;" (getenv "PATH")))
|
||||
#+END_SRC
|
||||
|
||||
** Installing ~pdf-tools~ elisp prerequisites
|
||||
*** Installing the epdfinfo server from source on macOS (+ Gotchas)
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: 3d4e6b6b-f015-475d-8ea2-84988efd6c22
|
||||
:CREATED: [2022-10-11 Tue 11:42]
|
||||
:ID: 60CBCD65-5654-400A-913F-8B31901D071C
|
||||
:END:
|
||||
This package depends on the following Elisp packages, which should be installed before installing the ~pdf-tools~ package.
|
||||
| Package | Required version |
|
||||
|-----------+----------------------------------|
|
||||
| [[https://elpa.gnu.org/packages/let-alist.html][let-alist]] | >= 1.0.4 (comes with Emacs 25.2) |
|
||||
| [[http://melpa.org/#/tablist][tablist]] | >= 0.70 |
|
||||
|-----------+----------------------------------|
|
||||
On macOS, ~autobuild~ adjusts ~PKG_CONFIG_PATH~ so that ~pdf-tools~ can find some of the keg-only packages installed by ~brew~. It is recommended that you review the output logs printed by ~brew~ during the installation process to also export the relevant paths to the appropriate ENV variables.
|
||||
|
||||
** Installing ~pdf-tools~ elisp code
|
||||
*** Common installation gotchas
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-10-11 Tue 11:04]
|
||||
:ID: 3F4C0FDF-6AC0-4845-BA2D-ED7C2F40D894
|
||||
:END:
|
||||
In case you decide to install ~libpoppler~ from source, make sure to run its configure script with the ~--enable-xpdf-headers~ option.
|
||||
|
||||
*** Installing optional features
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-10-11 Tue 11:15]
|
||||
:ID: 97FC4447-B567-457F-A498-7CCA74DD5657
|
||||
:END:
|
||||
One feature -- following links of a PDF document by plain keystrokes -- requires ~imagemagick~'s convert utility. This requirement is optional, the installation process will detect if you have ~imagemagick~ installed or not.
|
||||
** Installing pdf-tools elisp code
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: 32c4fc3b-b4ea-43bd-b92c-bdf2d3831fcf
|
||||
:END:
|
||||
If ~make~ produced the ELP file ~pdf-tools-${VERSION}.tar~ you are fine. This package contains all the necessary files for Emacs and may be installed by either using
|
||||
~pdf-tools~ requires ~tablist~ package (>= version 0.70) to be installed, for it to work correctly. Please make sure that the latest version of ~tablist~ is installed.
|
||||
|
||||
We have already run the steps necessary to install ~pdf-tools~ as part of [[id:e305cd0a-e798-4c2b-af27-21bcd936c1c9][the server installation]]! These are:
|
||||
#+BEGIN_SRC sh
|
||||
$ git clone https://github.com/vedang/pdf-tools
|
||||
$ cd /path/to/pdf-tools
|
||||
$ make -s
|
||||
#+END_SRC
|
||||
|
||||
If the ~make~ command produced the ELP file ~pdf-tools-${VERSION}.tar~ you are fine! This package contains all the necessary files for Emacs and may be installed by either using
|
||||
#+begin_src sh
|
||||
$ make install-package
|
||||
#+end_src
|
||||
@@ -222,6 +186,11 @@ or executing the Emacs command
|
||||
M-x package-install-file RET pdf-tools-${VERSION}.tar RET
|
||||
#+end_src
|
||||
|
||||
You can test if the package has been installed correctly, by running
|
||||
#+begin_src elisp
|
||||
M-x pdf-info-check-epdfinfo RET
|
||||
#+end_src
|
||||
|
||||
To complete the installation process, you need to activate the package by putting the code below somewhere in your ~.emacs~. Alternatively, and if you care about startup time, you may want to use the loader version instead.
|
||||
#+begin_src elisp
|
||||
(pdf-tools-install) ; Standard activation command
|
||||
@@ -229,14 +198,15 @@ To complete the installation process, you need to activate the package by puttin
|
||||
#+end_src
|
||||
|
||||
Once the Installation process is complete, check out [[id:19a3daea-6fa6-4ac3-9201-d2034c46ad8c][Easy Help for PDF Tools features]] and [[id:8dccd685-18b8-4c98-977a-0fe2d66b724c][Configuring PDF Tools features]] to get started!
|
||||
** Updating ~pdf-tools~
|
||||
** Updating pdf-tools
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
:ID: 9dd62314-f5ad-4bd4-83fa-8e28343e3d9c
|
||||
:END:
|
||||
Some day you might want to update this package via ~git pull~ and then reinstall it. Sometimes this may fail, especially if Lisp-Macros are involved and the version hasn't changed. To avoid this kind of problems, you should delete the old package via ~list-packages~, restart Emacs and then reinstall the package.
|
||||
Some day you might want to update this package via ~git pull~ and then reinstall it. Sometimes this may fail, especially if Lisp-Macros are involved and the version hasn't changed. To avoid this kind of problems, you should delete the old package via ~list-packages~, restart Emacs, run ~make distclean~ and then reinstall the package. Follow the steps described in [[id:32c4fc3b-b4ea-43bd-b92c-bdf2d3831fcf][Installing pdf-tools elisp code]].
|
||||
|
||||
This also applies when updating via MELPA / NonGNU ELPA (except for running the ~make distclean~ step).
|
||||
|
||||
This also applies when updating via package and MELPA.
|
||||
* Features
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
@@ -267,26 +237,25 @@ PDFView Mode is an Emacs PDF viewer. It displays PDF files as PNG images in Emac
|
||||
:CREATED: [2021-12-30 Thu 18:25]
|
||||
:ID: 01864499-2286-4e64-91f5-f8133f53ec61
|
||||
:END:
|
||||
| Navigation | |
|
||||
|-----------------------------------------------+-----------------------|
|
||||
| Scroll Up / Down by Page-full | ~space~ / ~backspace~ |
|
||||
| Scroll Up / Down by Line | ~C-n~ / ~C-p~ |
|
||||
| Scroll Right / Left | ~C-f~ / ~C-b~ |
|
||||
| First Page / Last Page | ~<~ / ~>~ |
|
||||
| Next Page / Previous Page | ~n~ / ~p~ |
|
||||
| First Page / Last Page | ~M-<~ / ~M->~ |
|
||||
| Incremental Search Forward / Backward | ~C-s~ / ~C-r~ |
|
||||
| Occur (list all lines containing a phrase) | ~M-s o~ |
|
||||
| Jump to Occur Line | ~RETURN~ |
|
||||
| Pick a Link and Jump | ~F~ |
|
||||
| Incremental Search in Links | ~f~ |
|
||||
| History Back / Forwards | ~l~ / ~r~ |
|
||||
| Display Outline | ~o~ |
|
||||
| Jump to Section from Outline | ~RETURN~ |
|
||||
| Jump to Page | ~M-g g~ |
|
||||
| Store position / Jump to position in register | ~m~ / ~'~ |
|
||||
|-----------------------------------------------+-----------------------|
|
||||
| | |
|
||||
| Navigation | |
|
||||
|-----------------------------------------------+-------------------------|
|
||||
| Scroll Up / Down by Page-full | ~space~ / ~backspace~ |
|
||||
| Scroll Up / Down by Line | ~C-n~ / ~C-p~ |
|
||||
| Scroll Right / Left | ~C-f~ / ~C-b~ |
|
||||
| First Page / Last Page | ~<~, ~M-<~ / ~>~, ~M->~ |
|
||||
| Next Page / Previous Page | ~n~ / ~p~ |
|
||||
| Incremental Search Forward / Backward | ~C-s~ / ~C-r~ |
|
||||
| Occur (list all lines containing a phrase) | ~M-s o~ |
|
||||
| Jump to Occur Line | ~RETURN~ |
|
||||
| Pick a Link and Jump | ~F~ |
|
||||
| Incremental Search in Links | ~f~ |
|
||||
| History Back / Forwards | ~l~ / ~r~ |
|
||||
| Display Outline | ~o~ |
|
||||
| Jump to Section from Outline | ~RETURN~ |
|
||||
| Jump to Page | ~M-g g~ |
|
||||
| Store position / Jump to position in register | ~m~ / ~'~ |
|
||||
|-----------------------------------------------+-------------------------|
|
||||
| | |
|
||||
Note that ~pdf-tools~ renders the PDF as images inside Emacs. This means that all the keybindings of ~image-mode~ work on individual PDF pages as well.
|
||||
| Image Mode | |
|
||||
|------------------------+---------------------------------------------|
|
||||
@@ -443,6 +412,37 @@ With a recent [[https://www.gnu.org/software/auctex/][AUCTeX]] installation, you
|
||||
:END:
|
||||
L/R scrolling breaks while zoomed into a pdf, with usage of sublimity smooth scrolling features
|
||||
|
||||
** Text selection is not transparent in PDFs OCRed with Tesseract
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-09-19 Mon 18:50]
|
||||
:ID: C3A4A7C0-6BBB-4923-AD39-3707C8482A76
|
||||
:END:
|
||||
|
||||
In such PDFs the selected text becomes hidden behind the selection; see [[https://github.com/vedang/pdf-tools/issues/149][this issue]], which also describes the workaround in detail. The following function, which depends on the [[https://github.com/orgtre/qpdf.el][qpdf.el]] package, can be used to convert such a PDF file into one where text selection is transparent:
|
||||
#+begin_src elisp
|
||||
(defun my-fix-pdf-selection ()
|
||||
"Replace pdf with one where selection shows transparently."
|
||||
(interactive)
|
||||
(unless (equal (file-name-extension (buffer-file-name)) "pdf")
|
||||
(error "Buffer should visit a pdf file."))
|
||||
(unless (equal major-mode 'pdf-view-mode)
|
||||
(pdf-view-mode))
|
||||
;; save file in QDF-mode
|
||||
(qpdf-run (list
|
||||
(concat "--infile="
|
||||
(buffer-file-name))
|
||||
"--qdf --object-streams=disable"
|
||||
"--replace-input"))
|
||||
;; do replacements
|
||||
(text-mode)
|
||||
(read-only-mode -1)
|
||||
(while (re-search-forward "3 Tr" nil t)
|
||||
(replace-match "7 Tr" nil nil))
|
||||
(save-buffer)
|
||||
(pdf-view-mode))
|
||||
#+end_src
|
||||
Note that this overwrites the PDF file visited in the buffer from which it is run! To avoid this replace the ~--replace-input~ with ~(concat "--outfile=" (file-truename (read-file-name "Outfile: ")))~.
|
||||
|
||||
* Key-bindings in PDF Tools
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-29 Wed 18:34]
|
||||
@@ -469,31 +469,157 @@ L/R scrolling breaks while zoomed into a pdf, with usage of sublimity smooth scr
|
||||
#+end_src
|
||||
Toggling debug mode prints information about various operations in the ~*Messages*~ buffer, and this is useful to see what is happening behind the scenes
|
||||
|
||||
# Local Variables:
|
||||
# mode: org
|
||||
# End:
|
||||
** Run Emacs lisp tests locally
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-05-09 Mon 21:27]
|
||||
:ID: 1CBE7325-A5A1-479B-9A98-BEEFBAC9D8FF
|
||||
:END:
|
||||
You can go to the ~pdf-tools~ folder and run ~make test~ to run the ERT tests and check if the changes you have made to the code break any of the tests.
|
||||
|
||||
The tests are written in ERT, which is the built-in testing system in Emacs. However, they are run using ~Cask~ which you will have to install first, if you don't have it already. You can install ~Cask~ by following the instructions on their site at https://github.com/cask/cask
|
||||
** Run server compilation tests locally
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-07-20 Wed 16:42]
|
||||
:ID: 5327945D-9D92-4462-8172-7237DEF4C359
|
||||
:END:
|
||||
You can go to the ~pdf-tools~ folder and run ~make server-test~ to check if the changes you have made to the server code break compilation on any of the supported operating systems.
|
||||
|
||||
The tests build ~Podman~ images for all supported operating systems, so you will have to install ~Podman~ first, if you don't have already. You can install ~Podman~ by following the instructions on their site at https://podman.io/getting-started/installation
|
||||
|
||||
Podman is compatible with Docker, so if you already have ~docker~ installed, you should be able to ~alias podman=docker~ on your shell and run the tests, without having to install Docker. (Note: I have not tested this)
|
||||
|
||||
** Add a Dockerfile to automate server compilation testing
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-07-20 Wed 16:52]
|
||||
:ID: A401543C-308B-4175-8212-5B78CD6C8389
|
||||
:END:
|
||||
The ~server/test/docker~ folder contains Dockerfile templates used for testing that the ~epdfinfo~ server compiles correctly on various operating systems ([[id:5327945D-9D92-4462-8172-7237DEF4C359][more details here]]).
|
||||
|
||||
To see the list of operating systems where compilation testing is supported, run ~make server-test-supported~. To see the list of operating systems where testing is unsupported, run ~make server-test-unsupported~. To add support, look into the ~server/test/docker/templates~ folder (~ubuntu~ files are a good example to refer to)
|
||||
|
||||
** Issue Template for Bug Reports
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-12-02 Fri 13:30]
|
||||
:ID: F563A2A4-FCF8-4F04-94CA-19E80E4841A6
|
||||
:END:
|
||||
Please use the 'Bug Report' issue template when reporting bugs. The template is as follows:
|
||||
|
||||
*** Describe the bug
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
*** Steps To Reproduce the behaviour:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
*** What is the expected behaviour?
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
*** Desktop
|
||||
Please complete the following information:
|
||||
|
||||
- OS: [eg: MacOS Catalina]
|
||||
- Emacs Version: [This should be the output of ~M-x emacs-version~ ]
|
||||
- Poppler Version: [eg: output of ~brew info poppler~ and similarly for other OSs]
|
||||
|
||||
*** Your pdf-tools install
|
||||
Please complete the following information:
|
||||
- ~pdf-tools~ Version: [ ~M-x package-list-packages~ -> Search for ~pdf-tools~ -> Hit Enter and copy all the details that pop up in the Help buffer]
|
||||
- ~pdf-tools~ customization / configuration that you use:
|
||||
|
||||
*** Additional context
|
||||
- If you are reporting a crash, please try and add the Backtrace / Stacktrace of the crash.
|
||||
- If you are reporting a bug, please try and attach an example PDF file where I can reproduce the bug.
|
||||
- If you can attach screenshots or recordings, that is a great help
|
||||
- Please try reproducing the bug yourself on Vanilla Emacs before reporting the problem.
|
||||
|
||||
* FAQs
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-30 Thu 22:04]
|
||||
:ID: 3be6abe7-163e-4c3e-a7df-28e8470fe37f
|
||||
:END:
|
||||
** I'm on a Macbook and PDFs are rendering blurry
|
||||
** PDFs are not rendering well!
|
||||
:PROPERTIES:
|
||||
:CREATED: [2021-12-30 Thu 22:04]
|
||||
:ID: 20ef86be-7c92-4cda-97ec-70a22484e689
|
||||
:END:
|
||||
If you are on a Macbook with a Retina display, you may see PDFs as blurry due to the high resolution display. Use:
|
||||
~pdf-tools~ version ~1.1.0~ release changed the default value of ~pdf-view-use-scaling~ to ~t~ (previously, it was ~nil~). This has been done keeping in mind that most modern monitors are HiDPI screens, so the default configuration should cater to this user. If you are not using a HiDPI screen, you might have to change this value to ~nil~ in your configuration
|
||||
|
||||
#+begin_src elisp
|
||||
(setq pdf-view-use-scaling t)
|
||||
(setq pdf-view-use-scaling nil)
|
||||
#+end_src
|
||||
|
||||
to scale the images correctly when rendering them.
|
||||
|
||||
** What Emacs versions does ~pdf-tools~ support?
|
||||
** What Emacs versions does pdf-tools support?
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-01-02 Sun 10:12]
|
||||
:ID: f44c66e6-402d-4154-b806-6bb4180a0a5b
|
||||
:END:
|
||||
~pdf-tools~ supports the 3 latest versions of Emacs major releases. At the moment of this writing, this means that the minimum supported Emacs version is ~25.1~.
|
||||
~pdf-tools~ supports the 3 latest versions of Emacs major releases. At the moment of this writing, this means that the minimum supported Emacs version is ~26.3~.
|
||||
** I want to add support for pdf-tools on "My Fav OS". How do I do that?
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-04-25 Mon 21:50]
|
||||
:ID: A34704B9-1B51-4614-8806-C4059F7B42D5
|
||||
:END:
|
||||
I'm working on automating ~pdf-tools~ installation as much as possible, in order to improve the installation experience. If you want to add support for a new / currently unsupported Operating System, please modify the ~server/autobuild~ script. Say you want to support a new Operating System called MyFavOS. You need to do the following work:
|
||||
|
||||
1. Search for the ~Figure out where we are~ section. Here, add a call to ~os_myfavos~ right below ~handle_options~ at the end of the existing call chain. Here we try and pick up the correct Operating System and install the relevant dependencies.
|
||||
2. Add handling for the ~--os~ argument in ~os_argument~ for ~myfavos~, so that the appropriate function can be called to install pre-requisites. ~--os~ is the argument that we pass to the script from the command-line to indicate which OS we are on.
|
||||
3. Create a ~os_myfavos~ function. This function checks if we are running on MyFavOS. If we are running on MyFavOS, it sets up ~PKGCMD~, ~PKGARGS~ and ~PACKAGES~ variables so that the appropriate package manager can install the dependencies as part of the rest of the ~autobuild~ script.
|
||||
4. If you are adding support for your favorite operating system, consider adding automated testing support as well, to help me ensure that ~epdfinfo~ continues to compile correctly. See [[id:A401543C-308B-4175-8212-5B78CD6C8389][Add a Dockerfile to automate server compilation testing]] for more details.
|
||||
|
||||
The idea here is to make the ~server/autobuild~ file the single place from which installation can happen on any Operating System. This makes building ~pdf-tools~ dead simple via the ~Makefile~.
|
||||
|
||||
This seems like a lot of work, but it is not. If you need a reference, search for ~os_gentoo~ or ~os_debian~ in the ~server/autobuild~ file and see how these are setup and used. The functions are used to install dependencies on Gentoo and Debian respectively, and are simple to copy / change.
|
||||
|
||||
When you make your changes, please be sure to test [[id:1CBE7325-A5A1-479B-9A98-BEEFBAC9D8FF][the elisp changes]] as well as [[id:5327945D-9D92-4462-8172-7237DEF4C359][the server code changes]] as described in the linked articles.
|
||||
|
||||
** I am on a Macbook M1 and pdf-tools installation fails with a stack-trace
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-05-09 Mon 20:29]
|
||||
:ID: 96D389D8-DD23-4FB0-996C-2D6F70A76BB2
|
||||
:END:
|
||||
There have been a number of issues around ~pdf-tools~ installation problems on M1. ~M-x pdf-tools-install~ throws the following stack trace:
|
||||
#+begin_example
|
||||
1 warning generated.
|
||||
ld: warning: ignoring file /opt/homebrew/opt/gettext/lib/libintl.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
|
||||
ld: warning: ignoring file /opt/homebrew/Cellar/glib/2.72.1/lib/libglib-2.0.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
|
||||
ld: warning: ignoring file /opt/homebrew/Cellar/poppler/22.02.0/lib/libpoppler-glib.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
|
||||
ld: warning: ignoring file /opt/homebrew/Cellar/glib/2.72.1/lib/libgobject-2.0.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
|
||||
ld: warning: ignoring file /opt/homebrew/Cellar/poppler/22.02.0/lib/libpoppler.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
|
||||
ld: warning: ignoring file /opt/homebrew/Cellar/cairo/1.16.0_5/lib/libcairo.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
|
||||
ld: warning: ignoring file /opt/homebrew/Cellar/libpng/1.6.37/lib/libpng16.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
|
||||
ld: warning: ignoring file /opt/homebrew/Cellar/zlib/1.2.11/lib/libz.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
|
||||
Undefined symbols for architecture x86_64:
|
||||
#+end_example
|
||||
|
||||
This happens because M1 architecture is =ARM64=, whereas the Emacs App you are using has been compiled for the =x86_64= architecture. The way to solve this problem is to install a version of Emacs which has been compiled for the M1. As of today, [2022-05-09 Mon], the latest version of Emacs available on https://emacsformacosx.com/ is natively compiled and you will not face these issues on it. Please remove your current Emacs App and install it from https://emacsformacosx.com/.
|
||||
|
||||
Thank you.
|
||||
|
||||
PS: How do I know if the Emacs I'm running has been compiled correctly?
|
||||
|
||||
You can see this by opening the =Activity Monitor=, selecting =Emacs=, clicking on the =Info= key, and then clicking on =Sample=. The =Code Type= field in the Sample output will show you how your Application has been compiled. Here is the output for EmacsForMacOSX (you can see that it's =ARM64=):
|
||||
#+begin_example
|
||||
Sampling process 61824 for 3 seconds with 1 millisecond of run time between samples
|
||||
Sampling completed, processing symbols...
|
||||
Analysis of sampling Emacs-arm64-11 (pid 61824) every 1 millisecond
|
||||
Process: Emacs-arm64-11 [61824]
|
||||
Path: /Applications/Emacs.app/Contents/MacOS/Emacs-arm64-11
|
||||
Load Address: 0x1007f0000
|
||||
Identifier: org.gnu.Emacs
|
||||
Version: Version 28.1 (9.0)
|
||||
Code Type: ARM64
|
||||
Platform: macOS
|
||||
#+end_example
|
||||
|
||||
If your Emacs is compiled for x86, the =Code Type= will be =x86_64=.
|
||||
|
||||
** I am a developer, making changes to the pdf-tools source code
|
||||
:PROPERTIES:
|
||||
:CREATED: [2022-05-09 Mon 21:31]
|
||||
:ID: 2D173424-C211-4474-B0D0-83F4381CAFFA
|
||||
:END:
|
||||
Thank you for taking the time to contribute back to the code. You may find some useful notes in the [[id:fd64c10c-4ea5-4ece-8d95-b723098dd4f6][Tips and Tricks for Developers]] section. Please be sure to check it out!
|
||||
|
||||
@@ -27,6 +27,11 @@ $(pkgfile): .cask/$(emacs_version) server/epdfinfo lisp/*.el
|
||||
bytecompile: .cask/$(emacs_version)
|
||||
$(CASK) exec $(emacs) --batch -L lisp -f batch-byte-compile lisp/*.el
|
||||
|
||||
# Clean bytecompiled sources
|
||||
byteclean:
|
||||
rm -f -- lisp/*.elc
|
||||
rm -f -- lisp/*.eln
|
||||
|
||||
# Run ERT tests
|
||||
test: all
|
||||
PACKAGE_TAR=$(pkgfile) $(CASK) exec ert-runner
|
||||
@@ -68,9 +73,8 @@ melpa-package: $(pkgfile)
|
||||
-f $(pkgname)-melpa.tar
|
||||
|
||||
# Various clean targets
|
||||
clean: server-clean
|
||||
clean: server-clean byteclean
|
||||
rm -f -- $(pkgfile)
|
||||
rm -f -- lisp/*.elc
|
||||
rm -f -- pdf-tools-readme.txt
|
||||
rm -f -- pdf-tools-$(version).entry
|
||||
|
||||
@@ -95,3 +99,9 @@ server-clean:
|
||||
|
||||
server-distclean:
|
||||
! [ -f server/Makefile ] || $(MAKE) -C server distclean
|
||||
|
||||
server-test-supported: server/test/Makefile
|
||||
$(MAKE) -C server/test print
|
||||
|
||||
server-test-unsupported: server/test/Makefile
|
||||
$(MAKE) -C server/test print-failing
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
bin_PROGRAMS = epdfinfo
|
||||
epdfinfo_CFLAGS = -Wall $(glib_CFLAGS) $(poppler_glib_CFLAGS) $(poppler_CFLAGS) \
|
||||
$(png_CFLAGS)
|
||||
epdfinfo_CXXFLAGS = -Wall $(epdfinfo_CFLAGS)
|
||||
# Need -lm to link libm.so.6
|
||||
epdfinfo_LDADD = $(glib_LIBS) $(poppler_glib_LIBS) $(poppler_LIBS) \
|
||||
$(png_LIBS) libsynctex.a $(zlib_LIBS)
|
||||
epdfinfo_SOURCES = epdfinfo.c epdfinfo.h poppler-hack.cc
|
||||
$(png_LIBS) libsynctex.a $(zlib_LIBS) -lm
|
||||
epdfinfo_SOURCES = epdfinfo.c epdfinfo.h
|
||||
|
||||
noinst_LIBRARIES = libsynctex.a
|
||||
libsynctex_a_SOURCES = synctex_parser.c synctex_parser_utils.c synctex_parser.h \
|
||||
|
||||
@@ -157,8 +157,6 @@ have_packages_installed()
|
||||
done
|
||||
which make || return 1
|
||||
which gcc || which cc || return 1
|
||||
which g++ || which c++ || return 1
|
||||
c++ $(pkg-config --cflags poppler) -o /dev/null -E install_test.cpp 2>/dev/null
|
||||
[ $? -eq 0 ] || return 1
|
||||
return 0
|
||||
} >/dev/null 2>&1
|
||||
@@ -221,7 +219,6 @@ os_centos() {
|
||||
PACKAGES="autoconf
|
||||
automake
|
||||
gcc
|
||||
gcc-c++
|
||||
libpng-devel
|
||||
make
|
||||
pkgconfig
|
||||
@@ -242,6 +239,17 @@ os_freebsd() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# NetBSD
|
||||
os_netbsd() {
|
||||
if ! which uname >/dev/null 2>&1 || [ "$(uname -s)" != "NetBSD" ]; then
|
||||
return 1
|
||||
fi
|
||||
PKGCMD=pkgin
|
||||
PKGARGS=install
|
||||
PACKAGES="autoconf automake poppler-glib png pkgconf"
|
||||
return 0
|
||||
}
|
||||
|
||||
# OpenBSD
|
||||
os_openbsd() {
|
||||
if ! which uname >/dev/null 2>&1 || [ "$(uname -s)" != "OpenBSD" ]; then
|
||||
@@ -252,15 +260,6 @@ os_openbsd() {
|
||||
PACKAGES="autoconf%2.69 automake%1.15 poppler poppler-utils png"
|
||||
export AUTOCONF_VERSION=2.69
|
||||
export AUTOMAKE_VERSION=1.15
|
||||
if whereis clang++ ;then
|
||||
export CXX=clang++
|
||||
elif whereis eg++ ;then
|
||||
export CXX=eg++
|
||||
else
|
||||
export CXX=eg++
|
||||
PACKAGES="${PACKAGES} g++"
|
||||
fi
|
||||
export CXXFLAGS="-std=c++11 -I/usr/local/include/poppler -I/usr/local/include"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -274,7 +273,6 @@ os_fedora() {
|
||||
PACKAGES="autoconf
|
||||
automake
|
||||
gcc
|
||||
gcc-c++
|
||||
libpng-devel
|
||||
make
|
||||
poppler-devel
|
||||
@@ -296,12 +294,10 @@ os_debian() {
|
||||
fi
|
||||
PACKAGES="autoconf
|
||||
automake
|
||||
g++
|
||||
gcc
|
||||
libpng-dev
|
||||
libpoppler-dev
|
||||
libpoppler-glib-dev
|
||||
libpoppler-private-dev
|
||||
libz-dev
|
||||
make
|
||||
pkg-config"
|
||||
@@ -318,15 +314,23 @@ os_msys2() {
|
||||
case $MSYSTEM in
|
||||
MINGW64)
|
||||
PACKAGES="base-devel
|
||||
autoconf
|
||||
automake
|
||||
mingw-w64-x86_64-libpng
|
||||
mingw-w64-x86_64-poppler
|
||||
mingw-w64-x86_64-imagemagick
|
||||
mingw-w64-x86_64-toolchain
|
||||
mingw-w64-x86_64-openssl
|
||||
mingw-w64-x86_64-zlib" ;;
|
||||
MINGW32)
|
||||
PACKAGES="base-devel
|
||||
autoconf
|
||||
automake
|
||||
mingw-w64-i686-libpng
|
||||
mingw-w64-i686-poppler
|
||||
mingw-w64-i686-imagemagick
|
||||
mingw-w64-i686-toolchain
|
||||
mingw-w64-i686-openssl
|
||||
mingw-w64-i686-zlib" ;;
|
||||
MSYS)
|
||||
case $(uname -m) in
|
||||
@@ -356,15 +360,15 @@ os_macos() {
|
||||
elif which brew >/dev/null 2>&1; then
|
||||
PKGCMD=brew
|
||||
PKGARGS=install
|
||||
PACKAGES="pkg-config poppler automake"
|
||||
PACKAGES="pkg-config poppler autoconf automake"
|
||||
PKG_INSTALL_AS_ROOT=
|
||||
# homebrew install libffi as keg-only, meaning we need to set
|
||||
# brew installs libffi as keg-only, meaning we need to set
|
||||
# PKG_CONFIG_PATH manually so configure can find it
|
||||
export PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig/"
|
||||
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$(brew --prefix libffi)/lib/pkgconfig/:$(brew --prefix zlib)/lib/pkgconfig/"
|
||||
elif which port >/dev/null 2>&1; then
|
||||
PKGCMD=port
|
||||
PKGARGS=install
|
||||
PACKAGES="pkgconfig poppler automake libpng"
|
||||
PACKAGES="pkgconfig poppler autoconf automake libpng"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
@@ -383,11 +387,15 @@ os_nixos() {
|
||||
if [ -n "$DRY_RUN" ]; then
|
||||
return 0
|
||||
fi
|
||||
if ! nix-instantiate --eval -E "<nixpkgs>" &>/dev/null; then
|
||||
echo "File 'nixpkgs' was not found in the Nix path. Using NixOS/nixpkgs"
|
||||
NIX_PATH="nixpkgs=https://github.com/nixos/nixpkgs/archive/master.tar.gz:$NIX_PATH"
|
||||
fi
|
||||
command="AUTOBUILD_NIX_SHELL=true"
|
||||
command="$command;export AUTOBUILD_NIX_SHELL"
|
||||
command="$command;$(quote "$0" "$@")"
|
||||
exec nix-shell --pure --command "$command" \
|
||||
-p gcc gnumake automake autoconf pkgconfig libpng zlib poppler
|
||||
exec nix-shell --pure --run "$command" \
|
||||
-p automake autoconf pkg-config libpng zlib poppler
|
||||
}
|
||||
|
||||
# Gentoo
|
||||
@@ -404,6 +412,7 @@ os_gentoo() {
|
||||
sys-devel/automake
|
||||
sys-devel/gcc
|
||||
sys-devel/make
|
||||
sys-libs/glibc
|
||||
sys-libs/zlib"
|
||||
return 0
|
||||
}
|
||||
@@ -412,7 +421,7 @@ os_gentoo() {
|
||||
os_void() {
|
||||
if [ -f "/etc/os-release" ]; then
|
||||
. /etc/os-release
|
||||
if [ "$NAME" != "void" ]; then
|
||||
if [ "$ID" != "void" ]; then
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
@@ -428,6 +437,55 @@ os_void() {
|
||||
pkgconf"
|
||||
PKGCMD=xbps-install
|
||||
PKGARGS="-Sy"
|
||||
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/lib/pkgconfig"
|
||||
return 0
|
||||
}
|
||||
|
||||
# openSUSE (TODO: add support for micro versions)
|
||||
os_opensuse() {
|
||||
if [ -f "/etc/os-release" ]; then
|
||||
. /etc/os-release
|
||||
if [ "$ID" != "opensuse-leap" ] && [ "$ID" != "opensuse-tumbleweed" ]; then
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
PACKAGES="make
|
||||
automake
|
||||
autoconf
|
||||
gcc
|
||||
libpng16-devel
|
||||
libpng16-compat-devel
|
||||
zlib-devel
|
||||
libpoppler-devel
|
||||
libpoppler-glib-devel
|
||||
glib2-devel
|
||||
pkgconf"
|
||||
PKGCMD=zypper
|
||||
PKGARGS="install"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Alpine Linux
|
||||
os_alpine() {
|
||||
if [ -f "/etc/os-release" ]; then
|
||||
. /etc/os-release
|
||||
if [ "$ID" != "alpine" ]; then
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
PACKAGES="autoconf
|
||||
automake
|
||||
libpng-dev
|
||||
poppler-dev
|
||||
glib-dev
|
||||
gcc
|
||||
build-base"
|
||||
PKGCMD=apk
|
||||
PKGARGS="add"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -439,6 +497,7 @@ os_argument() {
|
||||
freebsd) os_freebsd "$@";;
|
||||
arch) os_arch "$@";;
|
||||
centos) os_centos "$@";;
|
||||
netbsd) os_netbsd "$@";;
|
||||
openbsd) os_openbsd "$@";;
|
||||
fedora) os_fedora "$@";;
|
||||
debian) os_debian "$@";;
|
||||
@@ -446,6 +505,8 @@ os_argument() {
|
||||
msys2) os_msys2 "$@";;
|
||||
nixos) os_nixos "$@";;
|
||||
void) os_void "$@";;
|
||||
opensuse) os_opensuse "$@";;
|
||||
alpine) os_alpine "$@";;
|
||||
*) echo "Invalid --os argument: $OS"
|
||||
exit 1
|
||||
esac || {
|
||||
@@ -455,7 +516,8 @@ os_argument() {
|
||||
}
|
||||
|
||||
## +-----------------------------------------------------------+
|
||||
## * Figure out were we are, install deps and build the program
|
||||
## * Figure out where we are
|
||||
## ** install deps and build the program
|
||||
## +-----------------------------------------------------------+
|
||||
|
||||
handle_options "$@"
|
||||
@@ -465,6 +527,7 @@ os_macos "$@" || \
|
||||
os_freebsd "$@" || \
|
||||
os_arch "$@" || \
|
||||
os_centos "$@" || \
|
||||
os_netbsd "$@" || \
|
||||
os_openbsd "$@" || \
|
||||
os_fedora "$@" || \
|
||||
os_debian "$@" || \
|
||||
@@ -472,6 +535,8 @@ os_gentoo "$@" || \
|
||||
os_msys2 "$@" || \
|
||||
os_nixos "$@" || \
|
||||
os_void "$@" || \
|
||||
os_opensuse "$@" || \
|
||||
os_alpine "$@" || \
|
||||
{
|
||||
OS_IS_HANDLED=
|
||||
if [ -z "$DRY_RUN" ]; then
|
||||
|
||||
@@ -10,7 +10,6 @@ AC_CONFIG_HEADERS([config.h])
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CXX
|
||||
AC_PROG_RANLIB
|
||||
AM_PROG_AR
|
||||
|
||||
@@ -43,22 +42,6 @@ if test "$have_w32" = true; then
|
||||
fi
|
||||
fi
|
||||
|
||||
SAVED_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS=$poppler_CFLAGS
|
||||
AC_LANG_PUSH([C++])
|
||||
# Check if we can use the -std=c++11 option.
|
||||
m4_include([m4/ax_check_compile_flag.m4])
|
||||
AX_CHECK_COMPILE_FLAG([-std=c++11], [HAVE_STD_CXX11=yes])
|
||||
|
||||
if test "$HAVE_STD_CXX11" = yes; then
|
||||
CXXFLAGS="-std=c++11 $CXXFLAGS"
|
||||
fi
|
||||
# Check for private poppler header.
|
||||
AC_CHECK_HEADERS([Annot.h PDFDocEncoding.h], [],
|
||||
AC_MSG_ERROR([cannot find necessary poppler-private header (see README.org)]))
|
||||
AC_LANG_POP([C++])
|
||||
CPPFLAGS=$SAVED_CPPFLAGS
|
||||
|
||||
# Setup compile time features.
|
||||
if test "$HAVE_POPPLER_FIND_OPTS" = yes; then
|
||||
AC_DEFINE([HAVE_POPPLER_FIND_OPTS],1,
|
||||
|
||||
@@ -354,7 +354,7 @@ mktempfile()
|
||||
filename = tempnam(NULL, "epdfinfo");
|
||||
if (filename)
|
||||
{
|
||||
int fd = open(filename, O_CREAT | O_EXCL | O_RDONLY, S_IRWXU);
|
||||
int fd = open(filename, O_CREAT | O_EXCL | O_RDONLY, S_IRUSR | S_IWUSR);
|
||||
if (fd > 0)
|
||||
close (fd);
|
||||
else
|
||||
@@ -1309,25 +1309,6 @@ annotation_get_by_key (document_t *doc, const gchar *key)
|
||||
}
|
||||
|
||||
#ifdef HAVE_POPPLER_ANNOT_MARKUP
|
||||
void
|
||||
annotation_translate_quadrilateral (PopplerPage *page, PopplerQuadrilateral *q, gboolean inverse)
|
||||
{
|
||||
PopplerRectangle cbox;
|
||||
gdouble xs, ys;
|
||||
|
||||
poppler_page_get_crop_box (page, &cbox);
|
||||
xs = MIN (cbox.x1, cbox.x2);
|
||||
ys = MIN (cbox.y1, cbox.y2);
|
||||
|
||||
if (inverse)
|
||||
{
|
||||
xs = -xs; ys = -ys;
|
||||
}
|
||||
|
||||
q->p1.x -= xs, q->p2.x -= xs; q->p3.x -= xs; q->p4.x -= xs;
|
||||
q->p1.y -= ys, q->p2.y -= ys; q->p3.y -= ys; q->p4.y -= ys;
|
||||
}
|
||||
|
||||
static cairo_region_t*
|
||||
annotation_markup_get_text_regions (PopplerPage *page, PopplerAnnotTextMarkup *a)
|
||||
{
|
||||
@@ -1343,7 +1324,6 @@ annotation_markup_get_text_regions (PopplerPage *page, PopplerAnnotTextMarkup *a
|
||||
PopplerQuadrilateral *q = &g_array_index (quads, PopplerQuadrilateral, i);
|
||||
cairo_rectangle_int_t r;
|
||||
|
||||
annotation_translate_quadrilateral (page, q, FALSE);
|
||||
q->p1.y = height - q->p1.y;
|
||||
q->p2.y = height - q->p2.y;
|
||||
q->p3.y = height - q->p3.y;
|
||||
@@ -1398,7 +1378,6 @@ annotation_markup_append_text_region (PopplerPage *page, PopplerRectangle *regio
|
||||
q.p3.x = r->x1;
|
||||
q.p3.y = height - r->y2;
|
||||
|
||||
annotation_translate_quadrilateral (page, &q, TRUE);
|
||||
g_array_append_val (garray, q);
|
||||
}
|
||||
g_list_free (regions);
|
||||
@@ -1567,6 +1546,7 @@ annotation_print (const annotation_t *annot, /* const */ PopplerPage *page)
|
||||
gchar *text;
|
||||
gdouble opacity;
|
||||
cairo_region_t *region = NULL;
|
||||
GDate *date;
|
||||
|
||||
if (! annot || ! page)
|
||||
return;
|
||||
@@ -1668,11 +1648,13 @@ annotation_print (const annotation_t *annot, /* const */ PopplerPage *page)
|
||||
printf ("::");
|
||||
|
||||
/* Creation Date */
|
||||
text = xpoppler_annot_markup_get_created (ma);
|
||||
if (text)
|
||||
date = poppler_annot_markup_get_date (ma);
|
||||
if (date != NULL && g_date_valid(date))
|
||||
{
|
||||
print_response_string (text, NONE);
|
||||
g_free (text);
|
||||
gchar datebuf[128];
|
||||
g_date_strftime (datebuf, 127, "%x", date);
|
||||
print_response_string (datebuf, NONE);
|
||||
g_date_free (date);
|
||||
}
|
||||
|
||||
/* <<< Markup Annotation <<< */
|
||||
@@ -2848,7 +2830,7 @@ cmd_editannot (const epdfinfo_t *ctx, const command_arg_t *args)
|
||||
area->x1 = r.x1 * width;
|
||||
area->y2 = height - (r.y1 * height);
|
||||
|
||||
xpoppler_annot_set_rectangle (pa, area);
|
||||
poppler_annot_set_rectangle (pa, area);
|
||||
}
|
||||
else if (! strcmp (key, "label"))
|
||||
{
|
||||
|
||||
@@ -243,10 +243,4 @@ typedef struct
|
||||
const command_arg_type_t *args_spec;
|
||||
int nargs;
|
||||
} command_t;
|
||||
|
||||
/* Defined in poppler-hack.cc */
|
||||
#ifdef HAVE_POPPLER_ANNOT_WRITE
|
||||
extern void xpoppler_annot_set_rectangle (PopplerAnnot*, PopplerRectangle*);
|
||||
#endif
|
||||
extern gchar *xpoppler_annot_markup_get_created (PopplerAnnotMarkup*);
|
||||
#endif /* _EPDF_H_ */
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <PDFDocEncoding.h>
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello World, pdf-tools!";
|
||||
return 0;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check whether the given FLAG works with the current language's compiler
|
||||
# or gives an error. (Warnings, however, are ignored)
|
||||
#
|
||||
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
|
||||
# success/failure.
|
||||
#
|
||||
# If EXTRA-FLAGS is defined, it is added to the current language's default
|
||||
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
|
||||
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
|
||||
# force the compiler to issue an error when a bad flag is given.
|
||||
#
|
||||
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
|
||||
#
|
||||
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
|
||||
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 5
|
||||
|
||||
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
|
||||
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
|
||||
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
|
||||
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
||||
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
||||
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
||||
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
|
||||
[AS_VAR_SET(CACHEVAR,[yes])],
|
||||
[AS_VAR_SET(CACHEVAR,[no])])
|
||||
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
|
||||
AS_VAR_IF(CACHEVAR,yes,
|
||||
[m4_default([$2], :)],
|
||||
[m4_default([$3], :)])
|
||||
AS_VAR_POPDEF([CACHEVAR])dnl
|
||||
])dnl AX_CHECK_COMPILE_FLAGS
|
||||
@@ -1,122 +0,0 @@
|
||||
// Copyright (C) 2013, 2014 Andreas Politz
|
||||
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <config.h>
|
||||
#include <PDFDocEncoding.h>
|
||||
#include <Annot.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <poppler-features.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
GType poppler_annot_get_type (void) G_GNUC_CONST;
|
||||
GType poppler_annot_markup_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define POPPLER_TYPE_ANNOT (poppler_annot_get_type ())
|
||||
#define POPPLER_ANNOT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT, PopplerAnnot))
|
||||
#define POPPLER_IS_ANNOT_MARKUP(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_ANNOT_MARKUP))
|
||||
#define POPPLER_TYPE_ANNOT_MARKUP (poppler_annot_markup_get_type ())
|
||||
|
||||
#if POPPLER_CHECK_VERSION(0,72,0)
|
||||
#define GET_CSTR c_str
|
||||
#else
|
||||
#define GET_CSTR getCString
|
||||
#endif
|
||||
|
||||
struct PopplerAnnot
|
||||
{
|
||||
GObject parent_instance;
|
||||
Annot *annot;
|
||||
};
|
||||
|
||||
struct PopplerAnnotMarkup
|
||||
{
|
||||
GObject parent_instance;
|
||||
};
|
||||
|
||||
struct PopplerRectangle
|
||||
{
|
||||
double x1;
|
||||
double y1;
|
||||
double x2;
|
||||
double y2;
|
||||
};
|
||||
|
||||
// This function does not modify its argument s, but for
|
||||
// compatibility reasons (e.g. getLength in GooString.h before 2015)
|
||||
// with older poppler code, it can't be declared as such.
|
||||
char *_xpoppler_goo_string_to_utf8(/* const */ GooString *s)
|
||||
{
|
||||
char *result;
|
||||
|
||||
if (! s)
|
||||
return NULL;
|
||||
|
||||
if (s->hasUnicodeMarker()) {
|
||||
result = g_convert (s->GET_CSTR () + 2,
|
||||
s->getLength () - 2,
|
||||
"UTF-8", "UTF-16BE", NULL, NULL, NULL);
|
||||
} else {
|
||||
int len;
|
||||
gunichar *ucs4_temp;
|
||||
int i;
|
||||
|
||||
len = s->getLength ();
|
||||
ucs4_temp = g_new (gunichar, len + 1);
|
||||
for (i = 0; i < len; ++i) {
|
||||
ucs4_temp[i] = pdfDocEncoding[(unsigned char)s->getChar(i)];
|
||||
}
|
||||
ucs4_temp[i] = 0;
|
||||
|
||||
result = g_ucs4_to_utf8 (ucs4_temp, -1, NULL, NULL, NULL);
|
||||
|
||||
g_free (ucs4_temp);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#ifdef HAVE_POPPLER_ANNOT_WRITE
|
||||
// Set the rectangle of an annotation. It was first added in v0.26.
|
||||
void xpoppler_annot_set_rectangle (PopplerAnnot *a, PopplerRectangle *rectangle)
|
||||
{
|
||||
GooString *state = (GooString*) a->annot->getAppearState ();
|
||||
char *ustate = _xpoppler_goo_string_to_utf8 (state);
|
||||
|
||||
a->annot->setRect (rectangle->x1, rectangle->y1,
|
||||
rectangle->x2, rectangle->y2);
|
||||
a->annot->setAppearanceState (ustate);
|
||||
g_free (ustate);
|
||||
}
|
||||
#endif
|
||||
// This function is in the library, but the enforced date parsing is
|
||||
// incomplete (at least in some versions), because it ignores the
|
||||
// timezone.
|
||||
gchar *xpoppler_annot_markup_get_created (PopplerAnnotMarkup *poppler_annot)
|
||||
{
|
||||
AnnotMarkup *annot;
|
||||
GooString *text;
|
||||
|
||||
g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), NULL);
|
||||
|
||||
annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
|
||||
text = (GooString*) annot->getDate ();
|
||||
|
||||
return text ? _xpoppler_goo_string_to_utf8 (text) : NULL;
|
||||
}
|
||||
}
|
||||
1
lisp/pdf-tools/build/server/test/.gitignore
vendored
Normal file
1
lisp/pdf-tools/build/server/test/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.start-vm
|
||||
@@ -1,2 +1,3 @@
|
||||
*.Dockerfile
|
||||
*.build
|
||||
*.container
|
||||
|
||||
@@ -2,8 +2,23 @@
|
||||
|
||||
PATH="$(dirname "$0")":$PATH
|
||||
|
||||
set -e
|
||||
run_tests_exit_success()
|
||||
{
|
||||
echo "==============================="
|
||||
echo " Elisp Tests succeeded. :O) "
|
||||
echo "==============================="
|
||||
exit 0
|
||||
}
|
||||
|
||||
yes-or-enter | ./autobuild -i /bin
|
||||
yes-or-enter | ./autobuild -i /usr/bin | \
|
||||
set -e
|
||||
# Check that install completes successfully
|
||||
yes-or-enter | ./server/autobuild -i /bin
|
||||
# Check that re-install skips package installation
|
||||
yes-or-enter | ./server/autobuild -i /usr/bin | \
|
||||
grep -q "Skipping package installation (already installed)"
|
||||
# Check that lisp tests run correctly, if emacs is installed and available on PATH
|
||||
echo
|
||||
if which emacs > /dev/null 2> /dev/null; then
|
||||
echo "Emacs found installed! Running elisp tests"
|
||||
make test && run_tests_exit_success
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
COPY . /pdf-tools
|
||||
WORKDIR /pdf-tools
|
||||
RUN make -s distclean || true
|
||||
CMD ["sh", "./server/test/docker/lib/run-tests"]
|
||||
@@ -1,4 +0,0 @@
|
||||
ADD . /epdfinfo
|
||||
WORKDIR /epdfinfo
|
||||
RUN make -s distclean || true
|
||||
CMD ["sh", "./test/docker/lib/run-tests"]
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM archlinux:latest
|
||||
RUN pacman -Syu --noconfirm --noprogressbar && \
|
||||
pacman -S --noconfirm --noprogressbar poppler-glib base-devel
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM archlinux:latest
|
||||
RUN pacman -Syu --noconfirm --noprogressbar
|
||||
# @TODO: The official Archlinux image does not seem to have any form of shell. Marking this as FAILING.
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM centos:7
|
||||
RUN yum update -y && yum install -y gcc gcc-c++ poppler-glib-devel
|
||||
@@ -0,0 +1,6 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM centos:centos7
|
||||
RUN sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
|
||||
RUN sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*
|
||||
RUN yum update -y
|
||||
# @TODO: Since CentOS is no more, do I even want to try and fix this?
|
||||
@@ -1,3 +1,6 @@
|
||||
# -*- dockerfile -*-
|
||||
# Debian 10 is known as buster
|
||||
FROM debian:10
|
||||
RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update -y && apt-get install -y make tzdata
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# -*- dockerfile -*-
|
||||
# Debian 11 is known as bullseye
|
||||
FROM debian:11
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update -y && apt-get install -y make tzdata
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM debian:8
|
||||
RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# -*- dockerfile -*-
|
||||
# Debian 9 is known as stretch
|
||||
FROM debian:9
|
||||
RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update -y && apt-get install -y make tzdata
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM silex/emacs:26-ci-cask
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update -y && apt-get install -y make tzdata
|
||||
@@ -0,0 +1,5 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM silex/emacs:27-ci-cask
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update -y && apt-get install -y make tzdata
|
||||
@@ -0,0 +1,5 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM silex/emacs:28-ci-cask
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update -y && apt-get install -y make tzdata
|
||||
@@ -0,0 +1,5 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM silex/emacs:master-ci-cask
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update -y && apt-get install -y make tzdata
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM fedora:32
|
||||
RUN dnf update -y && dnf install -y gcc gcc-c++ poppler-glib-devel
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM fedora:33
|
||||
RUN dnf update -y && dnf install -y gcc gcc-c++ poppler-glib-devel
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM fedora:34
|
||||
RUN dnf update -y && dnf install -y gcc gcc-c++ poppler-glib-devel
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN dnf update -y && dnf install -y make tzdata
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM fedora:35
|
||||
RUN dnf update -y && dnf install -y gcc gcc-c++ poppler-glib-devel
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN dnf update -y && dnf install -y make tzdata
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM fedora:36
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN dnf update -y && dnf install -y make tzdata
|
||||
@@ -1,5 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM gentoo/stage3-amd64
|
||||
RUN emerge --sync && emerge sys-devel/gcc app-text/poppler
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM gentoo/stage3
|
||||
RUN emerge --sync
|
||||
# IF you see this error, just ignore it: !!! It seems /run is not mounted. Process management may malfunction.
|
||||
# Note that gentoo takes a **long** time to build and run, that's okay.
|
||||
# @TODO: Currently, running this errors out because it cannot find glib-2.0, needs fixing.
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM ubuntu:trusty
|
||||
RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM ubuntu:xenial
|
||||
RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM ubuntu:bionic
|
||||
RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update --fix-missing -y && apt-get install -y make tzdata
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM ubuntu:groovy
|
||||
RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev
|
||||
@@ -1,3 +1,5 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM ubuntu:focal
|
||||
RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update --fix-missing -y && apt-get install -y make tzdata
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM ubuntu:hirsute
|
||||
RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev
|
||||
@@ -0,0 +1,5 @@
|
||||
# -*- dockerfile -*-
|
||||
FROM ubuntu:jammy
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# Need to install make, tzdata here to avoid stupid prompts when running package install via autobuild
|
||||
RUN apt-get update --fix-missing -y && apt-get install -y make tzdata
|
||||
@@ -50,7 +50,7 @@ The functions on this hook will be called when some annotation is
|
||||
activated, usually by a mouse-click. Each one is called with the
|
||||
annotation as a single argument and it should return a non-nil
|
||||
value if it has `handled' it. If no such function exists, the
|
||||
default handler `pdf-annot-default-handler' will be
|
||||
default handler `pdf-annot-default-activate-handler' will be
|
||||
called.
|
||||
|
||||
This hook is meant to allow for custom annotations. FIXME:
|
||||
@@ -293,7 +293,6 @@ Setting this after the package was loaded has no effect."
|
||||
(smap (make-sparse-keymap)))
|
||||
(define-key kmap pdf-annot-minor-mode-map-prefix smap)
|
||||
(define-key smap "l" #'pdf-annot-list-annotations)
|
||||
;; (define-key smap "d" 'pdf-annot-toggle-display-annotations)
|
||||
(define-key smap "a" #'pdf-annot-attachment-dired)
|
||||
(when (pdf-info-writable-annotations-p)
|
||||
(define-key smap "D" #'pdf-annot-delete)
|
||||
@@ -525,12 +524,12 @@ the variable is nil and this function is called again."
|
||||
(union (cl-union (cl-union changed inserted :test 'pdf-annot-equal)
|
||||
deleted :test 'pdf-annot-equal))
|
||||
(closure (lambda (arg)
|
||||
(cl-ecase arg
|
||||
(:inserted (copy-sequence inserted))
|
||||
(:changed (copy-sequence changed))
|
||||
(:deleted (copy-sequence deleted))
|
||||
(t (copy-sequence union))
|
||||
(nil nil))))
|
||||
(when arg
|
||||
(cl-case arg
|
||||
(:inserted (copy-sequence inserted))
|
||||
(:changed (copy-sequence changed))
|
||||
(:deleted (copy-sequence deleted))
|
||||
(t (copy-sequence union))))))
|
||||
(pages (mapcar (lambda (a) (pdf-annot-get a 'page)) union)))
|
||||
(when union
|
||||
(unwind-protect
|
||||
@@ -1372,10 +1371,7 @@ by a header."
|
||||
;; latex-preview regardless of the user
|
||||
;; configuration.
|
||||
(org-preview-latex-default-process 'dvipng)
|
||||
;; For backward compatibility with emacs-version < 26.1
|
||||
(org-latex-create-formula-image-program 'dvipng)
|
||||
(org-format-latex-header
|
||||
pdf-annot-latex-header)
|
||||
(org-format-latex-header pdf-annot-latex-header)
|
||||
(temporary-file-directory
|
||||
(pdf-util-expand-file-name "pdf-annot-print-annotation-latex")))
|
||||
(unless (file-directory-p temporary-file-directory)
|
||||
@@ -1423,7 +1419,7 @@ by a header."
|
||||
(let ((mode (if (funcall pdf-annot-latex-string-predicate
|
||||
(pdf-annot-get a 'contents))
|
||||
'latex-mode
|
||||
'text-mode)))
|
||||
'org-mode)))
|
||||
(unless (derived-mode-p mode)
|
||||
(funcall mode))))
|
||||
"A function for setting up, e.g. the major-mode, of the edit buffer.
|
||||
@@ -1433,7 +1429,7 @@ is about to be edited in this buffer.
|
||||
|
||||
The default value turns on `latex-mode' if
|
||||
`pdf-annot-latex-string-predicate' returns non-nil on the
|
||||
annotation's contents and otherwise `text-mode'."
|
||||
annotation's contents and otherwise `org-mode'."
|
||||
:type 'function)
|
||||
|
||||
(defcustom pdf-annot-edit-contents-display-buffer-action
|
||||
@@ -1465,8 +1461,8 @@ annotation's contents and otherwise `text-mode'."
|
||||
"Finalize edit-operations on an Annotation.
|
||||
|
||||
If DO-SAVE is t, save the changes to annotation content without
|
||||
asking. If DO-SAVE is 'ask, check if the user if contents should
|
||||
be saved.
|
||||
asking. If DO-SAVE is `ask', check with the user if contents
|
||||
should be saved.
|
||||
|
||||
If DO-KILL is t, kill all windows displaying the annotation
|
||||
contents. Else just bury the buffers."
|
||||
@@ -1574,7 +1570,7 @@ Currently supported properties are page, type, label, date and contents."
|
||||
(date (integer :value 24 :tag "Column Width"))
|
||||
(contents (integer :value 56 :tag "Column Width"))))
|
||||
|
||||
(defcustom pdf-annot-list-highlight-type nil
|
||||
(defcustom pdf-annot-list-highlight-type t
|
||||
"Whether to highlight \"Type\" column annotation list with annotation color."
|
||||
:type 'boolean)
|
||||
|
||||
@@ -1642,7 +1638,9 @@ pretty-printed output."
|
||||
(lambda (str)
|
||||
(replace-regexp-in-string "\n" " " str t t))))
|
||||
(cl-ecase entry-type
|
||||
(date (pdf-annot-print-property a 'modified))
|
||||
(date (propertize (pdf-annot-print-property a 'modified)
|
||||
'date
|
||||
(pdf-annot-get a 'modified)))
|
||||
(page (pdf-annot-print-property a 'page))
|
||||
(label (funcall prune-newlines
|
||||
(pdf-annot-print-property a 'label)))
|
||||
@@ -1654,7 +1652,7 @@ pretty-printed output."
|
||||
(type
|
||||
(let ((color (pdf-annot-get a 'color))
|
||||
(type (pdf-annot-print-property a 'type)))
|
||||
(if pdf-annot-list-highlight-type
|
||||
(if (and pdf-annot-list-highlight-type color)
|
||||
(propertize
|
||||
type 'face
|
||||
`(:background ,color
|
||||
@@ -1669,19 +1667,38 @@ pretty-printed output."
|
||||
pdf-annot-list-format))))
|
||||
|
||||
(define-derived-mode pdf-annot-list-mode tablist-mode "Annots"
|
||||
;; @TODO: Remove the hard-coded index values here, and figure out a
|
||||
;; way to properly link this to the index values of
|
||||
;; `pdf-annot-list-format'.
|
||||
|
||||
;; @TODO: Add tests for annotation formatting and display
|
||||
(let* ((page-sorter
|
||||
(lambda (a b)
|
||||
(< (string-to-number (aref (cadr a) 0))
|
||||
(string-to-number (aref (cadr b) 0)))))
|
||||
(date-sorter
|
||||
(lambda (a b)
|
||||
(time-less-p (get-text-property 0 'date (aref (cadr a) 3))
|
||||
(get-text-property 0 'date (aref (cadr b) 3)))))
|
||||
(format-generator
|
||||
(lambda (format)
|
||||
(let ((field (car format))
|
||||
(width (cdr format)))
|
||||
(cl-case field
|
||||
(page `("Pg." 3 ,page-sorter :read-only t :right-alight t))
|
||||
(page `("Pg."
|
||||
,width
|
||||
,page-sorter
|
||||
:read-only t
|
||||
:right-align t))
|
||||
(date `("Date"
|
||||
,width
|
||||
,date-sorter
|
||||
:read-only t))
|
||||
(t (list
|
||||
(capitalize (symbol-name field))
|
||||
width t :read-only t)))))))
|
||||
width
|
||||
t
|
||||
:read-only t)))))))
|
||||
(setq tabulated-list-entries 'pdf-annot-list-entries
|
||||
tabulated-list-format (vconcat
|
||||
(mapcar
|
||||
|
||||
@@ -429,9 +429,9 @@ WINDOW and IMAGE-WIDTH decide the page and scale of the final image."
|
||||
(pdf-cache-lookup-image
|
||||
page
|
||||
image-width
|
||||
(if (not pdf-view-use-scaling)
|
||||
image-width
|
||||
(* 2 image-width))))
|
||||
(if pdf-view-use-scaling
|
||||
(* 2 image-width)
|
||||
image-width)))
|
||||
(setq page (pop pdf-cache--prefetch-pages)))
|
||||
(pdf-util-debug
|
||||
(when (null page)
|
||||
|
||||
@@ -305,7 +305,9 @@ error."
|
||||
(setq pdf-info--queue (tq-create proc))))
|
||||
pdf-info--queue)
|
||||
|
||||
(advice-add 'tq-process-buffer :around #'pdf-info--tq-workaround)
|
||||
(when (< emacs-major-version 27)
|
||||
(advice-add 'tq-process-buffer :around #'pdf-info--tq-workaround))
|
||||
|
||||
(defun pdf-info--tq-workaround (orig-fun tq &rest args)
|
||||
"Fix a bug in trunk where the wrong callback gets called.
|
||||
|
||||
@@ -1031,7 +1033,11 @@ Manually opened documents are never closed automatically."
|
||||
Returns t, if the document was actually open, otherwise nil.
|
||||
This command is rarely needed, see also `pdf-info-open'."
|
||||
(let* ((pdf (pdf-info--normalize-file-or-buffer file-or-buffer))
|
||||
(buffer (find-buffer-visiting pdf)))
|
||||
(buffer (cond
|
||||
((not file-or-buffer) (current-buffer))
|
||||
((bufferp file-or-buffer) file-or-buffer)
|
||||
((stringp file-or-buffer)
|
||||
(find-buffer-visiting file-or-buffer)))))
|
||||
(prog1
|
||||
(pdf-info-query 'close pdf)
|
||||
(if (buffer-live-p buffer)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defvar pdf-misc-minor-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "I") 'pdf-misc-display-metadata)
|
||||
@@ -187,7 +189,7 @@
|
||||
:group 'pdf-misc
|
||||
(pdf-util-assert-pdf-buffer))
|
||||
|
||||
(defun pdf-misc-popup-context-menu ()
|
||||
(defun pdf-misc-popup-context-menu (_event)
|
||||
"Popup a context menu at position."
|
||||
(interactive "@e")
|
||||
(popup-menu
|
||||
@@ -277,6 +279,10 @@ use when printing the PDF. Optionally, save the choice"
|
||||
(setq pdf-misc-print-program-executable program))))))
|
||||
|
||||
(defun pdf-misc-print-document (filename &optional interactive-p)
|
||||
"Print the PDF doc FILENAME.
|
||||
|
||||
`pdf-misc-print-program' handles the print program, which see for
|
||||
definition of INTERACTIVE-P."
|
||||
(interactive
|
||||
(list (pdf-view-buffer-file-name) t))
|
||||
(cl-check-type filename (and string (satisfies file-readable-p)))
|
||||
|
||||
@@ -572,23 +572,6 @@ not call `imenu-sort-function'."
|
||||
(cons title
|
||||
(nconc (nreverse keep-at-top) menulist))))
|
||||
|
||||
;; bugfix for imenu in Emacs 24.3 and below.
|
||||
(when (condition-case nil
|
||||
(progn (imenu--truncate-items '(("" 0))) nil)
|
||||
(error t))
|
||||
(eval-after-load "imenu"
|
||||
'(defun imenu--truncate-items (menulist)
|
||||
"Truncate all strings in MENULIST to `imenu-max-item-length'."
|
||||
(mapc (lambda (item)
|
||||
;; Truncate if necessary.
|
||||
(when (and (numberp imenu-max-item-length)
|
||||
(> (length (car item)) imenu-max-item-length))
|
||||
(setcar item (substring (car item) 0 imenu-max-item-length)))
|
||||
(when (imenu--subalist-p item)
|
||||
(imenu--truncate-items (cdr item))))
|
||||
menulist))))
|
||||
|
||||
|
||||
|
||||
(provide 'pdf-outline)
|
||||
|
||||
|
||||
@@ -113,14 +113,14 @@ position in the original tex file."
|
||||
\\<pdf-sync-minor-mode-map>
|
||||
This works via SyncTeX, which means the TeX sources need to have
|
||||
been compiled with `--synctex=1'. In AUCTeX this can be done by
|
||||
setting `TeX-source-correlate-method' to 'synctex \(before AUCTeX
|
||||
is loaded\) and enabling `TeX-source-correlate-mode'.
|
||||
setting `TeX-source-correlate-method' to `synctex' (before AUCTeX
|
||||
is loaded) and enabling `TeX-source-correlate-mode'.
|
||||
|
||||
Then \\[pdf-sync-backward-search-mouse] in the PDF buffer will open the
|
||||
corresponding TeX location.
|
||||
Then \\[pdf-sync-backward-search-mouse] in the PDF buffer will
|
||||
open the corresponding TeX location.
|
||||
|
||||
If AUCTeX is your preferred tex-mode, this library arranges to
|
||||
bind `pdf-sync-forward-display-pdf-key' \(the default is `C-c C-g'\)
|
||||
bind `pdf-sync-forward-display-pdf-key' (the default is `C-c C-g')
|
||||
to `pdf-sync-forward-search' in `TeX-source-correlate-map'. This
|
||||
function displays the PDF page corresponding to the current
|
||||
position in the TeX buffer. This function only works together
|
||||
@@ -758,7 +758,7 @@ The first such filename is returned, or nil if none was found."
|
||||
(let ((syncname (match-string-no-properties 1)))
|
||||
(when (and (file-exists-p syncname)
|
||||
(file-equal-p filename syncname))
|
||||
(goto-char (point-at-bol))
|
||||
(goto-char (line-beginning-position))
|
||||
(throw 'found syncname))))
|
||||
(setq end beg
|
||||
beg (point-min))
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
(define-package "pdf-tools" "20220103.308" "Support library for PDF documents"
|
||||
'((emacs "24.3")
|
||||
(nadvice "0.3")
|
||||
(define-package "pdf-tools" "20221202.1104" "Support library for PDF documents"
|
||||
'((emacs "26.3")
|
||||
(tablist "1.0")
|
||||
(let-alist "1.0.4"))
|
||||
:commit "ed1d4fc4b02eaf40fbaa7a1a8a2c59eff2a8555d" :authors
|
||||
:commit "b8079e4ebc2936f9772657332d50936350a65825" :authors
|
||||
'(("Andreas Politz" . "mail@andreas-politz.de"))
|
||||
:maintainer
|
||||
'("Vedang Manerikar" . "vedang.manerikar@gmail.com")
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
;; URL: http://github.com/vedang/pdf-tools/
|
||||
;; Keywords: files, multimedia
|
||||
;; Package: pdf-tools
|
||||
;; Version: 1.0.0snapshot
|
||||
;; Package-Requires: ((emacs "24.3") (nadvice "0.3") (tablist "1.0") (let-alist "1.0.4"))
|
||||
;; Version: 1.0.0
|
||||
;; Package-Requires: ((emacs "26.3") (tablist "1.0") (let-alist "1.0.4"))
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
@@ -239,6 +239,7 @@ Returns a appropriate directory or nil. See also
|
||||
(list default-directory
|
||||
(expand-file-name "build/server" pdf-tools-directory)
|
||||
(expand-file-name "server")
|
||||
(expand-file-name "server" pdf-tools-directory)
|
||||
(expand-file-name "../server" pdf-tools-directory))))
|
||||
|
||||
(defun pdf-tools-msys2-directory (&optional noninteractive-p)
|
||||
@@ -432,11 +433,15 @@ See `pdf-view-mode' and `pdf-tools-enabled-modes'."
|
||||
(pdf-virtual-global-minor-mode 1))
|
||||
(add-hook 'pdf-view-mode-hook #'pdf-tools-enable-minor-modes)
|
||||
(dolist (buf (buffer-list))
|
||||
(with-current-buffer buf
|
||||
(when (and (not (derived-mode-p 'pdf-view-mode))
|
||||
(pdf-tools-pdf-buffer-p)
|
||||
(buffer-file-name))
|
||||
(pdf-view-mode)))))
|
||||
;; This when check should not be necessary, but somehow dead
|
||||
;; buffers are showing up here. See
|
||||
;; https://github.com/vedang/pdf-tools/pull/93
|
||||
(when (buffer-live-p buf)
|
||||
(with-current-buffer buf
|
||||
(when (and (not (derived-mode-p 'pdf-view-mode))
|
||||
(pdf-tools-pdf-buffer-p)
|
||||
(buffer-file-name))
|
||||
(pdf-view-mode))))))
|
||||
|
||||
(defun pdf-tools-uninstall ()
|
||||
"Uninstall PDF-Tools in all current and future PDF buffers."
|
||||
|
||||
@@ -38,94 +38,6 @@
|
||||
(declare-function pdf-view-image-type "pdf-view")
|
||||
|
||||
|
||||
|
||||
;; * ================================================================== *
|
||||
;; * Compatibility with older Emacssen (< 25.1)
|
||||
;; * ================================================================== *
|
||||
|
||||
;; The with-file-modes macro is only available in recent Emacs
|
||||
;; versions.
|
||||
(eval-when-compile
|
||||
(unless (fboundp 'with-file-modes)
|
||||
(defmacro with-file-modes (modes &rest body)
|
||||
"Execute BODY with default file permissions temporarily set to MODES.
|
||||
MODES is as for `set-default-file-modes'."
|
||||
(declare (indent 1) (debug t))
|
||||
(let ((umask (make-symbol "umask")))
|
||||
`(let ((,umask (default-file-modes)))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(set-default-file-modes ,modes)
|
||||
,@body)
|
||||
(set-default-file-modes ,umask)))))))
|
||||
|
||||
(unless (fboundp 'alist-get) ;;25.1
|
||||
(defun alist-get (key alist &optional default remove)
|
||||
"Get the value associated to KEY in ALIST.
|
||||
DEFAULT is the value to return if KEY is not found in ALIST.
|
||||
REMOVE, if non-nil, means that when setting this element, we should
|
||||
remove the entry if the new value is `eql' to DEFAULT."
|
||||
(ignore remove) ;;Silence byte-compiler.
|
||||
(let ((x (assq key alist)))
|
||||
(if x (cdr x) default))))
|
||||
|
||||
(require 'register)
|
||||
(unless (fboundp 'register-read-with-preview)
|
||||
(defalias 'register-read-with-preview #'read-char
|
||||
"Compatibility alias for pdf-tools."))
|
||||
|
||||
;; In Emacs 24.3 window-width does not have a PIXELWISE argument.
|
||||
(defmacro pdf-util-window-pixel-width (&optional window)
|
||||
"Return the width of WINDOW in pixel."
|
||||
(if (< (cdr (subr-arity (symbol-function 'window-body-width))) 2)
|
||||
(let ((window* (make-symbol "window")))
|
||||
`(let ((,window* ,window))
|
||||
(* (window-body-width ,window*)
|
||||
(frame-char-width (window-frame ,window*)))))
|
||||
`(window-body-width ,window t)))
|
||||
|
||||
;; In Emacs 24.3 image-mode-winprops leads to infinite recursion.
|
||||
(unless (or (> emacs-major-version 24)
|
||||
(and (= emacs-major-version 24)
|
||||
(>= emacs-minor-version 4)))
|
||||
(require 'image-mode)
|
||||
(defvar image-mode-winprops-original-function
|
||||
(symbol-function 'image-mode-winprops))
|
||||
(defvar image-mode-winprops-alist)
|
||||
(eval-after-load "image-mode"
|
||||
'(defun image-mode-winprops (&optional window cleanup)
|
||||
(if (not (eq major-mode 'pdf-view-mode))
|
||||
(funcall image-mode-winprops-original-function
|
||||
window cleanup)
|
||||
(cond ((null window)
|
||||
(setq window
|
||||
(if (eq (current-buffer) (window-buffer)) (selected-window) t)))
|
||||
((eq window t))
|
||||
((not (windowp window))
|
||||
(error "Not a window: %s" window)))
|
||||
(when cleanup
|
||||
(setq image-mode-winprops-alist
|
||||
(delq nil (mapcar (lambda (winprop)
|
||||
(let ((w (car-safe winprop)))
|
||||
(if (or (not (windowp w)) (window-live-p w))
|
||||
winprop)))
|
||||
image-mode-winprops-alist))))
|
||||
(let ((winprops (assq window image-mode-winprops-alist)))
|
||||
;; For new windows, set defaults from the latest.
|
||||
(if winprops
|
||||
;; Move window to front.
|
||||
(setq image-mode-winprops-alist
|
||||
(cons winprops (delq winprops image-mode-winprops-alist)))
|
||||
(setq winprops (cons window
|
||||
(copy-alist (cdar image-mode-winprops-alist))))
|
||||
;; Add winprops before running the hook, to avoid inf-loops if the hook
|
||||
;; triggers window-configuration-change-hook.
|
||||
(setq image-mode-winprops-alist
|
||||
(cons winprops image-mode-winprops-alist))
|
||||
(run-hook-with-args 'image-mode-new-window-functions winprops))
|
||||
winprops)))))
|
||||
|
||||
|
||||
|
||||
;; * ================================================================== *
|
||||
;; * Transforming coordinates
|
||||
@@ -648,7 +560,7 @@ Signal an error, if color is invalid."
|
||||
(unless values
|
||||
(signal 'wrong-type-argument (list 'color-defined-p color)))
|
||||
(apply #'format "#%02x%02x%02x"
|
||||
(mapcar (lambda (c) (lsh c -8))
|
||||
(mapcar (lambda (c) (ash c -8))
|
||||
values)))))
|
||||
|
||||
(defun pdf-util-highlight-regexp-in-string (regexp string &optional face)
|
||||
@@ -669,6 +581,8 @@ string."
|
||||
'face (or face 'match))))
|
||||
(buffer-string)))
|
||||
|
||||
(autoload 'list-colors-duplicates "facemenu")
|
||||
|
||||
(defun pdf-util-color-completions ()
|
||||
"Return a fontified list of defined colors."
|
||||
(let ((color-list (list-colors-duplicates))
|
||||
@@ -942,14 +856,22 @@ See also `regexp-quote'."
|
||||
|
||||
(defun pdf-util-frame-ppi ()
|
||||
"Return the PPI of the current frame."
|
||||
(let* ((props (frame-monitor-attributes))
|
||||
(px (nthcdr 2 (alist-get 'geometry props)))
|
||||
(mm (alist-get 'mm-size props))
|
||||
(dp (sqrt (+ (expt (nth 0 px) 2)
|
||||
(expt (nth 1 px) 2))))
|
||||
(di (sqrt (+ (expt (/ (nth 0 mm) 25.4) 2)
|
||||
(expt (/ (nth 1 mm) 25.4) 2)))))
|
||||
(/ dp di)))
|
||||
(condition-case nil
|
||||
(let* ((props (frame-monitor-attributes))
|
||||
(px (nthcdr 2 (alist-get 'geometry props)))
|
||||
(mm (alist-get 'mm-size props))
|
||||
(dp (sqrt (+ (expt (nth 0 px) 2)
|
||||
(expt (nth 1 px) 2))))
|
||||
(di (sqrt (+ (expt (/ (nth 0 mm) 25.4) 2)
|
||||
(expt (/ (nth 1 mm) 25.4) 2)))))
|
||||
(/ dp di))
|
||||
;; Calculating frame-ppi failed, return 0 to indicate unknown.
|
||||
;; This can happen when (frame-monitor-attributes) does not have
|
||||
;; the right properties (Emacs 26, 27). It leads to the
|
||||
;; wrong-type-argument error, which is the only one we are
|
||||
;; catching here. We will catch more errors only if we see them
|
||||
;; happening.
|
||||
(wrong-type-argument 0)))
|
||||
|
||||
(defvar pdf-view-use-scaling)
|
||||
|
||||
@@ -1059,14 +981,14 @@ replacement string.
|
||||
IN-FILE coordinates. Each such rectangle triggers one execution
|
||||
of the last commands given earlier in SPEC. E.g. a call like
|
||||
|
||||
\(pdf-util-convert
|
||||
image-file out-file
|
||||
:foreground \"black\"
|
||||
:background \"white\"
|
||||
:commands '(\"-fill\" \"%f\" \"-draw\" \"rectangle %x,%y,%X,%Y\")
|
||||
:apply '((0 0 10 10) (10 10 20 20))
|
||||
:commands '(\"-fill\" \"%b\" \"-draw\" \"rectangle %x,%y,%X,%Y\")
|
||||
:apply '((10 0 20 10) (0 10 10 20)))
|
||||
(pdf-util-convert
|
||||
image-file out-file
|
||||
:foreground \"black\"
|
||||
:background \"white\"
|
||||
:commands \\='(\"-fill\" \"%f\" \"-draw\" \"rectangle %x,%y,%X,%Y\")
|
||||
:apply \\='((0 0 10 10) (10 10 20 20))
|
||||
:commands \\='(\"-fill\" \"%b\" \"-draw\" \"rectangle %x,%y,%X,%Y\")
|
||||
:apply \\='((10 0 20 10) (0 10 10 20)))
|
||||
|
||||
would draw a 4x4 checkerboard pattern in the left corner of the
|
||||
image, while leaving the rest of it as it was.
|
||||
|
||||
@@ -86,7 +86,7 @@ FIXME: Explain dis-/advantages of imagemagick and png."
|
||||
:group 'pdf-view
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom pdf-view-use-scaling nil
|
||||
(defcustom pdf-view-use-scaling t
|
||||
"Whether images should be allowed to be scaled for rendering.
|
||||
|
||||
This variable affects both the reuse of higher-resolution images
|
||||
@@ -334,6 +334,10 @@ PNG images in Emacs buffers."
|
||||
(setq-local mwheel-scroll-down-function
|
||||
#'pdf-view-scroll-down-or-previous-page))
|
||||
|
||||
;; Disable pixel-scroll-precision-mode locally if enabled
|
||||
(if (bound-and-true-p pixel-scroll-precision-mode)
|
||||
(set (make-local-variable 'pixel-scroll-precision-mode) nil))
|
||||
|
||||
;; Clearing overlays
|
||||
(add-hook 'change-major-mode-hook
|
||||
(lambda ()
|
||||
@@ -370,14 +374,6 @@ PNG images in Emacs buffers."
|
||||
;; Enable transient-mark-mode, so region deactivation when quitting
|
||||
;; will work.
|
||||
(setq-local transient-mark-mode t)
|
||||
;; In Emacs >= 24.4, `cua-copy-region' should have been advised when
|
||||
;; loading pdf-view.el so as to make it work with
|
||||
;; pdf-view-mode. Disable cua-mode if that is not the case.
|
||||
;; FIXME: cua-mode is a global minor-mode, but setting cua-mode to
|
||||
;; nil seems to do the trick.
|
||||
(when (and (bound-and-true-p cua-mode)
|
||||
(version< emacs-version "24.4"))
|
||||
(setq-local cua-mode nil))
|
||||
|
||||
(add-hook 'window-configuration-change-hook
|
||||
'pdf-view-redisplay-some-windows nil t)
|
||||
@@ -399,16 +395,15 @@ PNG images in Emacs buffers."
|
||||
(pdf-view-check-incompatible-modes buffer)))
|
||||
(current-buffer)))
|
||||
|
||||
(unless (version< emacs-version "24.4")
|
||||
(advice-add 'cua-copy-region
|
||||
:before-until
|
||||
#'cua-copy-region--pdf-view-advice)
|
||||
(defun cua-copy-region--pdf-view-advice (&rest _)
|
||||
"If the current buffer is in `pdf-view' mode, call
|
||||
`pdf-view-kill-ring-save'."
|
||||
(when (eq major-mode 'pdf-view-mode)
|
||||
(pdf-view-kill-ring-save)
|
||||
t)))
|
||||
(advice-add 'cua-copy-region
|
||||
:before-until
|
||||
#'cua-copy-region--pdf-view-advice)
|
||||
|
||||
(defun cua-copy-region--pdf-view-advice (&rest _)
|
||||
"If the current buffer is in `pdf-view' mode, call `pdf-view-kill-ring-save'."
|
||||
(when (eq major-mode 'pdf-view-mode)
|
||||
(pdf-view-kill-ring-save)
|
||||
t))
|
||||
|
||||
(defun pdf-view-check-incompatible-modes (&optional buffer)
|
||||
"Check BUFFER for incompatible modes, maybe issue a warning."
|
||||
@@ -479,6 +474,12 @@ operating on a local copy of a remote file."
|
||||
(when (file-exists-p tempfile)
|
||||
(delete-file tempfile))))))
|
||||
|
||||
(defun pdf-view--after-revert ()
|
||||
"Reload the local copy in case of a remote file, and close the document."
|
||||
(when pdf-view--buffer-file-name
|
||||
(write-region nil nil pdf-view--buffer-file-name nil 'no-message))
|
||||
(pdf-info-close))
|
||||
|
||||
(defun pdf-view-revert-buffer (&optional ignore-auto noconfirm)
|
||||
"Revert buffer while preserving current modes.
|
||||
|
||||
@@ -492,7 +493,7 @@ Optional parameters IGNORE-AUTO and NOCONFIRM are defined as in
|
||||
(let ((revert-buffer-function (when (fboundp #'revert-buffer--default)
|
||||
#'revert-buffer--default))
|
||||
(after-revert-hook
|
||||
(cons #'pdf-info-close
|
||||
(cons #'pdf-view--after-revert
|
||||
after-revert-hook)))
|
||||
(prog1
|
||||
(revert-buffer ignore-auto noconfirm 'preserve-modes)
|
||||
@@ -695,12 +696,15 @@ next page only on typing SPC (ARG is nil)."
|
||||
(interactive "P")
|
||||
(if (or pdf-view-continuous (null arg))
|
||||
(let ((hscroll (window-hscroll))
|
||||
(cur-page (pdf-view-current-page)))
|
||||
(when (or (= (window-vscroll nil pdf-view-have-image-mode-pixel-vscroll)
|
||||
(image-scroll-up arg))
|
||||
;; Workaround rounding/off-by-one issues.
|
||||
(memq pdf-view-display-size
|
||||
'(fit-height fit-page)))
|
||||
(cur-page (pdf-view-current-page))
|
||||
(win-scroll (window-vscroll nil pdf-view-have-image-mode-pixel-vscroll))
|
||||
(img-scroll (image-scroll-up arg)))
|
||||
(when (or
|
||||
;; There is no next line for the image to scroll to
|
||||
(and img-scroll (= win-scroll img-scroll))
|
||||
;; Workaround rounding/off-by-one issues.
|
||||
(memq pdf-view-display-size
|
||||
'(fit-height fit-page)))
|
||||
(pdf-view-next-page)
|
||||
(when (/= cur-page (pdf-view-current-page))
|
||||
(image-bob)
|
||||
@@ -717,12 +721,15 @@ to previous page only on typing DEL (ARG is nil)."
|
||||
(interactive "P")
|
||||
(if (or pdf-view-continuous (null arg))
|
||||
(let ((hscroll (window-hscroll))
|
||||
(cur-page (pdf-view-current-page)))
|
||||
(when (or (= (window-vscroll nil pdf-view-have-image-mode-pixel-vscroll)
|
||||
(image-scroll-down arg))
|
||||
;; Workaround rounding/off-by-one issues.
|
||||
(memq pdf-view-display-size
|
||||
'(fit-height fit-page)))
|
||||
(cur-page (pdf-view-current-page))
|
||||
(win-scroll (window-vscroll nil pdf-view-have-image-mode-pixel-vscroll))
|
||||
(img-scroll (image-scroll-down arg)))
|
||||
(when (or
|
||||
;; There is no previous line for the image to scroll to
|
||||
(and img-scroll (= win-scroll img-scroll))
|
||||
;; Workaround rounding/off-by-one issues.
|
||||
(memq pdf-view-display-size
|
||||
'(fit-height fit-page)))
|
||||
(pdf-view-previous-page)
|
||||
(when (/= cur-page (pdf-view-current-page))
|
||||
(image-eob)
|
||||
@@ -779,6 +786,32 @@ displayed page number."
|
||||
(error "No such label: %s" label))
|
||||
(pdf-view-goto-page (1+ index))))
|
||||
|
||||
(defun pdf-view-center-in-window ()
|
||||
"Center PDF in window horizontally."
|
||||
(interactive)
|
||||
(image-set-window-hscroll
|
||||
(/ (* (- (car (pdf-view-image-size))
|
||||
(window-pixel-width))
|
||||
(window-width))
|
||||
2 (window-pixel-width))) ; convert from pixel to character width
|
||||
(pdf-view-redisplay t))
|
||||
|
||||
(defun pdf-view-align-left ()
|
||||
"Align left edge of pdf with left edge of window."
|
||||
(interactive)
|
||||
(image-set-window-hscroll 0)
|
||||
(pdf-view-redisplay t))
|
||||
|
||||
(defun pdf-view-align-right ()
|
||||
"Align right edge of pdf with right edge of window."
|
||||
(interactive)
|
||||
(image-set-window-hscroll
|
||||
(/ (* (- (car (pdf-view-image-size))
|
||||
(window-pixel-width))
|
||||
(window-width))
|
||||
(window-pixel-width))) ; convert from pixel to character width
|
||||
(pdf-view-redisplay t))
|
||||
|
||||
|
||||
;; * ================================================================== *
|
||||
;; * Slicing
|
||||
@@ -922,9 +955,9 @@ See also `pdf-view-use-imagemagick'."
|
||||
(let* ((size (pdf-view-desired-image-size page window))
|
||||
(data (pdf-cache-renderpage
|
||||
page (car size)
|
||||
(if (not pdf-view-use-scaling)
|
||||
(car size)
|
||||
(* 2 (car size)))))
|
||||
(if pdf-view-use-scaling
|
||||
(* 2 (car size))
|
||||
(car size))))
|
||||
(hotspots (pdf-view-apply-hotspot-functions
|
||||
window page size)))
|
||||
(pdf-view-create-image data
|
||||
@@ -1093,7 +1126,7 @@ If WINDOW is t, redisplay pages in all windows."
|
||||
(let* ((pagesize (pdf-cache-pagesize
|
||||
(or page (pdf-view-current-page window))))
|
||||
(slice (pdf-view-current-slice window))
|
||||
(width-scale (/ (/ (float (pdf-util-window-pixel-width window))
|
||||
(width-scale (/ (/ (float (window-body-width window t))
|
||||
(or (nth 2 slice) 1.0))
|
||||
(float (car pagesize))))
|
||||
(height (- (nth 3 (window-inside-pixel-edges window))
|
||||
|
||||
@@ -31,12 +31,6 @@
|
||||
;; asynchronous case.
|
||||
|
||||
;;; Code:
|
||||
(eval-when-compile
|
||||
(unless (or (> emacs-major-version 24)
|
||||
(and (= emacs-major-version 24)
|
||||
(>= emacs-minor-version 4)))
|
||||
(error "pdf-virtual.el only works with Emacs >= 24.4")))
|
||||
|
||||
(require 'let-alist)
|
||||
(require 'pdf-info)
|
||||
(require 'pdf-util)
|
||||
@@ -735,8 +729,8 @@ PAGE should be a page-number."
|
||||
(defun ,fn ,(cons base-fn-arg arglist)
|
||||
,(format "%sPDF virtual adapter to `%s'.
|
||||
|
||||
This function delegates to `%s', unless the FILE-OR-BUFFER
|
||||
argument denotes a VPDF document."
|
||||
This function delegates to `%s',
|
||||
unless the FILE-OR-BUFFER argument denotes a VPDF document."
|
||||
(if doc (concat doc "\n\n") "")
|
||||
base-fn
|
||||
base-fn)
|
||||
|
||||
Reference in New Issue
Block a user