<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[QElectroTech — Python script for generate cross-references in .pdf file]]></title>
		<link>https://qelectrotech.org/forum/viewtopic.php?id=2982</link>
		<atom:link href="https://qelectrotech.org/forum/extern.php?action=feed&amp;tid=2982&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Python script for generate cross-references in .pdf file.]]></description>
		<lastBuildDate>Fri, 29 May 2026 08:11:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22939#p22939</link>
			<description><![CDATA[<p> **Native PDF hyperlinks for cross-references – Feature Request**</p><p>Currently, QElectroTech exports PDF files using Qt&#039;s `QPrinter`/`QPainter`, which renders content flat — text and shapes are drawn correctly, but there is no support for embedded hyperlink annotations in the PDF output.</p><p>This is why the workaround Python script (using PyMuPDF/fitz) was created: it post-processes the exported PDF to detect cross-reference labels, calculate target page positions, and inject clickable link annotations (`/Annots`) into the PDF.</p><p>It would be great to have this functionality built directly into QET&#039;s PDF export.</p><p>**Why Qt5 is a dead end**</p><p>Qt5 has reached its end of life. No security patches, no bug fixes unless they also affect Qt6. Linux distributions are already phasing it out. The migration to Qt6 is not optional — it is a matter of survival for the project. Any energy invested in patching the PDF export on Qt5 is wasted effort.</p><p>**What Qt6 brings — and what it still doesn&#039;t**</p><p>Despite ongoing improvements to `QPdfWriter` across Qt6 releases (ColorModel, CMYK, OutputIntent...), there is still no official public API for writing link annotations (`/Annots`) as of Qt 6.11. This limitation has actually been tracked since 2015 (QTBUG-44563) with no resolution to date.</p><p>However, Qt&#039;s internal PDF engine does have a private method — `QPdfEngine::drawHyperlink(QRect, QUrl)` — that can write link annotations. It is accessible (unofficially) by casting the paint engine:</p><p>```cpp<br />dynamic_cast&lt;QPdfEngine*&gt;(painter.paintEngine())-&gt;drawHyperlink(rect, url);<br />```</p><p>This requires including the private header `qpdf_p.h` and is not part of the public API, so it could break between Qt versions. But it proves the underlying engine already supports it — it just isn&#039;t exposed.</p><p>**The right approach**</p><p>There are three realistic paths for QET:</p><p>1. **Use `QPdfEngine::drawHyperlink` (private API)** — works today, no external dependency, but fragile across Qt version updates.<br />2. **Port the Python post-processing to C++** — using a library such as libmupdf or QPDF to inject `/Annots` after export, same logic as Alfonso&#039;s script but integrated natively.<br />3. **Wait for Qt to expose this officially** — unlikely in the short term given QTBUG-44563 has been open for 10 years.</p><p>The Qt6 migration is the right moment to tackle this. The PDF export code will be touched anyway, and option 1 could be a pragmatic first step while option 2 is planned as a more robust long-term solution.</p><p>Thanks to Alfonso and the community for the Python workaround — it proves the concept and shows this is a real user need. </p>]]></description>
			<author><![CDATA[null@example.com (scorpio810)]]></author>
			<pubDate>Fri, 29 May 2026 08:11:04 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22939#p22939</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22936#p22936</link>
			<description><![CDATA[<p> @Alfonso, thanks for your compliments. <img src="https://qelectrotech.org/forum/img/smilies/nomicons/wink.png" width="20" alt="nomicons/wink" /> </p>]]></description>
			<author><![CDATA[null@example.com (scorpio810)]]></author>
			<pubDate>Thu, 28 May 2026 14:16:46 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22936#p22936</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22933#p22933</link>
			<description><![CDATA[<p> That would be brilliant, Laurent!</p><p>I can see that, between you all, you’re making the programme progress by leaps and bounds! It’s fantastic!</p><p>For example, at the company where I work, we’re developing a Python programme that uses .qetmak files to automatically generate a complete drawing. We’ve seen that it’s entirely feasible based on the tests we’ve run, but we’ve still got a lot of work ahead of us creating the .qetmak files to a specific standard, and we’re looking into how to maintain the link between elements with the same name, as they currently depend on their ‘uuid’, which is currently generated randomly and therefore changes from project to project.<br />The idea for the future is that, using AI to help understand client requirements, a code containing the schematic’s characteristics will be generated, and using this code and the Python programme, we will obtain a .qet file ready for minor adjustments.<br />Of course, we’ll share the solution once it’s more fully developed; although it might not be suitable for everyone, it could be useful for some people.</p><p>Thanks to Kellermorph for implementing .qetmak and other features!<br />I’d love to contribute code directly rather than Python applications, but we don’t have enough programming knowledge and much time to acquire it. </p>]]></description>
			<author><![CDATA[null@example.com (Alfonso)]]></author>
			<pubDate>Thu, 28 May 2026 06:55:38 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22933#p22933</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22931#p22931</link>
			<description><![CDATA[<p> Thanks for the info, Laurent.<br />Then we can go ahead and implement that.<br />As soon as QET has been upgraded to QT6, I was planning to start working on adding direct PDF import instead of just an image. </p>]]></description>
			<author><![CDATA[null@example.com (Kellermorph)]]></author>
			<pubDate>Wed, 27 May 2026 18:21:16 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22931#p22931</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22928#p22928</link>
			<description><![CDATA[<p> Native PDF hyperlinks for cross-references – Feature Request</p><p>Currently, QElectroTech exports PDF files using Qt&#039;s QPrinter/QPainter, which renders content &quot;flat&quot; — text and shapes are drawn correctly, but there is no support for embedded hyperlink annotations in the PDF output.</p><p>This is why the workaround Python script (using PyMuPDF/fitz) was created: it post-processes the exported PDF to detect cross-reference labels, calculate target page positions, and inject clickable link annotations (/Annots) into the PDF.</p><p>It would be great to have this functionality built directly into QET&#039;s PDF export.</p><p>Why Qt6 is now the only way forward</p><p>Qt5 reached its end of life and is no longer receiving updates. This migration is not optional — it is a matter of long-term maintainability and security for QET. But beyond that, Qt6 also brings the technical solution to this very problem.</p><p>Qt5 was fundamentally limited to &quot;painting&quot; content onto PDF pages with no awareness of the document structure. There was no supported way to embed hyperlink annotations natively — hence the need for external post-processing tools like the Python script.</p><p>Qt6 introduced the QtPdf module, which works with PDF documents at a structural level rather than just drawing pixels. Starting from Qt 6.4, this module exposes proper PDF navigation and document structure capabilities, and the writing side is actively being extended. This makes it technically feasible to embed internal page-to-page hyperlinks (/Annots) directly at export time — no external library, no post-processing step, no Python script needed.</p><p>In short: the end of Qt5 support is already decided. The migration to Qt6 is inevitable. And Qt6 happens to bring exactly the PDF capabilities needed to implement native cross-reference links properly. This is the right moment to plan this feature as part of the Qt6 migration effort, rather than treating it as a separate task later.</p><p>Thanks to Alfonso and the community for the Python workaround in the meantime — it proves the concept works and that users genuinely need this feature! </p>]]></description>
			<author><![CDATA[null@example.com (scorpio810)]]></author>
			<pubDate>Wed, 27 May 2026 16:39:52 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22928#p22928</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22690#p22690</link>
			<description><![CDATA[<p> Hello everyone,</p><p>I’ve continued developing the script.<br />To do this, I’ve configured and programmed a wide variety of settings from QET.<br />Could you please test it and give me some feedback? There might still be some errors, for example because the page size is significantly different and the scaling isn’t quite right yet, or something like that.</p><p>Features that aren’t included yet:<br />Position of the cross-reference for the slave component: text alignment. I’m not exactly sure how this works yet. Can someone tell me?<br />Also, the component information isn’t available in languages other than German and English yet.</p><p>As soon as the script runs without errors, I&#039;ll adapt it for the command line</p><p>Translated with DeepL.com (free version) </p>]]></description>
			<author><![CDATA[null@example.com (Kellermorph)]]></author>
			<pubDate>Fri, 13 Mar 2026 19:17:57 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22690#p22690</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22644#p22644</link>
			<description><![CDATA[<p> Could someone give me all the translations for the component information? I think they are already in the Code? Then i could add them in my tool </p>]]></description>
			<author><![CDATA[null@example.com (Kellermorph)]]></author>
			<pubDate>Wed, 04 Mar 2026 06:26:31 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22644#p22644</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22626#p22626</link>
			<description><![CDATA[<p> Thanks for testing and reporting back. I&#039;ll look into where the problem lies, fix it, and upload an update.</p><p>would it be possible, that u give me .qet to test it? I have tried with a single page with 2-1 and it works. </p>]]></description>
			<author><![CDATA[null@example.com (Kellermorph)]]></author>
			<pubDate>Fri, 27 Feb 2026 10:21:12 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22626#p22626</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22625#p22625</link>
			<description><![CDATA[<p> WOW, great work Thomas, but for the latest documentation of a project I&#039;m currently working on with very customised folio orders, the programme you wrote crashes. I suspected as much beforehand, but for other less exotic projects, the programme works very well.</p><p><span class="postimg"><img src="https://download.qelectrotech.org/qet/forum_img_2/Thomas_qet_linker.py_crashe_with%20personal%20page_numbering.png" alt="https://download.qelectrotech.org/qet/forum_img_2/Thomas_qet_linker.py_crashe_with%20personal%20page_numbering.png" /></span> </p>]]></description>
			<author><![CDATA[null@example.com (scorpio810)]]></author>
			<pubDate>Fri, 27 Feb 2026 08:18:41 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22625#p22625</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22624#p22624</link>
			<description><![CDATA[<p> Thank you.</p><p>I think this should be possible. <br />i can take a look.</p><p>But that this works, i have to enter the different Settings from QET. This will take a bit of time. If u want, i can do that </p>]]></description>
			<author><![CDATA[null@example.com (Kellermorph)]]></author>
			<pubDate>Thu, 26 Feb 2026 21:45:24 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22624#p22624</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22623#p22623</link>
			<description><![CDATA[<p> WOW <br />Unbelievable!!! Just one question: is it possible to use it only in command line? If so, QElectroTech could simply use it in post-processing a PDF export without the user even noticing. That would be a HUGE plus for QElectroTech. Well done for your work. </p>]]></description>
			<author><![CDATA[null@example.com (Joshua)]]></author>
			<pubDate>Thu, 26 Feb 2026 20:32:16 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22623#p22623</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22622#p22622</link>
			<description><![CDATA[<p> I have attached everything.<br />I deleted many pages from a previous project. So don&#039;t be surprised that the plan doesn&#039;t make much sense as it stands. </p>]]></description>
			<author><![CDATA[null@example.com (Kellermorph)]]></author>
			<pubDate>Thu, 26 Feb 2026 12:08:41 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22622#p22622</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22621#p22621</link>
			<description><![CDATA[<p> Hello Thomas, please share an example and an video, thanks.<br />B.R Laurent </p>]]></description>
			<author><![CDATA[null@example.com (scorpio810)]]></author>
			<pubDate>Thu, 26 Feb 2026 10:43:42 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22621#p22621</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=22620#p22620</link>
			<description><![CDATA[<p> </p><div class="quotebox"><cite>scorpio810 wrote:</cite><blockquote><p>A workaround it&#039;s to program code that use PDF like yours python program and also read the .qet XML, also you didn&#039;t need to enter rows, columns counts, size, and maybe with the folio label found page position.</p><p>You neeed two file, PDF of your project and the project.qet, I think!</p></blockquote></div><p>I have implemented your idea.<br />The script is attached.</p><p>Currently, German and English are supported.<br />The settings currently supported in QET are:</p><p>Text alignment for slave elements: Top, Right, Bottom, Left<br />Settings for the master: Position below the master and display as contacts. </p><p>This means that the options for displaying as a table and showing the contacts at the bottom of the slide are still missing. I don&#039;t use these settings either.<br />For Commutator must be used slave elements which are marked with other</p><p>I have implemented an additional function:<br />You can also enter component information, such as manufacturer, function, etc.<br />To do this, an info box is placed on the upper left contact of the element. This allows you to see directly which component it is and you don&#039;t have to go to the component directory. Since I use the variables for my tool with the terminal diagram differently than their labeling, I have included the option to exclude any components of the terminal type for the info boxes.</p><p>Translated with DeepL.com (free version) </p>]]></description>
			<author><![CDATA[null@example.com (Kellermorph)]]></author>
			<pubDate>Thu, 26 Feb 2026 06:51:48 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=22620#p22620</guid>
		</item>
		<item>
			<title><![CDATA[Re: Python script for generate cross-references in .pdf file]]></title>
			<link>https://qelectrotech.org/forum/viewtopic.php?pid=21888#p21888</link>
			<description><![CDATA[<p> Hello scorpio810 and Kellermorph!</p><p>Thank you for moving forward with this kind of tools that greatly improve our diagrams!</p><p>As you know, my program reads the page+coordinate, and creates a link on the corresponding page of the PDF file with the row/column coordinate.</p><p>If the formatting is not correct, or the pages are not consecutive, there will be problems with the references in my program.<br />The tool adapts to our schema creation rules (use of row and column, use consecutive pages, etc.). We are trying to make it more universal by adding the most common cross-reference formats, but it will never be to the liking of all users.</p><p>Probably we can make a tool that reads the links directly from .qet, but we don&#039;t have the time to develop it right now.</p><p>This is why, the best thing would be to include this functionality directly in QET built-in PDF export tool. </p>]]></description>
			<author><![CDATA[null@example.com (Alfonso)]]></author>
			<pubDate>Tue, 15 Jul 2025 06:58:08 +0000</pubDate>
			<guid>https://qelectrotech.org/forum/viewtopic.php?pid=21888#p21888</guid>
		</item>
	</channel>
</rss>
