diff --git a/CodeGenerator/codegenerator.cpp b/CodeGenerator/codegenerator.cpp index d11f796..79ad7aa 100644 --- a/CodeGenerator/codegenerator.cpp +++ b/CodeGenerator/codegenerator.cpp @@ -40,6 +40,14 @@ QObjectList GeneratedCodeStorage::getFunctions() const void GeneratedCodeStorage::setFunctions(const QObjectList& functions) { m_functions = functions; + + auto comparator = [](const QObject* left, const QObject* right) + { + const GeneratedFunction* leftFunction = qobject_cast(left); + const GeneratedFunction* rightFunction = qobject_cast(right); + return leftFunction->getFunctionName() < rightFunction->getFunctionName(); + }; + std::sort(m_functions.begin(), m_functions.end(), comparator); } GeneratedFunction* GeneratedCodeStorage::addFunction(const QString& name) diff --git a/CodeGenerator/codegenerator.h b/CodeGenerator/codegenerator.h index 78ce5ab..d5aed03 100644 --- a/CodeGenerator/codegenerator.h +++ b/CodeGenerator/codegenerator.h @@ -145,7 +145,8 @@ public: _QRectF, _QColor, _QVariant, - _TextAnnotationIcon + _TextAnnotationIcon, + _LinkHighlightMode }; Q_ENUM(DataType) @@ -352,7 +353,8 @@ public: { Structure, Annotations, - ColorSpace + ColorSpace, + Actions }; Q_ENUM(FunctionType) diff --git a/PdfExampleGenerator/pdfexamplesgenerator.cpp b/PdfExampleGenerator/pdfexamplesgenerator.cpp index bfc1eb5..903dd07 100644 --- a/PdfExampleGenerator/pdfexamplesgenerator.cpp +++ b/PdfExampleGenerator/pdfexamplesgenerator.cpp @@ -40,6 +40,12 @@ void PDFExamplesGenerator::generateAnnotationsExample() builder.createAnnotationText(page1, QRectF(250, 300, 24, 24), pdf::TextAnnotationIcon::Note, "Title1", "Subject1", "Note", true); builder.createAnnotationText(page1, QRectF(250, 350, 24, 24), pdf::TextAnnotationIcon::Paragraph, "Title1", "Subject1", "Paragraph", true); + pdf::PDFObjectReference page2 = builder.appendPage(QRectF(0, 0, 400, 400)); + builder.createAnnotationLink(page2, QRectF(50, 50, 200, 50), "www.seznam.cz", pdf::LinkHighlightMode::Invert); + builder.createAnnotationLink(page2, QRectF(50, 150, 200, 50), "www.seznam.cz", pdf::LinkHighlightMode::None); + builder.createAnnotationLink(page2, QRectF(50, 250, 200, 50), "www.seznam.cz", pdf::LinkHighlightMode::Outline); + builder.createAnnotationLink(page2, QRectF(50, 350, 200, 50), "www.seznam.cz", pdf::LinkHighlightMode::Push); + pdf::PDFObjectReference page5 = builder.appendPage(QRectF(0, 0, 400, 400)); builder.createAnnotationSquare(page5, QRectF(50, 50, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary"); builder.createAnnotationSquare(page5, QRectF(50, 150, 50, 50), 3.0, QColor(), Qt::red, "Title2", "Subject2", "Contents - red boundary"); diff --git a/PdfForQtLib/sources/pdfannotation.cpp b/PdfForQtLib/sources/pdfannotation.cpp index 63c7f6a..e47b14c 100644 --- a/PdfForQtLib/sources/pdfannotation.cpp +++ b/PdfForQtLib/sources/pdfannotation.cpp @@ -197,14 +197,14 @@ PDFAnnotationPtr PDFAnnotation::parse(const PDFDocument* document, PDFObject obj } linkAnnotation->m_previousAction = PDFAction::parse(document, dictionary->get("PA")); - constexpr const std::array, 4> highlightMode = { - std::pair{ "N", PDFLinkAnnotation::HighlightMode::None }, - std::pair{ "I", PDFLinkAnnotation::HighlightMode::Invert }, - std::pair{ "O", PDFLinkAnnotation::HighlightMode::Outline }, - std::pair{ "P", PDFLinkAnnotation::HighlightMode::Push } + constexpr const std::array, 4> highlightMode = { + std::pair{ "N", LinkHighlightMode::None }, + std::pair{ "I", LinkHighlightMode::Invert }, + std::pair{ "O", LinkHighlightMode::Outline }, + std::pair{ "P", LinkHighlightMode::Push } }; - linkAnnotation->m_highlightMode = loader.readEnumByName(dictionary->get("H"), highlightMode.begin(), highlightMode.end(), PDFLinkAnnotation::HighlightMode::Invert); + linkAnnotation->m_highlightMode = loader.readEnumByName(dictionary->get("H"), highlightMode.begin(), highlightMode.end(), LinkHighlightMode::Invert); linkAnnotation->m_activationRegion = parseQuadrilaterals(document, dictionary->get("QuadPoints"), annotationsRectangle); } else if (subtype == "FreeText") diff --git a/PdfForQtLib/sources/pdfannotation.h b/PdfForQtLib/sources/pdfannotation.h index 8211cab..af91e13 100644 --- a/PdfForQtLib/sources/pdfannotation.h +++ b/PdfForQtLib/sources/pdfannotation.h @@ -545,6 +545,14 @@ private: QString m_stateModel; }; +enum class LinkHighlightMode +{ + None, + Invert, + Outline, + Push +}; + /// Link annotation represents hypertext link to a destination to elsewhere /// in the document, or action to be performed. class PDFLinkAnnotation : public PDFAnnotation @@ -554,16 +562,8 @@ public: virtual AnnotationType getType() const override { return AnnotationType::Link; } - enum class HighlightMode - { - None, - Invert, - Outline, - Push - }; - const PDFAction* getAction() const { return m_action.data(); } - HighlightMode getHighlightMode() const { return m_highlightMode; } + LinkHighlightMode getHighlightMode() const { return m_highlightMode; } const PDFAction* getURIAction() const { return m_previousAction.data(); } const PDFAnnotationQuadrilaterals& getActivationRegion() const { return m_activationRegion; } @@ -571,7 +571,7 @@ private: friend static PDFAnnotationPtr PDFAnnotation::parse(const PDFDocument* document, PDFObject object); PDFActionPtr m_action; - HighlightMode m_highlightMode = HighlightMode::Invert; + LinkHighlightMode m_highlightMode = LinkHighlightMode::Invert; PDFActionPtr m_previousAction; PDFAnnotationQuadrilaterals m_activationRegion; }; diff --git a/PdfForQtLib/sources/pdfdocumentbuilder.cpp b/PdfForQtLib/sources/pdfdocumentbuilder.cpp index f67b83f..23c01c6 100644 --- a/PdfForQtLib/sources/pdfdocumentbuilder.cpp +++ b/PdfForQtLib/sources/pdfdocumentbuilder.cpp @@ -64,6 +64,42 @@ void PDFObjectFactory::endDictionaryItem() std::get(dictionaryItem.object).addEntry(qMove(topItem.itemName), qMove(std::get(topItem.object))); } +PDFObjectFactory& PDFObjectFactory::operator<<(LinkHighlightMode mode) +{ + switch (mode) + { + case LinkHighlightMode::None: + { + *this << WrapName("N"); + break; + } + + case LinkHighlightMode::Invert: + { + *this << WrapName("I"); + break; + } + + case LinkHighlightMode::Outline: + { + *this << WrapName("O"); + break; + } + + case LinkHighlightMode::Push: + { + *this << WrapName("P"); + break; + } + + default: + Q_ASSERT(false); + break; + } + + return *this; +} + PDFObjectFactory& PDFObjectFactory::operator<<(TextAnnotationIcon icon) { switch (icon) @@ -374,7 +410,59 @@ PDFInteger PDFDocumentBuilder::getPageTreeRootChildCount() const /* START GENERATED CODE */ -PDFObjectReference PDFDocumentBuilder::createAnnotationSquare(PDFObjectReference page, +PDFObjectReference PDFDocumentBuilder::appendPage(QRectF mediaBox) +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Page"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Parent"); + objectBuilder << getPageTreeRoot(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionary(); + objectBuilder.endDictionary(); + objectBuilder.beginDictionaryItem("MediaBox"); + objectBuilder << mediaBox; + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObjectReference pageReference = addObject(objectBuilder.takeObject()); + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Kids"); + objectBuilder << std::initializer_list{ pageReference }; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Count"); + objectBuilder << getPageTreeRootChildCount() + 1; + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObject updatedTreeRoot = objectBuilder.takeObject(); + appendTo(getPageTreeRoot(), updatedTreeRoot); + return pageReference; +} + + +PDFObjectReference PDFDocumentBuilder::createActionURI(QString URL) +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Action"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("S"); + objectBuilder << WrapName("URI"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("URI"); + objectBuilder << URL; + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObjectReference actionReference = addObject(objectBuilder.takeObject()); + return actionReference; +} + + +PDFObjectReference PDFDocumentBuilder::createAnnotationCircle(PDFObjectReference page, QRectF rectangle, PDFReal borderWidth, QColor fillColor, @@ -386,8 +474,11 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationSquare(PDFObjectReference PDFObjectFactory objectBuilder; objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Annot"); + objectBuilder.endDictionaryItem(); objectBuilder.beginDictionaryItem("Subtype"); - objectBuilder << WrapName("Square"); + objectBuilder << WrapName("Circle"); objectBuilder.endDictionaryItem(); objectBuilder.beginDictionaryItem("Rect"); objectBuilder << rectangle; @@ -447,6 +538,58 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationSquare(PDFObjectReference } +PDFObjectReference PDFDocumentBuilder::createAnnotationLink(PDFObjectReference page, + QRectF linkRectangle, + PDFObjectReference action, + LinkHighlightMode highlightMode) +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Annot"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Subtype"); + objectBuilder << WrapName("Link"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("P"); + objectBuilder << page; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Rect"); + objectBuilder << linkRectangle; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("A"); + objectBuilder << action; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("H"); + objectBuilder << highlightMode; + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObjectReference annotationReference = addObject(objectBuilder.takeObject()); + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Annots"); + objectBuilder.beginArray(); + objectBuilder << annotationReference; + objectBuilder.endArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObject pageAnnots = objectBuilder.takeObject(); + appendTo(page, pageAnnots); + return annotationReference; +} + + +PDFObjectReference PDFDocumentBuilder::createAnnotationLink(PDFObjectReference page, + QRectF linkRectangle, + QString URL, + LinkHighlightMode highlightMode) +{ + PDFObjectFactory objectBuilder; + + return createAnnotationLink(page, linkRectangle, createActionURI(URL), highlightMode); +} + + PDFObjectReference PDFDocumentBuilder::createAnnotationPopup(PDFObjectReference page, PDFObjectReference parentAnnotation, QRectF rectangle, @@ -455,6 +598,9 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationPopup(PDFObjectReference PDFObjectFactory objectBuilder; objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Annot"); + objectBuilder.endDictionaryItem(); objectBuilder.beginDictionaryItem("Subtype"); objectBuilder << WrapName("Popup"); objectBuilder.endDictionaryItem(); @@ -476,130 +622,7 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationPopup(PDFObjectReference } -PDFObjectReference PDFDocumentBuilder::createCatalog() -{ - PDFObjectFactory objectBuilder; - - objectBuilder.beginDictionary(); - objectBuilder.beginDictionaryItem("Type"); - objectBuilder << WrapName("Catalog"); - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("Pages"); - objectBuilder << createCatalogPageTreeRoot(); - objectBuilder.endDictionaryItem(); - objectBuilder.endDictionary(); - PDFObjectReference catalogReference = addObject(objectBuilder.takeObject()); - return catalogReference; -} - - -PDFObject PDFDocumentBuilder::createTrailerDictionary(PDFObjectReference catalog) -{ - PDFObjectFactory objectBuilder; - - objectBuilder.beginDictionary(); - objectBuilder.beginDictionaryItem("Size"); - objectBuilder << 1; - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("Root"); - objectBuilder << catalog; - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("Info"); - objectBuilder.beginDictionary(); - objectBuilder.beginDictionaryItem("Producer"); - objectBuilder << getProducerString(); - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("CreationDate"); - objectBuilder << WrapCurrentDateTime(); - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("ModDate"); - objectBuilder << WrapCurrentDateTime(); - objectBuilder.endDictionaryItem(); - objectBuilder.endDictionary(); - objectBuilder.endDictionaryItem(); - objectBuilder.endDictionary(); - PDFObject trailerDictionary = objectBuilder.takeObject(); - return trailerDictionary; -} - - -void PDFDocumentBuilder::updateTrailerDictionary(PDFInteger objectCount) -{ - PDFObjectFactory objectBuilder; - - objectBuilder.beginDictionary(); - objectBuilder.beginDictionaryItem("Size"); - objectBuilder << objectCount; - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("Info"); - objectBuilder.beginDictionary(); - objectBuilder.beginDictionaryItem("Producer"); - objectBuilder << getProducerString(); - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("ModDate"); - objectBuilder << WrapCurrentDateTime(); - objectBuilder.endDictionaryItem(); - objectBuilder.endDictionary(); - objectBuilder.endDictionaryItem(); - objectBuilder.endDictionary(); - PDFObject trailerDictionary = objectBuilder.takeObject(); - m_storage.updateTrailerDictionary(qMove(trailerDictionary)); -} - - -PDFObjectReference PDFDocumentBuilder::appendPage(QRectF mediaBox) -{ - PDFObjectFactory objectBuilder; - - objectBuilder.beginDictionary(); - objectBuilder.beginDictionaryItem("Type"); - objectBuilder << WrapName("Page"); - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("Parent"); - objectBuilder << getPageTreeRoot(); - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionary(); - objectBuilder.endDictionary(); - objectBuilder.beginDictionaryItem("MediaBox"); - objectBuilder << mediaBox; - objectBuilder.endDictionaryItem(); - objectBuilder.endDictionary(); - PDFObjectReference pageReference = addObject(objectBuilder.takeObject()); - objectBuilder.beginDictionary(); - objectBuilder.beginDictionaryItem("Kids"); - objectBuilder << std::initializer_list{ pageReference }; - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("Count"); - objectBuilder << getPageTreeRootChildCount() + 1; - objectBuilder.endDictionaryItem(); - objectBuilder.endDictionary(); - PDFObject updatedTreeRoot = objectBuilder.takeObject(); - appendTo(getPageTreeRoot(), updatedTreeRoot); - return pageReference; -} - - -PDFObjectReference PDFDocumentBuilder::createCatalogPageTreeRoot() -{ - PDFObjectFactory objectBuilder; - - objectBuilder.beginDictionary(); - objectBuilder.beginDictionaryItem("Type"); - objectBuilder << WrapName("Pages"); - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("Kids"); - objectBuilder << WrapEmptyArray(); - objectBuilder.endDictionaryItem(); - objectBuilder.beginDictionaryItem("Count"); - objectBuilder << 0; - objectBuilder.endDictionaryItem(); - objectBuilder.endDictionary(); - PDFObjectReference pageTreeRoot = addObject(objectBuilder.takeObject()); - return pageTreeRoot; -} - - -PDFObjectReference PDFDocumentBuilder::createAnnotationCircle(PDFObjectReference page, +PDFObjectReference PDFDocumentBuilder::createAnnotationSquare(PDFObjectReference page, QRectF rectangle, PDFReal borderWidth, QColor fillColor, @@ -611,8 +634,11 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationCircle(PDFObjectReference PDFObjectFactory objectBuilder; objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Annot"); + objectBuilder.endDictionaryItem(); objectBuilder.beginDictionaryItem("Subtype"); - objectBuilder << WrapName("Circle"); + objectBuilder << WrapName("Square"); objectBuilder.endDictionaryItem(); objectBuilder.beginDictionaryItem("Rect"); objectBuilder << rectangle; @@ -683,6 +709,9 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationText(PDFObjectReference p PDFObjectFactory objectBuilder; objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Annot"); + objectBuilder.endDictionaryItem(); objectBuilder.beginDictionaryItem("Subtype"); objectBuilder << WrapName("Text"); objectBuilder.endDictionaryItem(); @@ -741,6 +770,97 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationText(PDFObjectReference p } +PDFObjectReference PDFDocumentBuilder::createCatalog() +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Catalog"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Pages"); + objectBuilder << createCatalogPageTreeRoot(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObjectReference catalogReference = addObject(objectBuilder.takeObject()); + return catalogReference; +} + + +PDFObjectReference PDFDocumentBuilder::createCatalogPageTreeRoot() +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Pages"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Kids"); + objectBuilder << WrapEmptyArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Count"); + objectBuilder << 0; + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObjectReference pageTreeRoot = addObject(objectBuilder.takeObject()); + return pageTreeRoot; +} + + +PDFObject PDFDocumentBuilder::createTrailerDictionary(PDFObjectReference catalog) +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Size"); + objectBuilder << 1; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Root"); + objectBuilder << catalog; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Info"); + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Producer"); + objectBuilder << getProducerString(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("CreationDate"); + objectBuilder << WrapCurrentDateTime(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("ModDate"); + objectBuilder << WrapCurrentDateTime(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObject trailerDictionary = objectBuilder.takeObject(); + return trailerDictionary; +} + + +void PDFDocumentBuilder::updateTrailerDictionary(PDFInteger objectCount) +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Size"); + objectBuilder << objectCount; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Info"); + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Producer"); + objectBuilder << getProducerString(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("ModDate"); + objectBuilder << WrapCurrentDateTime(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObject trailerDictionary = objectBuilder.takeObject(); + m_storage.updateTrailerDictionary(qMove(trailerDictionary)); +} + + /* END GENERATED CODE */ } // namespace pdf diff --git a/PdfForQtLib/sources/pdfdocumentbuilder.h b/PdfForQtLib/sources/pdfdocumentbuilder.h index 371765b..2ee4bc2 100644 --- a/PdfForQtLib/sources/pdfdocumentbuilder.h +++ b/PdfForQtLib/sources/pdfdocumentbuilder.h @@ -79,6 +79,7 @@ public: PDFObjectFactory& operator<<(QString textString); PDFObjectFactory& operator<<(WrapEmptyArray); PDFObjectFactory& operator<<(TextAnnotationIcon icon); + PDFObjectFactory& operator<<(LinkHighlightMode mode); /// Treat containers - write them as array template()))> @@ -182,68 +183,14 @@ public: /* START GENERATED CODE */ - /// Square annotation displays rectangle (or square). When opened, they display pop-up window - /// containing the text of associated note (and window title). Square border/fill color can be defined, - /// along with border width. - /// \param page Page to which is annotation added - /// \param rectangle Area in which is rectangle displayed - /// \param borderWidth Width of the border line of rectangle - /// \param fillColor Fill color of rectangle (interior color). If you do not want to have area color filled, - /// then use invalid QColor. - /// \param strokeColor Stroke color (color of the rectangle border). If you do not want to have a - /// border, then use invalid QColor. - /// \param title Title (it is displayed as title of popup window) - /// \param subject Subject (short description of the subject being adressed by the annotation) - /// \param contents Contents (text displayed, for example, in the marked annotation dialog) - PDFObjectReference createAnnotationSquare(PDFObjectReference page, - QRectF rectangle, - PDFReal borderWidth, - QColor fillColor, - QColor strokeColor, - QString title, - QString subject, - QString contents); - - - /// Creates a new popup annotation on the page. Popup annotation is represented usually by floating - /// window, which can be opened, or closed. Popup annotation is associated with parent annotation, - /// which can be usually markup annotation. Popup annotation displays parent annotation's texts, for - /// example, title, comment, date etc. - /// \param page Page to which is annotation added - /// \param parentAnnotation Parent annotation (for which is popup window displayed) - /// \param rectangle Area on the page, where popup window appears - /// \param opened Is the window opened? - PDFObjectReference createAnnotationPopup(PDFObjectReference page, - PDFObjectReference parentAnnotation, - QRectF rectangle, - bool opened); - - - /// Creates empty catalog. This function is used, when a new document is being created. Do not call - /// this function manually. - PDFObjectReference createCatalog(); - - - /// This function is used to create a new trailer dictionary, when blank document is created. Do not - /// call this function manually. - /// \param catalog Reference to document catalog - PDFObject createTrailerDictionary(PDFObjectReference catalog); - - - /// This function is used to update trailer dictionary. Must be called each time the final document is - /// being built. - /// \param objectCount Number of objects (including empty ones) - void updateTrailerDictionary(PDFInteger objectCount); - - /// Appends a new page after last page. /// \param mediaBox Media box of the page (size of paper) PDFObjectReference appendPage(QRectF mediaBox); - /// Creates page tree root for the catalog. This function is only called when new document is being - /// created. Do not call this function manually. - PDFObjectReference createCatalogPageTreeRoot(); + /// Creates URI action. + /// \param URL Target URL + PDFObjectReference createActionURI(QString URL); /// Circle annotation displays ellipse (or circle). When opened, they display pop-up window containing @@ -269,6 +216,69 @@ public: QString contents); + /// Creates new link annotation. It usually represents clickable hypertext link. User can also specify + /// action, which can be executed, for example, link can be also in the PDF document (link to some + /// location in document). + /// \param page Page to which is annotation added + /// \param linkRectangle Link rectangle + /// \param action Action to be performed when user clicks on a link + /// \param highlightMode Highlight mode + PDFObjectReference createAnnotationLink(PDFObjectReference page, + QRectF linkRectangle, + PDFObjectReference action, + LinkHighlightMode highlightMode); + + + /// Creates new link annotation. It usually represents clickable hypertext link. User can also specify + /// action, which can be executed, for example, link can be also in the PDF document (link to some + /// location in document). + /// \param page Page to which is annotation added + /// \param linkRectangle Link rectangle + /// \param URL URL to be launched when user clicks on the link + /// \param highlightMode Highlight mode + PDFObjectReference createAnnotationLink(PDFObjectReference page, + QRectF linkRectangle, + QString URL, + LinkHighlightMode highlightMode); + + + /// Creates a new popup annotation on the page. Popup annotation is represented usually by floating + /// window, which can be opened, or closed. Popup annotation is associated with parent annotation, + /// which can be usually markup annotation. Popup annotation displays parent annotation's texts, for + /// example, title, comment, date etc. + /// \param page Page to which is annotation added + /// \param parentAnnotation Parent annotation (for which is popup window displayed) + /// \param rectangle Area on the page, where popup window appears + /// \param opened Is the window opened? + PDFObjectReference createAnnotationPopup(PDFObjectReference page, + PDFObjectReference parentAnnotation, + QRectF rectangle, + bool opened); + + + /// Square annotation displays rectangle (or square). When opened, they display pop-up window + /// containing the text of associated note (and window title). Square border/fill color can be defined, + /// along with border width. + /// \param page Page to which is annotation added + /// \param rectangle Area in which is rectangle displayed + /// \param borderWidth Width of the border line of rectangle + /// \param fillColor Fill color of rectangle (interior color). If you do not want to have area color filled, + /// then use invalid QColor. + /// \param strokeColor Stroke color (color of the rectangle border). If you do not want to have a + /// border, then use invalid QColor. + /// \param title Title (it is displayed as title of popup window) + /// \param subject Subject (short description of the subject being adressed by the annotation) + /// \param contents Contents (text displayed, for example, in the marked annotation dialog) + PDFObjectReference createAnnotationSquare(PDFObjectReference page, + QRectF rectangle, + PDFReal borderWidth, + QColor fillColor, + QColor strokeColor, + QString title, + QString subject, + QString contents); + + /// Creates text annotation. Text annotation is "sticky note" attached to a point in the PDF document. /// When closed, it is displayed as icon, if opened, widget appears with attached text. Text annotations /// do not scale or rotate, they appear independent of zoom/rotate. So, they behave as if flags @@ -289,6 +299,28 @@ public: bool open); + /// Creates empty catalog. This function is used, when a new document is being created. Do not call + /// this function manually. + PDFObjectReference createCatalog(); + + + /// Creates page tree root for the catalog. This function is only called when new document is being + /// created. Do not call this function manually. + PDFObjectReference createCatalogPageTreeRoot(); + + + /// This function is used to create a new trailer dictionary, when blank document is created. Do not + /// call this function manually. + /// \param catalog Reference to document catalog + PDFObject createTrailerDictionary(PDFObjectReference catalog); + + + /// This function is used to update trailer dictionary. Must be called each time the final document is + /// being built. + /// \param objectCount Number of objects (including empty ones) + void updateTrailerDictionary(PDFInteger objectCount); + + /* END GENERATED CODE */ private: diff --git a/generated_code_definition.xml b/generated_code_definition.xml index ad79e43..e19f0a4 100644 --- a/generated_code_definition.xml +++ b/generated_code_definition.xml @@ -2,597 +2,6 @@ - - - - - - - - - - page - _PDFObjectReference - Page to which is annotation added - - - - - rectangle - _QRectF - Area in which is rectangle displayed - - - - - borderWidth - _PDFReal - Width of the border line of rectangle - - - - - fillColor - _QColor - Fill color of rectangle (interior color). If you do not want to have area color filled, then use invalid QColor. - - - - - strokeColor - _QColor - Stroke color (color of the rectangle border). If you do not want to have a border, then use invalid QColor. - - - - - title - _QString - Title (it is displayed as title of popup window) - - - - - subject - _QString - Subject (short description of the subject being adressed by the annotation) - - - - - contents - _QString - Contents (text displayed, for example, in the marked annotation dialog) - - - Parameters - - _void - - - - - - - - - - - - Subtype - DictionaryItemSimple - WrapName("Square") - - - - - Rect - DictionaryItemSimple - rectangle - - - - - F - DictionaryItemSimple - 4 - - - - - P - DictionaryItemSimple - page - - - - - M - DictionaryItemSimple - WrapCurrentDateTime() - - - - - CreationDate - DictionaryItemSimple - WrapCurrentDateTime() - - - - - Border - DictionaryItemSimple - std::initializer_list<PDFReal>{ 0.0, 0.0, borderWidth } - - - - - C - DictionaryItemSimple - WrapAnnotationColor(strokeColor) - - - - - IC - DictionaryItemSimple - WrapAnnotationColor(fillColor) - - - - - T - DictionaryItemSimple - title - - - - - Contents - DictionaryItemSimple - contents - - - - - Subj - DictionaryItemSimple - subject - - - - Dictionary - - - - CreateObject - annotationObject - _PDFObjectReference - - - - - - Code - - _void - PDFObjectReference popupAnnotation = createAnnotationPopup(page, annotationObject, getPopupWindowRect(rectangle), false); - - - - - - - - - - - Popup - DictionaryItemSimple - popupAnnotation - - - Popup - Dictionary - popupAnnotation - - - CreateObject - updateAnnotationPopup - _PDFObject - - - - - - - - - - - - - - - - ArraySimple - annotationObject;popupAnnotation - - - Annots - DictionaryItemComplex - - - - - Dictionary - - - - CreateObject - pageAnnots - _PDFObject - - - - - - Code - - _void - mergeTo(annotationObject, updateAnnotationPopup); -appendTo(page, pageAnnots); -return annotationObject; - - - Annotations - createAnnotationSquare - Square annotation displays rectangle (or square). When opened, they display pop-up window containing the text of associated note (and window title). Square border/fill color can be defined, along with border width. - _PDFObjectReference - - - - - - - - - - - page - _PDFObjectReference - Page to which is annotation added - - - - - parentAnnotation - _PDFObjectReference - Parent annotation (for which is popup window displayed) - - - - - rectangle - _QRectF - Area on the page, where popup window appears - - - - - opened - _bool - Is the window opened? - - - Parameters - - _void - - - - - - - - - - - - Subtype - DictionaryItemSimple - WrapName("Popup") - - - - - Rect - DictionaryItemSimple - rectangle - - - - - P - DictionaryItemSimple - page - - - - - Parent - DictionaryItemSimple - parentAnnotation - - - - - Open - DictionaryItemSimple - opened - - - - Dictionary - - - - CreateObject - popupAnnotation - _PDFObjectReference - - - - - - Code - - _void - return popupAnnotation; - - - Annotations - createAnnotationPopup - Creates a new popup annotation on the page. Popup annotation is represented usually by floating window, which can be opened, or closed. Popup annotation is associated with parent annotation, which can be usually markup annotation. Popup annotation displays parent annotation's texts, for example, title, comment, date etc. - _PDFObjectReference - - - - - - - - - - - - - - Type - DictionaryItemSimple - WrapName("Catalog") - - - - - Pages - DictionaryItemSimple - createCatalogPageTreeRoot() - - - - Dictionary - - - - CreateObject - catalogReference - _PDFObjectReference - - - - - - Code - - _void - return catalogReference; - - - Structure - createCatalog - Creates empty catalog. This function is used, when a new document is being created. Do not call this function manually. - _PDFObjectReference - - - - - - - - - - - catalog - _PDFObjectReference - Reference to document catalog - - - Parameters - - _void - - - - - - - - - - - - Size - DictionaryItemSimple - 1 - - - - - Root - DictionaryItemSimple - catalog - - - - - - - - - - - Producer - DictionaryItemSimple - getProducerString() - - - - - CreationDate - DictionaryItemSimple - WrapCurrentDateTime() - - - - - ModDate - DictionaryItemSimple - WrapCurrentDateTime() - - - - Dictionary - - - - Info - DictionaryItemComplex - - - - - Dictionary - - - - CreateObject - trailerDictionary - _PDFObject - - - - - - Code - - _void - return trailerDictionary; - - - Structure - createTrailerDictionary - This function is used to create a new trailer dictionary, when blank document is created. Do not call this function manually. - _PDFObject - - - - - - - - - - - objectCount - _PDFInteger - Number of objects (including empty ones) - - - Parameters - - _void - - - - - - - - - - - - Size - DictionaryItemSimple - objectCount - - - - - - - - - - - Producer - DictionaryItemSimple - getProducerString() - - - - - ModDate - DictionaryItemSimple - WrapCurrentDateTime() - - - - Dictionary - - - - Info - DictionaryItemComplex - - - - - Dictionary - - - - CreateObject - trailerDictionary - _PDFObject - - - - - - Code - - _void - m_storage.updateTrailerDictionary(qMove(trailerDictionary)); - - - Structure - updateTrailerDictionary - This function is used to update trailer dictionary. Must be called each time the final document is being built. - _void - @@ -706,6 +115,22 @@ return pageReference; + + + + + + + URL + _QString + Target URL + + + Parameters + + _void + + @@ -717,21 +142,21 @@ return pageReference; Type DictionaryItemSimple - WrapName("Pages") + WrapName("Action") - Kids + S DictionaryItemSimple - WrapEmptyArray() + WrapName("URI") - Count + URI DictionaryItemSimple - 0 + URL @@ -740,7 +165,7 @@ return pageReference; CreateObject - pageTreeRoot + actionReference _PDFObjectReference @@ -750,12 +175,12 @@ return pageReference; Code _void - return pageTreeRoot; + return actionReference; - Structure - createCatalogPageTreeRoot - Creates page tree root for the catalog. This function is only called when new document is being created. Do not call this function manually. + Actions + createActionURI + Creates URI action. _PDFObjectReference @@ -832,6 +257,13 @@ return pageReference; + + + + Type + DictionaryItemSimple + WrapName("Annot") + @@ -1007,6 +439,575 @@ return annotationObject; Circle annotation displays ellipse (or circle). When opened, they display pop-up window containing the text of associated note (and window title). Circle border/fill color can be defined, along with border width. _PDFObjectReference + + + + + + + + + + page + _PDFObjectReference + Page to which is annotation added + + + + + linkRectangle + _QRectF + Link rectangle + + + + + action + _PDFObjectReference + Action to be performed when user clicks on a link + + + + + highlightMode + _LinkHighlightMode + Highlight mode + + + Parameters + + _void + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Annot") + + + + + Subtype + DictionaryItemSimple + WrapName("Link") + + + + + P + DictionaryItemSimple + page + + + + + Rect + DictionaryItemSimple + linkRectangle + + + + + A + DictionaryItemSimple + action + + + + + H + DictionaryItemSimple + highlightMode + + + + Dictionary + + + + CreateObject + annotationReference + _PDFObjectReference + + + + + + + + + + + + + + + + ArraySimple + annotationReference + + + Annots + DictionaryItemComplex + + + + + Dictionary + + + + CreateObject + pageAnnots + _PDFObject + + + + + + Code + + _void + appendTo(page, pageAnnots); +return annotationReference; + + + Annotations + createAnnotationLink + Creates new link annotation. It usually represents clickable hypertext link. User can also specify action, which can be executed, for example, link can be also in the PDF document (link to some location in document). + _PDFObjectReference + + + + + + + + + + + page + _PDFObjectReference + Page to which is annotation added + + + + + linkRectangle + _QRectF + Link rectangle + + + + + URL + _QString + URL to be launched when user clicks on the link + + + + + highlightMode + _LinkHighlightMode + Highlight mode + + + Parameters + + _void + + + + + + Code + + _void + return createAnnotationLink(page, linkRectangle, createActionURI(URL), highlightMode); + + + Annotations + createAnnotationLink + Creates new link annotation. It usually represents clickable hypertext link. User can also specify action, which can be executed, for example, link can be also in the PDF document (link to some location in document). + _PDFObjectReference + + + + + + + + + + + page + _PDFObjectReference + Page to which is annotation added + + + + + parentAnnotation + _PDFObjectReference + Parent annotation (for which is popup window displayed) + + + + + rectangle + _QRectF + Area on the page, where popup window appears + + + + + opened + _bool + Is the window opened? + + + Parameters + + _void + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Annot") + + + + + Subtype + DictionaryItemSimple + WrapName("Popup") + + + + + Rect + DictionaryItemSimple + rectangle + + + + + P + DictionaryItemSimple + page + + + + + Parent + DictionaryItemSimple + parentAnnotation + + + + + Open + DictionaryItemSimple + opened + + + + Dictionary + + + + CreateObject + popupAnnotation + _PDFObjectReference + + + + + + Code + + _void + return popupAnnotation; + + + Annotations + createAnnotationPopup + Creates a new popup annotation on the page. Popup annotation is represented usually by floating window, which can be opened, or closed. Popup annotation is associated with parent annotation, which can be usually markup annotation. Popup annotation displays parent annotation's texts, for example, title, comment, date etc. + _PDFObjectReference + + + + + + + + + + + page + _PDFObjectReference + Page to which is annotation added + + + + + rectangle + _QRectF + Area in which is rectangle displayed + + + + + borderWidth + _PDFReal + Width of the border line of rectangle + + + + + fillColor + _QColor + Fill color of rectangle (interior color). If you do not want to have area color filled, then use invalid QColor. + + + + + strokeColor + _QColor + Stroke color (color of the rectangle border). If you do not want to have a border, then use invalid QColor. + + + + + title + _QString + Title (it is displayed as title of popup window) + + + + + subject + _QString + Subject (short description of the subject being adressed by the annotation) + + + + + contents + _QString + Contents (text displayed, for example, in the marked annotation dialog) + + + Parameters + + _void + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Annot") + + + + + Subtype + DictionaryItemSimple + WrapName("Square") + + + + + Rect + DictionaryItemSimple + rectangle + + + + + F + DictionaryItemSimple + 4 + + + + + P + DictionaryItemSimple + page + + + + + M + DictionaryItemSimple + WrapCurrentDateTime() + + + + + CreationDate + DictionaryItemSimple + WrapCurrentDateTime() + + + + + Border + DictionaryItemSimple + std::initializer_list<PDFReal>{ 0.0, 0.0, borderWidth } + + + + + C + DictionaryItemSimple + WrapAnnotationColor(strokeColor) + + + + + IC + DictionaryItemSimple + WrapAnnotationColor(fillColor) + + + + + T + DictionaryItemSimple + title + + + + + Contents + DictionaryItemSimple + contents + + + + + Subj + DictionaryItemSimple + subject + + + + Dictionary + + + + CreateObject + annotationObject + _PDFObjectReference + + + + + + Code + + _void + PDFObjectReference popupAnnotation = createAnnotationPopup(page, annotationObject, getPopupWindowRect(rectangle), false); + + + + + + + + + + + Popup + DictionaryItemSimple + popupAnnotation + + + Popup + Dictionary + popupAnnotation + + + CreateObject + updateAnnotationPopup + _PDFObject + + + + + + + + + + + + + + + + ArraySimple + annotationObject;popupAnnotation + + + Annots + DictionaryItemComplex + + + + + Dictionary + + + + CreateObject + pageAnnots + _PDFObject + + + + + + Code + + _void + mergeTo(annotationObject, updateAnnotationPopup); +appendTo(page, pageAnnots); +return annotationObject; + + + Annotations + createAnnotationSquare + Square annotation displays rectangle (or square). When opened, they display pop-up window containing the text of associated note (and window title). Square border/fill color can be defined, along with border width. + _PDFObjectReference + @@ -1074,6 +1075,13 @@ return annotationObject; + + + + Type + DictionaryItemSimple + WrapName("Annot") + @@ -1242,5 +1250,296 @@ return annotationObject; Creates text annotation. Text annotation is "sticky note" attached to a point in the PDF document. When closed, it is displayed as icon, if opened, widget appears with attached text. Text annotations do not scale or rotate, they appear independent of zoom/rotate. So, they behave as if flags NoZoom or NoRotate to the annotations are being set. _PDFObjectReference + + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Catalog") + + + + + Pages + DictionaryItemSimple + createCatalogPageTreeRoot() + + + + Dictionary + + + + CreateObject + catalogReference + _PDFObjectReference + + + + + + Code + + _void + return catalogReference; + + + Structure + createCatalog + Creates empty catalog. This function is used, when a new document is being created. Do not call this function manually. + _PDFObjectReference + + + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Pages") + + + + + Kids + DictionaryItemSimple + WrapEmptyArray() + + + + + Count + DictionaryItemSimple + 0 + + + + Dictionary + + + + CreateObject + pageTreeRoot + _PDFObjectReference + + + + + + Code + + _void + return pageTreeRoot; + + + Structure + createCatalogPageTreeRoot + Creates page tree root for the catalog. This function is only called when new document is being created. Do not call this function manually. + _PDFObjectReference + + + + + + + + + + + catalog + _PDFObjectReference + Reference to document catalog + + + Parameters + + _void + + + + + + + + + + + + Size + DictionaryItemSimple + 1 + + + + + Root + DictionaryItemSimple + catalog + + + + + + + + + + + Producer + DictionaryItemSimple + getProducerString() + + + + + CreationDate + DictionaryItemSimple + WrapCurrentDateTime() + + + + + ModDate + DictionaryItemSimple + WrapCurrentDateTime() + + + + Dictionary + + + + Info + DictionaryItemComplex + + + + + Dictionary + + + + CreateObject + trailerDictionary + _PDFObject + + + + + + Code + + _void + return trailerDictionary; + + + Structure + createTrailerDictionary + This function is used to create a new trailer dictionary, when blank document is created. Do not call this function manually. + _PDFObject + + + + + + + + + + + objectCount + _PDFInteger + Number of objects (including empty ones) + + + Parameters + + _void + + + + + + + + + + + + Size + DictionaryItemSimple + objectCount + + + + + + + + + + + Producer + DictionaryItemSimple + getProducerString() + + + + + ModDate + DictionaryItemSimple + WrapCurrentDateTime() + + + + Dictionary + + + + Info + DictionaryItemComplex + + + + + Dictionary + + + + CreateObject + trailerDictionary + _PDFObject + + + + + + Code + + _void + m_storage.updateTrailerDictionary(qMove(trailerDictionary)); + + + Structure + updateTrailerDictionary + This function is used to update trailer dictionary. Must be called each time the final document is being built. + _void +