From 9fa2a70bf48cfe4e4810287d9a3f9be1a8fd6738 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Wed, 25 Mar 2020 18:53:24 +0100 Subject: [PATCH] Free text and line annotations --- CodeGenerator/codegenerator.h | 4 +- PdfExampleGenerator/pdfexamplesgenerator.cpp | 53 ++ PdfForQtLib/sources/pdfannotation.h | 2 + PdfForQtLib/sources/pdfdocumentbuilder.cpp | 320 ++++++++ PdfForQtLib/sources/pdfdocumentbuilder.h | 106 ++- generated_code_definition.xml | 792 ++++++++++++++++++- 6 files changed, 1274 insertions(+), 3 deletions(-) diff --git a/CodeGenerator/codegenerator.h b/CodeGenerator/codegenerator.h index d5aed03..2b3edaa 100644 --- a/CodeGenerator/codegenerator.h +++ b/CodeGenerator/codegenerator.h @@ -146,7 +146,9 @@ public: _QColor, _QVariant, _TextAnnotationIcon, - _LinkHighlightMode + _LinkHighlightMode, + _TextAlignment, + _AnnotationLineEnding }; Q_ENUM(DataType) diff --git a/PdfExampleGenerator/pdfexamplesgenerator.cpp b/PdfExampleGenerator/pdfexamplesgenerator.cpp index 903dd07..a860a45 100644 --- a/PdfExampleGenerator/pdfexamplesgenerator.cpp +++ b/PdfExampleGenerator/pdfexamplesgenerator.cpp @@ -46,6 +46,59 @@ void PDFExamplesGenerator::generateAnnotationsExample() 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 page3 = builder.appendPage(QRectF(0, 0, 400, 400)); + builder.createAnnotationFreeText(page3, QRectF(50, 50, 100, 50), "Title", "Subject", "Toto je dolni text", Qt::AlignLeft); + builder.createAnnotationFreeText(page3, QRectF(50, 150, 100, 50), "Title", "Subject", "Toto je stredni text", Qt::AlignCenter); + builder.createAnnotationFreeText(page3, QRectF(50, 250, 100, 50), "Title", "Subject", "Toto je horni text", Qt::AlignRight); + builder.createAnnotationFreeText(page3, QRectF(250, 50, 100, 50), QRectF(300, 50, 50, 50), "Title", "Subject", "Toto je dolni text", Qt::AlignLeft, QPointF(250, 50), QPointF(300, 100), pdf::AnnotationLineEnding::OpenArrow, pdf::AnnotationLineEnding::ClosedArrow); + builder.createAnnotationFreeText(page3, QRectF(250, 150, 100, 50), QRectF(50, 50, 50, 50), "Title", "Subject", "Toto je stredni text", Qt::AlignCenter, QPointF(250, 150), QPointF(300, 200), pdf::AnnotationLineEnding::OpenArrow, pdf::AnnotationLineEnding::ClosedArrow); + builder.createAnnotationFreeText(page3, QRectF(250, 250, 100, 50), QRectF(0, 50, 50, 50), "Title", "Subject", "Toto je horni text", Qt::AlignRight, QPointF(250, 250), QPointF(300, 300), pdf::AnnotationLineEnding::OpenArrow, pdf::AnnotationLineEnding::ClosedArrow); + + pdf::PDFObjectReference page4 = builder.appendPage(QRectF(0, 0, 400, 400)); + std::vector lineRects; + QRectF baseRect = QRectF(0, 0, 100, 50); + qreal spaceCoef = 1.2; + int lineRows = 400 / (baseRect.height() * spaceCoef); + int lineCols = 400 / (baseRect.width() * spaceCoef); + int lineNumber = 0; + constexpr pdf::AnnotationLineEnding lineEndings[] = + { + pdf::AnnotationLineEnding::None, + pdf::AnnotationLineEnding::Square, + pdf::AnnotationLineEnding::Circle, + pdf::AnnotationLineEnding::Diamond, + pdf::AnnotationLineEnding::OpenArrow, + pdf::AnnotationLineEnding::ClosedArrow, + pdf::AnnotationLineEnding::Butt, + pdf::AnnotationLineEnding::ROpenArrow, + pdf::AnnotationLineEnding::RClosedArrow, + pdf::AnnotationLineEnding::Slash + }; + for (int i = 0; i < lineCols; ++i) + { + for (int j = 0; j < lineRows; ++j) + { + QRectF rect = baseRect.translated(i * baseRect.width() * spaceCoef, j * baseRect.height() * spaceCoef); + + QPointF start; + QPointF end; + if (lineNumber % 2 == 0) + { + start = rect.topLeft(); + end = rect.bottomRight(); + } + else + { + start = rect.bottomLeft(); + end = rect.topRight(); + } + + pdf::AnnotationLineEnding lineEnding = lineEndings[lineNumber % std::size(lineEndings)]; + builder.createAnnotationLine(page4, rect, start, end, 2.0, Qt::yellow, Qt::green, "Title", "Subject", "Contents", lineEnding, lineEnding); + ++lineNumber; + } + } + 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.h b/PdfForQtLib/sources/pdfannotation.h index af91e13..cc3dd0e 100644 --- a/PdfForQtLib/sources/pdfannotation.h +++ b/PdfForQtLib/sources/pdfannotation.h @@ -34,6 +34,8 @@ namespace pdf class PDFDocument; class PDFDrawWidgetProxy; +using TextAlignment = Qt::Alignment; + enum class AnnotationType { Invalid, diff --git a/PdfForQtLib/sources/pdfdocumentbuilder.cpp b/PdfForQtLib/sources/pdfdocumentbuilder.cpp index 23c01c6..a6270d9 100644 --- a/PdfForQtLib/sources/pdfdocumentbuilder.cpp +++ b/PdfForQtLib/sources/pdfdocumentbuilder.cpp @@ -64,6 +64,83 @@ void PDFObjectFactory::endDictionaryItem() std::get(dictionaryItem.object).addEntry(qMove(topItem.itemName), qMove(std::get(topItem.object))); } +PDFObjectFactory& PDFObjectFactory::operator<<(AnnotationLineEnding lineEnding) +{ + switch (lineEnding) + { + case AnnotationLineEnding::Square: + *this << WrapName("Square"); + break; + + case AnnotationLineEnding::Circle: + *this << WrapName("Circle"); + break; + + case AnnotationLineEnding::Diamond: + *this << WrapName("Diamond"); + break; + + case AnnotationLineEnding::OpenArrow: + *this << WrapName("OpenArrow"); + break; + + case AnnotationLineEnding::ClosedArrow: + *this << WrapName("ClosedArrow"); + break; + + case AnnotationLineEnding::Butt: + *this << WrapName("Butt"); + break; + + case AnnotationLineEnding::ROpenArrow: + *this << WrapName("ROpenArrow"); + break; + + case AnnotationLineEnding::RClosedArrow: + *this << WrapName("RClosedArrow"); + break; + + case AnnotationLineEnding::Slash: + *this << WrapName("Slash"); + break; + + case AnnotationLineEnding::None: + default: + *this << WrapName("None"); + break; + } + + return *this; +} + +PDFObjectFactory& PDFObjectFactory::operator<<(WrapString string) +{ + addObject(PDFObject::createString(std::make_shared(qMove(string.string)))); + return *this; +} + +PDFObjectFactory& PDFObjectFactory::operator<<(WrapFreeTextAlignment alignment) +{ + if (alignment.alignment.testFlag(Qt::AlignLeft)) + { + *this << 0; + } + else if (alignment.alignment.testFlag(Qt::AlignHCenter)) + { + *this << 1; + } + else if (alignment.alignment.testFlag(Qt::AlignRight)) + { + *this << 2; + } + else + { + // Default is left alignment + *this << 0; + } + return *this; +} + PDFObjectFactory& PDFObjectFactory::operator<<(LinkHighlightMode mode) { switch (mode) @@ -350,6 +427,11 @@ PDFDocument PDFDocumentBuilder::build() return PDFDocument(PDFObjectStorage(m_storage), m_version); } +std::array PDFDocumentBuilder::getAnnotationReductionRectangle(const QRectF& boundingRect, const QRectF& innerRect) const +{ + return { qAbs(innerRect.left() - boundingRect.left()), qAbs(boundingRect.bottom() - innerRect.bottom()), qAbs(boundingRect.right() - innerRect.right()), qAbs(boundingRect.top() - innerRect.top()) }; +} + PDFObjectReference PDFDocumentBuilder::addObject(PDFObject object) { return m_storage.addObject(PDFObjectManipulator::removeNullObjects(object)); @@ -538,6 +620,244 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationCircle(PDFObjectReference } +PDFObjectReference PDFDocumentBuilder::createAnnotationFreeText(PDFObjectReference page, + QRectF rectangle, + QString title, + QString subject, + QString contents, + TextAlignment textAlignment) +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Annot"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Subtype"); + objectBuilder << WrapName("FreeText"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Rect"); + objectBuilder << rectangle; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("F"); + objectBuilder << 4; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("P"); + objectBuilder << page; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("M"); + objectBuilder << WrapCurrentDateTime(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("CreationDate"); + objectBuilder << WrapCurrentDateTime(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("T"); + objectBuilder << title; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Contents"); + objectBuilder << contents; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Subj"); + objectBuilder << subject; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Q"); + objectBuilder << WrapFreeTextAlignment(textAlignment); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("DA"); + objectBuilder << WrapString("/Arial 10 Tf"); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObjectReference annotationObject = addObject(objectBuilder.takeObject()); + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Annots"); + objectBuilder.beginArray(); + objectBuilder << annotationObject; + objectBuilder.endArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObject pageAnnots = objectBuilder.takeObject(); + appendTo(page, pageAnnots); + return annotationObject; +} + + +PDFObjectReference PDFDocumentBuilder::createAnnotationFreeText(PDFObjectReference page, + QRectF boundingRectangle, + QRectF textRectangle, + QString title, + QString subject, + QString contents, + TextAlignment textAlignment, + QPointF startPoint, + QPointF endPoint, + AnnotationLineEnding startLineType, + AnnotationLineEnding endLineType) +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Annot"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Subtype"); + objectBuilder << WrapName("FreeText"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Rect"); + objectBuilder << boundingRectangle; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("F"); + objectBuilder << 4; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("P"); + objectBuilder << page; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("M"); + objectBuilder << WrapCurrentDateTime(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("CreationDate"); + objectBuilder << WrapCurrentDateTime(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("T"); + objectBuilder << title; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Contents"); + objectBuilder << contents; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Subj"); + objectBuilder << subject; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Q"); + objectBuilder << WrapFreeTextAlignment(textAlignment); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("DA"); + objectBuilder << WrapString("/Arial 10 Tf"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("RD"); + objectBuilder << getAnnotationReductionRectangle(boundingRectangle, textRectangle); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("CL"); + objectBuilder.beginArray(); + objectBuilder << startPoint.x(); + objectBuilder << startPoint.y(); + objectBuilder << endPoint.x(); + objectBuilder << endPoint.y(); + objectBuilder.endArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("LE"); + objectBuilder.beginArray(); + objectBuilder << startLineType; + objectBuilder << endLineType; + objectBuilder.endArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObjectReference annotationObject = addObject(objectBuilder.takeObject()); + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Annots"); + objectBuilder.beginArray(); + objectBuilder << annotationObject; + objectBuilder.endArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObject pageAnnots = objectBuilder.takeObject(); + appendTo(page, pageAnnots); + return annotationObject; +} + + +PDFObjectReference PDFDocumentBuilder::createAnnotationLine(PDFObjectReference page, + QRectF boundingRect, + QPointF startPoint, + QPointF endPoint, + PDFReal lineWidth, + QColor fillColor, + QColor strokeColor, + QString title, + QString subject, + QString contents, + AnnotationLineEnding startLineType, + AnnotationLineEnding endLineType) +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Annot"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Subtype"); + objectBuilder << WrapName("Line"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Rect"); + objectBuilder << boundingRect; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("F"); + objectBuilder << 4; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("P"); + objectBuilder << page; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("L"); + objectBuilder.beginArray(); + objectBuilder << startPoint.x(); + objectBuilder << startPoint.y(); + objectBuilder << endPoint.x(); + objectBuilder << endPoint.y(); + objectBuilder.endArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("LE"); + objectBuilder.beginArray(); + objectBuilder << startLineType; + objectBuilder << endLineType; + objectBuilder.endArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("M"); + objectBuilder << WrapCurrentDateTime(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("CreationDate"); + objectBuilder << WrapCurrentDateTime(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Border"); + objectBuilder << std::initializer_list{ 0.0, 0.0, lineWidth }; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("C"); + objectBuilder << WrapAnnotationColor(strokeColor); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("IC"); + objectBuilder << WrapAnnotationColor(fillColor); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("T"); + objectBuilder << title; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Contents"); + objectBuilder << contents; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Subj"); + objectBuilder << subject; + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObjectReference annotationObject = addObject(objectBuilder.takeObject()); + PDFObjectReference popupAnnotation = createAnnotationPopup(page, annotationObject, getPopupWindowRect(boundingRect), false); + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Popup"); + objectBuilder << popupAnnotation; + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObject updateAnnotationPopup = objectBuilder.takeObject(); + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Annots"); + objectBuilder.beginArray(); + objectBuilder << annotationObject; + objectBuilder << popupAnnotation; + objectBuilder.endArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObject pageAnnots = objectBuilder.takeObject(); + mergeTo(annotationObject, updateAnnotationPopup); + appendTo(page, pageAnnots); + return annotationObject; +} + + PDFObjectReference PDFDocumentBuilder::createAnnotationLink(PDFObjectReference page, QRectF linkRectangle, PDFObjectReference action, diff --git a/PdfForQtLib/sources/pdfdocumentbuilder.h b/PdfForQtLib/sources/pdfdocumentbuilder.h index 2ee4bc2..0f3c22e 100644 --- a/PdfForQtLib/sources/pdfdocumentbuilder.h +++ b/PdfForQtLib/sources/pdfdocumentbuilder.h @@ -47,6 +47,28 @@ struct WrapAnnotationColor QColor color; }; +struct WrapFreeTextAlignment +{ + constexpr inline WrapFreeTextAlignment(Qt::Alignment alignment) : + alignment(alignment) + { + + } + + Qt::Alignment alignment; +}; + +struct WrapString +{ + WrapString(const char* string) : + string(string) + { + + } + + QByteArray string; +}; + struct WrapCurrentDateTime { }; struct WrapEmptyArray { }; @@ -80,6 +102,9 @@ public: PDFObjectFactory& operator<<(WrapEmptyArray); PDFObjectFactory& operator<<(TextAnnotationIcon icon); PDFObjectFactory& operator<<(LinkHighlightMode mode); + PDFObjectFactory& operator<<(WrapFreeTextAlignment alignment); + PDFObjectFactory& operator<<(WrapString string); + PDFObjectFactory& operator<<(AnnotationLineEnding lineEnding); /// Treat containers - write them as array template()))> @@ -181,6 +206,9 @@ public: /// is returned (no exception is thrown). const PDFObject& getObjectByReference(PDFObjectReference reference) const; + /// Returns annotation bounding rectangle + std::array getAnnotationReductionRectangle(const QRectF& boundingRect, const QRectF& innerRect) const; + /* START GENERATED CODE */ /// Appends a new page after last page. @@ -216,6 +244,82 @@ public: QString contents); + /// Free text annotation displays text directly on a page. Text appears directly on the page, in the + /// same way, as standard text in PDF document. Free text annotations are usually used to comment + /// the document. Free text annotation can also have callout line, with, or without a knee. + /// \param page Page to which is annotation added + /// \param rectangle Area in which is text displayed + /// \param title Title + /// \param subject Subject + /// \param contents Contents (text displayed) + /// \param textAlignment Text alignment. Only horizontal alignment flags are valid. + PDFObjectReference createAnnotationFreeText(PDFObjectReference page, + QRectF rectangle, + QString title, + QString subject, + QString contents, + TextAlignment textAlignment); + + + /// Free text annotation displays text directly on a page. Text appears directly on the page, in the + /// same way, as standard text in PDF document. Free text annotations are usually used to comment + /// the document. Free text annotation can also have callout line, with, or without a knee. Specify + /// start/end point parameters of this function to get callout line. + /// \param page Page to which is annotation added + /// \param boundingRectangle Bounding rectangle of free text annotation. It must contain both + /// callout line and text rectangle. + /// \param textRectangle Rectangle with text, in absolute coordinates. They are then recomputed to + /// match bounding rectangle. + /// \param title Title + /// \param subject Subject + /// \param contents Contents (text displayed) + /// \param textAlignment Text alignment. Only horizontal alignment flags are valid. + /// \param startPoint Start point of callout line + /// \param endPoint End point of callout line + /// \param startLineType Line ending at the start point + /// \param endLineType Line ending at the end point + PDFObjectReference createAnnotationFreeText(PDFObjectReference page, + QRectF boundingRectangle, + QRectF textRectangle, + QString title, + QString subject, + QString contents, + TextAlignment textAlignment, + QPointF startPoint, + QPointF endPoint, + AnnotationLineEnding startLineType, + AnnotationLineEnding endLineType); + + + /// Line annotation represents straight line, or some more advanced graphics, such as dimension with + /// text. Line annotations are markup annotations, so they can have popup window. Line endings can + /// be specified. + /// \param page Page to which is annotation added + /// \param boundingRect Line annotation bounding rectangle + /// \param startPoint Line start + /// \param endPoint Line end + /// \param lineWidth Line width + /// \param fillColor Fill color of line parts (for example, filled line endings) + /// \param strokeColor Line stroke color + /// \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) + /// \param startLineType Start line ending type + /// \param endLineType End line ending type + PDFObjectReference createAnnotationLine(PDFObjectReference page, + QRectF boundingRect, + QPointF startPoint, + QPointF endPoint, + PDFReal lineWidth, + QColor fillColor, + QColor strokeColor, + QString title, + QString subject, + QString contents, + AnnotationLineEnding startLineType, + AnnotationLineEnding endLineType); + + /// 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). @@ -289,7 +393,7 @@ public: /// \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) - /// \param open Is annotation initiali displayed as opened? + /// \param open Is annotation initially displayed as opened? PDFObjectReference createAnnotationText(PDFObjectReference page, QRectF rectangle, TextAnnotationIcon iconType, diff --git a/generated_code_definition.xml b/generated_code_definition.xml index e19f0a4..29477e8 100644 --- a/generated_code_definition.xml +++ b/generated_code_definition.xml @@ -439,6 +439,796 @@ 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 + + + + + rectangle + _QRectF + Area in which is text displayed + + + + + title + _QString + Title + + + + + subject + _QString + Subject + + + + + contents + _QString + Contents (text displayed) + + + + + textAlignment + _TextAlignment + Text alignment. Only horizontal alignment flags are valid. + + + Parameters + + _void + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Annot") + + + + + Subtype + DictionaryItemSimple + WrapName("FreeText") + + + + + Rect + DictionaryItemSimple + rectangle + + + + + F + DictionaryItemSimple + 4 + + + + + P + DictionaryItemSimple + page + + + + + M + DictionaryItemSimple + WrapCurrentDateTime() + + + + + CreationDate + DictionaryItemSimple + WrapCurrentDateTime() + + + + + T + DictionaryItemSimple + title + + + + + Contents + DictionaryItemSimple + contents + + + + + Subj + DictionaryItemSimple + subject + + + + + Q + DictionaryItemSimple + WrapFreeTextAlignment(textAlignment) + + + + + DA + DictionaryItemSimple + WrapString("/Arial 10 Tf") + + + + Dictionary + + + + CreateObject + annotationObject + _PDFObjectReference + + + + + + + + + + + + + + + + ArraySimple + annotationObject + + + Annots + DictionaryItemComplex + + + + + Dictionary + + + + CreateObject + pageAnnots + _PDFObject + + + + + + Code + + _void + appendTo(page, pageAnnots); +return annotationObject; + + + Annotations + createAnnotationFreeText + Free text annotation displays text directly on a page. Text appears directly on the page, in the same way, as standard text in PDF document. Free text annotations are usually used to comment the document. Free text annotation can also have callout line, with, or without a knee. + _PDFObjectReference + + + + + + + + + + + page + _PDFObjectReference + Page to which is annotation added + + + + + boundingRectangle + _QRectF + Bounding rectangle of free text annotation. It must contain both callout line and text rectangle. + + + + + textRectangle + _QRectF + Rectangle with text, in absolute coordinates. They are then recomputed to match bounding rectangle. + + + + + title + _QString + Title + + + + + subject + _QString + Subject + + + + + contents + _QString + Contents (text displayed) + + + + + textAlignment + _TextAlignment + Text alignment. Only horizontal alignment flags are valid. + + + + + startPoint + _QPointF + Start point of callout line + + + + + endPoint + _QPointF + End point of callout line + + + + + startLineType + _AnnotationLineEnding + Line ending at the start point + + + + + endLineType + _AnnotationLineEnding + Line ending at the end point + + + Parameters + + _void + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Annot") + + + + + Subtype + DictionaryItemSimple + WrapName("FreeText") + + + + + Rect + DictionaryItemSimple + boundingRectangle + + + + + F + DictionaryItemSimple + 4 + + + + + P + DictionaryItemSimple + page + + + + + M + DictionaryItemSimple + WrapCurrentDateTime() + + + + + CreationDate + DictionaryItemSimple + WrapCurrentDateTime() + + + + + T + DictionaryItemSimple + title + + + + + Contents + DictionaryItemSimple + contents + + + + + Subj + DictionaryItemSimple + subject + + + + + Q + DictionaryItemSimple + WrapFreeTextAlignment(textAlignment) + + + + + DA + DictionaryItemSimple + WrapString("/Arial 10 Tf") + + + + + RD + DictionaryItemSimple + getAnnotationReductionRectangle(boundingRectangle, textRectangle) + + + + + + + + + ArraySimple + startPoint.x();startPoint.y();endPoint.x();endPoint.y() + + + CL + DictionaryItemComplex + + + + + + + + + + ArraySimple + startLineType;endLineType + + + LE + DictionaryItemComplex + + + + + Dictionary + + + + CreateObject + annotationObject + _PDFObjectReference + + + + + + + + + + + + + + + + ArraySimple + annotationObject + + + Annots + DictionaryItemComplex + + + + + Dictionary + + + + CreateObject + pageAnnots + _PDFObject + + + + + + Code + + _void + appendTo(page, pageAnnots); +return annotationObject; + + + Annotations + createAnnotationFreeText + Free text annotation displays text directly on a page. Text appears directly on the page, in the same way, as standard text in PDF document. Free text annotations are usually used to comment the document. Free text annotation can also have callout line, with, or without a knee. Specify start/end point parameters of this function to get callout line. + _PDFObjectReference + + + + + + + + + + + page + _PDFObjectReference + Page to which is annotation added + + + + + boundingRect + _QRectF + Line annotation bounding rectangle + + + + + startPoint + _QPointF + Line start + + + + + endPoint + _QPointF + Line end + + + + + lineWidth + _PDFReal + Line width + + + + + fillColor + _QColor + Fill color of line parts (for example, filled line endings) + + + + + strokeColor + _QColor + Line stroke color + + + + + 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) + + + + + startLineType + _AnnotationLineEnding + Start line ending type + + + + + endLineType + _AnnotationLineEnding + End line ending type + + + Parameters + + _void + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Annot") + + + + + Subtype + DictionaryItemSimple + WrapName("Line") + + + + + Rect + DictionaryItemSimple + boundingRect + + + + + F + DictionaryItemSimple + 4 + + + + + P + DictionaryItemSimple + page + + + + + + + + + ArraySimple + startPoint.x();startPoint.y();endPoint.x();endPoint.y() + + + L + DictionaryItemComplex + + + + + + + + + + ArraySimple + startLineType;endLineType + + + LE + DictionaryItemComplex + + + + + + M + DictionaryItemSimple + WrapCurrentDateTime() + + + + + CreationDate + DictionaryItemSimple + WrapCurrentDateTime() + + + + + Border + DictionaryItemSimple + std::initializer_list<PDFReal>{ 0.0, 0.0, lineWidth } + + + + + 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(boundingRect), 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 + createAnnotationLine + Line annotation represents straight line, or some more advanced graphics, such as dimension with text. Line annotations are markup annotations, so they can have popup window. Line endings can be specified. + _PDFObjectReference + @@ -1061,7 +1851,7 @@ return annotationObject; open _bool - Is annotation initiali displayed as opened? + Is annotation initially displayed as opened? Parameters