mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-28 04:54:13 +02:00
Add PDF page import to the scripting API
qet.addPdfPage() renders one page of a PDF file to an image and places it, through the same QPdfDocument::render() call, white- background compositing (a transparent page would otherwise show whatever is under it, unlike every other placed image) and DiagramImageItem/AddGraphicsObjectCommand underneath as the "add PDF" toolbar action's own file/page-selection dialogs. Only reachable in a build with the QtPdf module (Qt >= 6.4) -- some Qt6 distributions omit it entirely (see diagrameventaddpdf.h). The method is still always declared and compiled, guarded internally instead of with the class itself: a script asking whether qet.addPdfPage exists must never get "not a function" for a reason it has no way to discover. Refuses with a clear reason when the module is missing, the page number is out of range, the file cannot be loaded, or the resulting render is degenerate. Verified against a real 2-page PDF (this session installed qt6-pdf-dev, which was missing here) that the two rendered pages differ in content and that dpi scales the rendered pixel size linearly, not just that the call returns something. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -499,6 +499,8 @@ class QetScriptApi : public QObject
|
||||
Q_INVOKABLE bool setImageScale(int folioIndex, int imageIndex, double factor);
|
||||
Q_INVOKABLE bool setImageRotation(int folioIndex, int imageIndex, double angle);
|
||||
Q_INVOKABLE bool deleteImage(int folioIndex, int imageIndex);
|
||||
Q_INVOKABLE int addPdfPage(int folioIndex, const QString &pdfPath, int pageNumber,
|
||||
int dpi, double x, double y);
|
||||
|
||||
// -- the text fields shown on a symbol (label, terminal names, ...) --
|
||||
Q_INVOKABLE QStringList elementTexts(int folioIndex, const QString &elementUuid) const;
|
||||
|
||||
Reference in New Issue
Block a user