Topic: Frage zu PDF-Export mit Links

Hallo zusammen,

ich habe einen bestehenden Schaltplan, den ich gerne als PDF mit verlinkten Verweisen vorliegen hätte.

Bei dem Plan kommt zwar eine PDF mit Links heraus, die Links verweisen aber nicht mit relativen Links auf Seite xy innerhalb des PDF, sondern enthalten einen kompletten Internet-Link:

file:///kompletter/Pfad/zur/Datei/und/dateiname.pdf#page=3&fitr=57_257_171_371

Damit können all meine PDF-Betrachter nichts anfangen und entsprechend funktionieren die Links nicht.
Auch wenn die Links dort funktionierten, ginge es schief, wenn die PDF-Datei umbenannt oder verschoben wird.

Die QET-Datei kann ich hier leider nicht posten, deswegen die Fragen:
- Welche Voraussetzungen müsen gegeben sein, dass die Links im PDF-Export funktionieren?
- Kann ich mit wenig Aufwand den bestehenden Plan modifizieren, damit die Links funktionieren?

Gruß
  plc-user

PS: Eine neu erstellte Datei mit Verknüpfungen funktioniert auch als PDF-Export.

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

2 (edited by plc-user 2026-08-22 15:21:03)

Re: Frage zu PDF-Export mit Links

[EDITED]

Ich war der Hoffnung, dass auch Beiträge auf Deutsch vom Ersteller der Funktion gelesen werden, das scheint aber wohl nicht der Fall zu sein – schade!

Deswegen versuche ich es noch einmal auf Englisch...



I was hoping that the creator of these features would also read posts in German, but that doesn't seem to be the case — too bad!

So next try in English...


PS:
Danke für den Hinweis, Kellermorph  nomicons/angel

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

Hello everyone,

I have an existing schematic that I’d like to save as a PDF with hyperlinks.

Although the schematic does generate a PDF with links, the links do not use relative links to page xy within the PDF; instead, they contain a full web link:

file:///complete/path/to/file/and/filename.pdf#page=3&fitr=57_257_171_371

None of my PDF viewers can handle this format, so the links don’t work.
Even if the links did work there, they would break if the PDF file were renamed or moved.

Unfortunately, I can’t post the QET file here, which is why I’m asking:
- What requirements must be met for the links in the PDF export to work?
- Can I modify the existing plan with minimal effort so that the links work?

Best regards,
  plc-user

P.S.: A newly created file with links also works as a PDF export.

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

plc-user wrote:

Ich war der Hoffnung, dass der deutschsprachige Ersteller der Funktionen die Frage beantworten könne, das scheint aber wohl nicht der Fall zu sein – schade!

Deswegen versuche ich es noch einmal auf Englisch...



I was hoping that the German-speaking creator of the features could answer this question, but that doesn’t seem to be the case — too bad!

So next try in English...

Die Querverweisfunktion war doch von Laurent erstellt? Das war doch kein deutschsprachiger? Oder vertue ich mich da gerade?

Re: Frage zu PDF-Export mit Links

Hallo plc-user,

kurze Klarstellung: Die Querverweis-Hyperlinks im PDF-Export stammen nicht von mir, sondern von ispyisail (PR #490, schließt Issue #417 „Internal links in PDF export"). Danke an ihn dafür!

Zum eigentlichen Problem: Die internen Links werden in zwei Schritten erzeugt. Zuerst wird für jeden Querverweis ein file://...#page=N-Link geschrieben, danach wandelt eine Nachbearbeitung diese file://-URIs direkt in den PDF-Bytes in interne /GoTo-Sprungziele um. Wenn das klappt, sieht man am Ende gar keine file://-Links mehr.

Dass es bei einem neuen Testfile funktioniert, beim bestehenden Plan aber nicht, deutet auf einen Sonderfall in dieser Nachbearbeitung hin: Sie sucht im PDF nach der ersten Fundstelle von /Type /Pages, um die Seitenliste zu finden. Enthält der bestehende Plan eingebettete Bilder (Logo im Schriftfeld, Hintergrundbild o.ä.), könnte deren Binärinhalt zufällig diese Zeichenfolge enthalten und die Erkennung durcheinanderbringen — die Umwandlung würde dann still übersprungen, und die ursprünglichen file://-Links blieben stehen.

Um das einzugrenzen, ohne dass du die Datei posten musst:

Enthält dein Plan eingebettete Bilder (Logo, Hintergrund, Bild in einem Textfeld/Schriftfeld)?
Testweise: Plan duplizieren, alle eingebetteten Bilder entfernen, erneut als PDF exportieren — funktionieren die Links dann?
Wie viele Seiten/Pläne hat das Projekt ungefähr?
Falls sich das bestätigt, ist das ein echter Bug in der Nachbearbeitung, den wir fixen sollten.

Gruß

English:

Hallo plc-user

Quick correction: the cross-reference hyperlinks in the PDF export weren't written by me — that's ispyisail's work (PR #490, closing issue #417 "Internal links in PDF export"). Credit where it's due!

On the actual issue: internal links are produced in two steps. First, each cross-reference gets a file://...#page=N link written out; then a post-processing pass rewrites those file:// URIs directly in the PDF bytes into internal /GoTo destinations. When that succeeds, you shouldn't see any file:// links in the final PDF at all.

The fact that it works on a fresh test file but not on your existing plan points to an edge case in that post-processing step: it locates the page list by searching for the first occurrence of /Type /Pages in the raw PDF bytes. If your existing plan has embedded images (a logo in the title block, a background image, etc.), their binary content could accidentally contain that same byte sequence and throw off the detection — the conversion would then silently be skipped, leaving the original file:// links in place.

To help narrow this down without needing the file itself:

Does your plan contain any embedded images (logo, background, image in a text/title field)?
Quick test: duplicate the plan, remove any embedded images, re-export to PDF — do the links become internal then?
Roughly how many pages/folios does the project have?
If that's confirmed, it's a real bug in the post-processing step that should get fixed.

Best regards,
Laurent

@kellermorph no I don't speak german.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

Halko plc-user,

That points to a genuine bug rather than a version mismatch — likely in the post-processing step that converts the file:// links into internal /GoTo destinations.

That step locates the PDF's page tree by searching for the first occurrence of /Type /Pages in the raw file. If your existing plan has an embedded image (a logo in the title block, a background image, etc. — something a fresh test file wouldn't have), its binary content could accidentally contain that same byte sequence earlier in the file, throwing off the detection and silently leaving the original file:// links untouched.

I've put together a patch that makes this detection more robust (it now checks every occurrence and keeps the one whose /Kids array actually resolves to the most pages, rather than trusting the first match): 0001-pdf_links-robust-page-tree-detection.patch (attached).

Would you be able to build with this patch applied and re-export your plan, to see if the links become internal? You shouldn't need to share the file for that — just the pass/fail result. If you can also confirm whether your plan has embedded images and roughly how many pages it has, that'll help confirm the diagnosis either way.

Thanks for your patience with this one!

Laurent

Post's attachments

Attachment icon 0001-pdf_links-robust-page-tree-detection.patch 2.63 kb, 13 downloads since 2026-08-23 

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

History
https://github.com/qelectrotech/qelectr … c79f080262
https://github.com/search?q=repo%3Aqele … pe=commits

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

Small correction to my own correction: I looked more closely at the commit history — Kellermorph was right, the original hyperlink feature in the PDF export is indeed mine (commit cd76b6a, end of May). What I mixed up was a later contribution from ispyisail that exposed the same feature through the CLI export path. Several people have worked on it since — including, small irony, you yourself, with a compiler-warning fix in that very codebase. nomicons/wink

Back to the actual issue, my patch suggestion above still stands — would appreciate it if you could give it a try.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

Salut Laurent !

Indeed there are some embedded pictures in my plan!
But even when removing them the links in PDF stay the same as before.  nomicons/sad

I'll try to compile with your patch from above and keep you informed!

For this point so far: Thanks!

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

10 (edited by plc-user 2026-08-23 18:57:26)

Re: Frage zu PDF-Export mit Links

Salut Laurent !

It took a while, but I finally figured it out! nomicons/smile

It's the name of the QET file that's causing the error!
If the file name contains an opening and closing bracket, the PDF links are inserted as Internet links instead of internal links!

filename that works.qet
filename that does (not) work.qet

Your patch from above definitely makes perfect sense but does not help with brackets in the filename...

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

nomicons/smile
I’m old-school when it comes to Linux – I never use spaces in file or directory names, let alone square brackets, or brackets...On Linux and Windows..

filename that does (not) work.qet -> filename_that_does-not-work.qet

It was a bad experience I had back in 2000 with Windows files being read on Linux that has stuck in my mind…

Exemples on my personal wiki on my NAS:

Fichier transféré d'une partition Windows sur une partition UTF-8 ext3:

convmv -f cp1252 -t utf-8 -r --notest <fichier_a_convertir>

Fichier extrait d'une archive:

convmv -f iso-8859-1 -t utf-8 -r --notest <fichier_a_convertir>

Exemples:

enlever espaces dans noms de fichier

for i in *; do mv "$i" "$(echo $i | tr " " "-")"; done

supprimer les majuscules

for i in *; do mv "$i" "$(echo $i | tr A-Z a-z)"; done
for i in *; do mv "$i" `echo $i | tr [:upper:] [:lower:]

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

I’m glad I was able to help you – even though the answer was well hidden in the file name, you managed to find it in the end. Well done!

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

I don't think the problem is solved!
The links are generated when the PDF file is created by QET.
Why does QET care about the file name if all links point to a destination within the same PDF file?
The QET-filename shouldn’t matter then!

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

I would say that we must also take care to restrict the filename of PDF files and not accept just anything, as this could in fact leave us vulnerable to an attack.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

15 (edited by plc-user 2026-08-24 18:45:03)

Re: Frage zu PDF-Export mit Links

I don't like restrictions!

Please try my fix in https://github.com/qelectrotech/qelectr … r/pull/784

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Frage zu PDF-Export mit Links

Merged!

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !