summaryrefslogtreecommitdiff
path: root/server/epdfinfo.c
AgeCommit message (Collapse)Author
2025-12-29feat(midnight-mode): add gamma correction and fix RGB bugsZiv Scully
Add gamma correction options for better contrast control in midnight mode: - pdf-view-midnight-gamma: nonlinearly scale lightness (default 1.0) - pdf-view-midnight-gamma-before-invert: control gamma application order Bug fixes: - Fix RGB normalization (255 not 256) - was causing incorrect background color - Add missing black→foreground fast path (comment existed but code was missing) Closes: #329 Author: @vizziv
2025-12-28fix(server): replace tempnam with mkstemp/_tempnamJimmy Yuen Ho Wong
Use platform-appropriate temp file creation: - _tempnam() on Windows (Microsoft-recommended) - mkstemp() on Unix-like systems Fixes #110, addresses #316 Supersedes #235
2023-06-11Allow creation of markup annotations without a text selectionAugusto Stoffel
This allows calling `pdf-info-addannot` from Lisp with a nil `markup-edges` argument, which was previously disallowed. In this case, the annotation covers exactly the selected region of the page, without attempting to match it to a certain text region. This means that you can now highlight an exact region! Just select the region by holding down the Meta key and dragging the mouse. Then invoke `pdf-annot-add-highlight-markup-annotation` (with `C-c C-a h`) and voila! Closes: #191
2023-06-10Add hue contribution of background color to inverted midnight modeZach Kost-Smith
From the comments in the PR, @smithzvk explains the changes: > I was bugged that it didn't pick up the hue from the background, > however, so I made the all color a/b parameters start from the a/b > parameters of the BG color. This makes the PDF background (white) > map to your BG color and PDF foreground (black) map to your FG > color, which can be set to your theme background making it seem > pretty seamless. Note that if you set your BG and FG to a color > theme without zero saturation (a gray tone of some sort), then you > recover the original behavior. > > I also reinstated the cached transforms for background and the last > color computed. > > I also refactored the loop to move the switch statement outside of > the loop. It is more repetitive, but it was needed to get rid of > some warnings about potentially uninitialized variables. It should > also be faster as the branch was removed from the loop. > > I also ditched the gamma correction as it seemed to be doing the > wrong thing and I never had a theoretical reasoning for it. I can > get similar results if I just set my BG color to something like > gray5 instead of black. Barely a difference in background but the > hinting on the fonts is showing again. The root of my issue may > have always been some kind of display calibration issue. Closes: #197
2023-06-10Fix: high contrast render in midnight modeZero
Uses the Lightness values from the `pdf-view-midnight-colors` `fg` and `bg` to scale the inverted color's lightness. Band-aid till better method is found. Relates to: #69
2023-01-17Add support for midnight mode with colorZach Kost-Smith
This inversion method attempts to maintain the color hue and saturation but inverts the lightness using the OKLab color space[^1]. [^1]: https://bottosson.github.io/posts/oklab/ * server/epdfinfo.c (image-recolor): Add feature to support the OKLab inversion method functionality * lisp/pdf-view.el (pdf-view-midnight-invert): Add new variable to invert the image color lightness while maintaining hue. (pdf-view-midnight-minor-mode): Account for above. * lisp/pdf-info.el (pdf-info-query--parse-response): Handle changes to :render/usecolors command Closes: #69 Closes: #169 Closes: politza/pdf-tools#698 Closes: politza/pdf-tools#608
2023-01-16Make selection style configurable by introducing a new variablelennonhill
Make selection-style configurable via `pdf-view-selection-style`. A default value of `word` might be desirable, as selection is usually intended to select entire words is perceptually faster than glyph-based selection. This affects selections and highlights, but not search. Limitation: The selection type is fixed for all currently selected regions. Selecting multiple regions with different selection styles at the same time would require storing the selection style for every region and replacing the protocol for `cmd_addannot` with a more flexible one, e.g. the keyword-based one used by `cmd_renderpage`. Closes: #73
2023-01-15epdfinfo: Extract server code for selection_style validationlennonhill
2022-10-04Revert "Adds translattion of highlight annotations"Vedang Manerikar
This reverts commit 0107f80dcf268d08ac075b01729820062c0fbd67 The reason for doing this is explained by @vizs in #143, copying the message here: Andreas wrote the function `annotation_translate_quadrilateral`[^1][^2] to fix misplaced annotations due to the then bug in `glib`. This misplacement bug can be seen in the images posted in issue politza/pdf-tools#577, along with PDFs in which the bug can be reproduced. This lack of translation in the `glib` backend was fixed in `poppler 0.86.0` but the workaround was still left hanging in `epdfinfo.c` which brings us to today where this unneeded translation bites our back. I commented out the calls to `annotation_translate_quadrilateral` in `epdinfo.c` and to my surprise, there were no misplaced translations in files which displayed the misplacing behaviour and in files which did not have this behaviour. [1]: https://github.com/politza/pdf-tools/commit/0107f80dcf268d08ac075b01729820062c0fbd67 [2]: politza/pdf-tools#122 Closes: #143 Closes: #146
2022-08-22Fix: remove execute permisions from temp filesZachary Newman
They aren't used. Fixes #138.
2022-05-21Remove usage of all private poppler headers in pdf-toolsPi-Cla
This commit also removes C++ entirely, as it is not needed anymore for correct compilation of `epdfinfo`. The following changes are made: - Remove private headers from all the server code. This involves: - Replace private header functionality with the correct public functions provided by poppler. - Remove unneeded headers around date checks - Delete dead-code (headers, m4 macros) - Remove C++, g++ and similar aliases from all the code. Also: - Remove related information from the README - Remove related information from CI and Dockerfiles Work done by: @Pi-Cla Closes: #105, #103, #109, #114
2022-05-11Revert "Use mkstemp instead of tempnam"Vedang Manerikar
This reverts commit 37bbe861755bc60c7cc333359fee3e2a5d919c77. As explained by @ShuguangSun (re: testing the change on Windows) on > Sorry. It is my fault. The issue is still there. The different is > that the temp dir is created now. However, it reports "Unable to > create temporary file". Reopens: #110
2022-05-11Use mkstemp instead of tempnamVedang Manerikar
This reverts commit 8ee31220a6ae3e41549bfffca7a89c481d270004 and brings in @JunyuanChen's change once again. We modify the commit to fix the problem on Windows by changing the code as follows: --- a/server/epdfinfo.c +++ b/server/epdfinfo.c @@ -347,6 +347,6 @@ static char* mktempfile() { - char template[] = "/tmp/epdfinfoXXXXXX"; + char template[] = P_tmpdir "/epdfinfoXXXXXX"; char *filename = malloc(sizeof(template)); memcpy(filename, template, sizeof(template)); This works correctly for Windows (as confirmed by @ShuguangSun), Mac (tested by @vedang) and Linux (tested by @Junyuanchen) Relates to: #101, #94 Closes: #110
2022-05-09Revert "Use mkstemp instead of tempnam"Vedang Manerikar
This reverts commit d63a1e7d87f9b0a19209f2eeb170bcf64612aa2f. In d63a1e7, @JunyuanChen fixed a long standing compilation warning by replacing `tempnam` with `mkstemp` in `epdfinfo`. However, the `mkstemp` implementation does not work correctly on MS Windows (probably because the path template is "wrong" for Windows). I am reverting the commit and opening a new issue #110 to track the correct implementation of `mkstemp` (or equivalent) on MS Windows. It would also be great to add a test against Windows CI to open a PDF and check that the operation completes successfully. Closes: #101
2022-04-25Use mkstemp instead of tempnamJunyuanChen
Removes the following warning when compiling `epdfinfo`: ``` build/server/epdfinfo.c:354: warning: the use of `tempnam' is dangerous, better use `mkstemp' ```
2022-01-03Minor language correction: it's -> itsVedang Manerikar
The correct possessive with it is "its", not "it's". Closes: politza#689
2019-12-28Adapt to changes in synctex APIAndreas Politz
2019-11-26Fix typosDamien Cassou
Typos found with codespell.
2017-09-18Revert incorrect previous change and use the old methodAndreas Politz
Discard synctex's stdout by redefining printf as before.
2017-09-18Mute synctex library's stdoutAndreas Politz
2017-08-25Improves error messages for synctex failuresAndreas Politz
2017-08-11Fix trailing whitespaceAndreas Politz
2016-11-11Fix a synctex-backward-search bug not properly escaping filenamesAndreas Politz
2016-02-26Enable building under WindowsLars Ljung
Added some functions missing in Windows. Switch to binary mode on stdin and stdout to avoid line ending issues.
2015-11-12Adds translattion of highlight annotationsv0.70Andreas Politz
2015-07-16Avoid gcc warningAndreas Politz
*server/epdfinfo.c(annotation_print): Make error label conditional.
2015-06-13Drop default error logfile.Andreas Politz
* server/epdfinfo.c (main): Withou args redirect to /dev/null.
2015-06-12Added a noop command to the server.Andreas Politz
* server/epdfinfo.c (cmd_ping): Pong. * lisp/pdf-info.el (pdf-info-ping): Handle it.
2015-06-12Fix :crop-to handling.Andreas Politz
* server/epdfinfo.c (cmd_renderpage): Use the correct transformations.
2015-06-07Unified rendering commands in the server.Andreas Politz
* server/epdfinfo.c (cmd_renderpage): Incorporated cmd_renderpage_x commands into cmd_renderpage. * lisp/pdf-view.el (pdf-view-extract-region-image): Use new rendering capabilities. * lisp/pdf-info.el (pdf-info-renderpage): Adhere to and provide new command protocol. (pdf-info-renderpage-text-regions): Use pdf-info-renderpage. (pdf-info-renderpage-highlight): Use pdf-info-renderpage.
2015-06-06Modified visual highlighting styleAndreas Politz
* server/epdfinfo.c (cmd_renderpage_highlight): Drop the x/y-offsets, otherwise the visuals do not accurately represent the selected region.
2015-06-02Make filter function independent of optionsAndreas Politz
* server/epdfinfo.c (image_recolor): Use PopplerColor as argument. Some renaming. (image_render_page): Apply signature difference.
2015-05-31Added recolor feature based on pdf-info-setoptionsoscar
2015-05-14Merge branch 'master' into optionsoscar
Conflicts: lisp/pdf-info.el server/epdfinfo.c server/epdfinfo.h
2015-05-05Added navigation by and display of pagelabels.Andreas Politz
* server/epdfinfo.c: New command pagelabels. * lisp/pdf-view.el (pdf-view-goto-label): New command for going to the page corresponding to it's label. (pdf-view-mode-map): Bind it to `M-g l' . * lisp/pdf-outline.el (pdf-outline-display-labels): New option for displaying labels instead of page numbers. (pdf-outline-insert-outline, pdf-outline-insert-outline, pdf-outline-imenu-create-item, pdf-outline-imenu-create-index-flat, pdf-outline-imenu-create-index-tree, pdf-outline-imenu-create-index-tree-1): Handle it. * lisp/pdf-info.el (pdf-info-pagelabels): New command returning a list of pagelabels. (pdf-info-query--transform-response): Handle it. * NEWS: Add news items.
2015-04-20Build CompatibilityAndreas Politz
* server/configure.ac: Check for error.h * server/epdfinfo.h: * server/epdfinfo.c: Use result of above check. * server/autogen.sh: Use /bin/sh instead of bash.
2015-04-12Streamline PPM writing.Andreas Politz
* server/epdfinfo.c (image_write): Use a buffer for writing.
2015-04-07Remove unnecessary path check.Andreas Politz
* server/epdfinfo.c (cmd_open): g_filename_to_uri already checks for absolutity.
2015-04-01Removed sneaked in commands from other branch.Andreas Politz
* server/epdfinfo.c: Remove get- and setoptions
2015-04-01CosmeticsAndreas Politz
2015-04-01Use a macro for declaring commands.Andreas Politz
* server/epdfinfo.h (DEC_CMD, DEC_CMD2): New macros. * server/epdfinfo.c (commands): Use macros.
2015-04-01Summary: Removed unused argument type.Andreas Politz
* server/epdfinfo.c (command_arg_parse_arg): Remove ARG_QUADRILATERAL. * server/epdfinfo.h (command_arg_type_t): Dito.
2015-04-01Improved command handling.Andreas Politz
* server/epdfinfo.h (DEC_CMD, DEC_CMD2, DEC_DOPT): Macros for declaring commands and options. * server/epdfinfo.c (command_arg_parse_arg): Removed unused ARG_QUADRILATERAL. (command_arg_print, command_arg_type_size): New function. (document_options): New array holding document options. (cmd_getoptions, cmd_setoptions): Use above array. (commands): Use Macros.
2015-03-31Started options branch.Andreas Politz
* server/epdfinfo.h : Add option structs. * server/epdfinfo.c (image_render_page): Use struct as argument. (cmd_getoptions, cmd_setoptions): New commands. * lisp/pdf-info.el (pdf-info-query--transform-response, pdf-info-getoptions, pdf-info-setoptions): Handle new commands.
2015-03-30Added PCRE support.Andreas Politz
* lisp/pdf-info.el (pdf-info-query--transform-response): Put match face properties on the matched text of the line. (pdf-info-search-string): The returned line now contains face properties on the matched part. (pdf-info-search-regexp): This function now searches for PCRE, and as such the calling convention has changed to support the various flags of the underlying engine. (pdf-info-regexp-compile-flags, pdf-info-regexp-match-flags): List of regexp flags. * server/epdfinfo.c: (cmd_search_regexp): Use complex numeric flags of the new engine instead of the old boolean ones. Now returns both the matched text and it's corresponding line. (cmd_search_string): Return both as well. (cmd_regexp_flags): New command returning regexp flags and their values. * lisp/pdf-util.el (pdf-util-highlight-regexp-in-string): New function for propertizing a string. (pdf-util-edges-union): Added minor optimization.
2015-03-23Added compile check for CYGWINAndreas Politz
* server/epdfinfo.c: Don't include poppler Error.h when compiling for * cygwin. (There may be a better fix, i.e change the include path priorities?) server/epdfinfo.h: Dito
2015-03-09Handle empty annotation regions.Andreas Politz
* server/epdfinfo.c (region_print): Print a zero sized region at 0,0.
2015-02-18Open error log in append mode.Andreas Politz
* server/epdfinfo.c (main): Use `a'.
2015-02-13Treat compiler warnings.Andreas Politz
* server/poppler-hack.cc (poppler_annot_markup_get_type): Remove unused variable. * server/epdfinfo.c (cmd_charlayout): Use proper type. (main): Initialize variable.
2015-02-12Added charlayout command.Andreas Politz
* server/epdfinfo.c (cmd_charlayout): Provides edges of character. * lisp/pdf-info.el (pdf-info-query--transform-response): Added transform. (pdf-info-charlayout): Added interface for the command.