Copy PDF text without hyphenated words

Hi, I recently learned that Typst seems to be able to produce PDFs where a hyphenated text can be copied without the hyphenation (so all words in the copied text are not hyphenated). I seem to recall that the PDF format has an extra mode for this, where the creation program can embed some text that should only appear when copied and replace the word parts that are visible on the page. ConTeXt, in it's default mode, seems not to embed this text. When copying hyphenated words, the hyphenated word parts appear as distinct words (even without the hyphen). Is there a way to tell ConTeXt to produce PDF where the text can be copied without hyphenated words? Gerion

On 2/14/2025 2:19 AM, Gerion Entrup wrote:
Hi,
I recently learned that Typst seems to be able to produce PDFs where a hyphenated text can be copied without the hyphenation (so all words in the copied text are not hyphenated). I seem to recall that the PDF format has an extra mode for this, where the creation program can embed some text that should only appear when copied and replace the word parts that are visible on the page.
ConTeXt, in it's default mode, seems not to embed this text. When copying hyphenated words, the hyphenated word parts appear as distinct words (even without the hyphen). Is there a way to tell ConTeXt to produce PDF where the text can be copied without hyphenated words?
This is a fuzzy area and has always depended on how pdf viewers see things. The standard has some suggestions and oenm is to use soft hyphens which is what we do (can be turned off). From your description it looks like actual text is used and in this case, although one can make that work, to me it is not a solution, it not only polutes the page stream, it also can interferes with other features and increases overhead. When a viewer sees aoft hyphen it is assumed that it looks for the next part of the word. Afaik acrobat reader can handle both variants. The other (open source) viewers that I use are a mixed bag (in areas like these). Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

Am Freitag, 14. Februar 2025, 08:48:06 Mitteleuropäische Normalzeit schrieb Hans Hagen via ntg-context:
On 2/14/2025 2:19 AM, Gerion Entrup wrote:
Hi,
I recently learned that Typst seems to be able to produce PDFs where a hyphenated text can be copied without the hyphenation (so all words in the copied text are not hyphenated). I seem to recall that the PDF format has an extra mode for this, where the creation program can embed some text that should only appear when copied and replace the word parts that are visible on the page.
ConTeXt, in it's default mode, seems not to embed this text. When copying hyphenated words, the hyphenated word parts appear as distinct words (even without the hyphen). Is there a way to tell ConTeXt to produce PDF where the text can be copied without hyphenated words?
This is a fuzzy area and has always depended on how pdf viewers see things. The standard has some suggestions and oenm is to use soft hyphens which is what we do (can be turned off). From your description it looks like actual text is used and in this case, although one can make that work, to me it is not a solution, it not only polutes the page stream, it also can interferes with other features and increases overhead.
When a viewer sees aoft hyphen it is assumed that it looks for the next part of the word. Afaik acrobat reader can handle both variants. The other (open source) viewers that I use are a mixed bag (in areas like these).
Thanks for the answer. I researched this for my default PDF-viewer, Okular from KDE, and this program seems to be really special in this regard. It should be actively responsible for the behavior described in my original mail. See https://bugs.kde.org/show_bug.cgi?id=447094#c5 and https://bugs.kde.org/show_bug.cgi?id=233604. Gerion

On Sun, 16 Feb 2025 04:04:11 +0100
Gerion Entrup
I researched this for my default PDF-viewer, Okular from KDE, and this program seems to be really special in this regard.
I don't think it is. I quickly tested a few other viewers and they all behave the same way: - zathura (0.5.11) - evince (46.3.1) - pdftotext (25.01.0) - Firefox PDF Viewer (135.0) Marco

Hi!
Den sön 16 feb. 2025 08:40Marco Patzer
On Sun, 16 Feb 2025 04:04:11 +0100 Gerion Entrup
wrote: I researched this for my default PDF-viewer, Okular from KDE, and this program seems to be really special in this regard.
I don't think it is. I quickly tested a few other viewers and they all behave the same way:
- zathura (0.5.11) - evince (46.3.1) - pdftotext (25.01.0) - Firefox PDF Viewer (135.0)
The only one that worked for me was the viewer in the chrome browser. /Mikael

Am Sun, 16 Feb 2025 04:04:11 +0100 schrieb Gerion Entrup:
Thanks for the answer. I researched this for my default PDF-viewer, Okular from KDE, and this program seems to be really special in this regard. It should be actively responsible for the behavior described in my original mail. See https://bugs.kde.org/show_bug.cgi?id=447094#c5 and https://bugs.kde.org/show_bug.cgi?id=233604.
Well 14 years old bug reports are not really good references. In any case: at least the second bug report is not relevant, the attached PDF uses a hard hyphen 002D and not a soft hyphen 00AD as context (correctly) does. I don't know what typst does (you didn't attach an example pdf) but if they use ActualText I wouldn't recommend to copy that. Support for ActualText is worse than support for soft hyphen (and I had even examples where words or sylables got lost in copy & paste if ActualText was involved). -- Ulrike Fischer http://www.troubleshooting-tex.de/
participants (5)
-
Gerion Entrup
-
Hans Hagen
-
Marco Patzer
-
Mikael Sundqvist
-
Ulrike Fischer