diff --git a/CodeGenerator/codegenerator.h b/CodeGenerator/codegenerator.h index 2b3edaa..2b28078 100644 --- a/CodeGenerator/codegenerator.h +++ b/CodeGenerator/codegenerator.h @@ -145,6 +145,7 @@ public: _QRectF, _QColor, _QVariant, + _QPolygonF, _TextAnnotationIcon, _LinkHighlightMode, _TextAlignment, diff --git a/PdfExampleGenerator/pdfexamplesgenerator.cpp b/PdfExampleGenerator/pdfexamplesgenerator.cpp index a860a45..25e4666 100644 --- a/PdfExampleGenerator/pdfexamplesgenerator.cpp +++ b/PdfExampleGenerator/pdfexamplesgenerator.cpp @@ -54,48 +54,86 @@ void PDFExamplesGenerator::generateAnnotationsExample() 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) + pdf::PDFObjectReference page4 = builder.appendPage(QRectF(0, 0, 400, 400)); + 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[] = { - QRectF rect = baseRect.translated(i * baseRect.width() * spaceCoef, j * baseRect.height() * spaceCoef); - - QPointF start; - QPointF end; - if (lineNumber % 2 == 0) + 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) { - start = rect.topLeft(); - end = rect.bottomRight(); - } - else - { - start = rect.bottomLeft(); - end = rect.topRight(); - } + QRectF rect = baseRect.translated(i * baseRect.width() * spaceCoef, j * baseRect.height() * spaceCoef); - 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; + 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 page4 = builder.appendPage(QRectF(0, 0, 400, 400)); + 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(rect.left(), rect.center().y()); + QPointF end(rect.right(), rect.center().y()); + + 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, 10.0, 2.0, 3.0, true, (j % 2 == 0)); + ++lineNumber; + } } } @@ -109,6 +147,19 @@ void PDFExamplesGenerator::generateAnnotationsExample() builder.createAnnotationCircle(page6, QRectF(50, 150, 50, 50), 3.0, QColor(), Qt::red, "Title2", "Subject2", "Contents - red boundary"); builder.createAnnotationCircle(page6, QRectF(50, 250, 50, 50), 3.0, Qt::green, QColor(), "Title3", "Subject3", "Contents - green filling"); + pdf::PDFObjectReference page7 = builder.appendPage(QRectF(0, 0, 400, 400)); + QPolygonF polygon; + QRectF polygonRect(50, 50, 50, 50); + polygon << polygonRect.topLeft() << polygonRect.center() << polygonRect.topRight() << polygonRect.bottomRight() << polygonRect.bottomLeft() << polygonRect.topLeft(); + builder.createAnnotationPolygon(page7, polygon, 2.0, Qt::green, Qt::yellow, "Title", "Subject", "Contents"); + polygon.translate(0, 100); + builder.createAnnotationPolygon(page7, polygon, 2.0, Qt::red, Qt::cyan, "Title", "Subject", "Contents"); + polygon.pop_back(); + polygon.translate(200, 0); + builder.createAnnotationPolyline(page7, polygon, 2.0, Qt::green, Qt::yellow, "Title", "Subject", "Contents", pdf::AnnotationLineEnding::ClosedArrow, pdf::AnnotationLineEnding::Circle); + polygon.translate(0, -100); + builder.createAnnotationPolyline(page7, polygon, 2.0, Qt::green, Qt::yellow, "Title", "Subject", "Contents", pdf::AnnotationLineEnding::ClosedArrow, pdf::AnnotationLineEnding::Circle); + // Write result to a file pdf::PDFDocument document = builder.build(); pdf::PDFDocumentWriter writer(nullptr); diff --git a/PdfForQtLib/sources/pdfdocumentbuilder.cpp b/PdfForQtLib/sources/pdfdocumentbuilder.cpp index a6270d9..8544ba3 100644 --- a/PdfForQtLib/sources/pdfdocumentbuilder.cpp +++ b/PdfForQtLib/sources/pdfdocumentbuilder.cpp @@ -64,6 +64,13 @@ void PDFObjectFactory::endDictionaryItem() std::get(dictionaryItem.object).addEntry(qMove(topItem.itemName), qMove(std::get(topItem.object))); } +PDFObjectFactory& PDFObjectFactory::operator<<(const QPointF& point) +{ + *this << point.x(); + *this << point.y(); + return *this; +} + PDFObjectFactory& PDFObjectFactory::operator<<(AnnotationLineEnding lineEnding) { switch (lineEnding) @@ -858,6 +865,120 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationLine(PDFObjectReference p } +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, + PDFReal leaderLineLength, + PDFReal leaderLineOffset, + PDFReal leaderLineExtension, + bool displayContents, + bool displayedContentsTopAlign) +{ + 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.beginDictionaryItem("LL"); + objectBuilder << leaderLineLength; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("LLO"); + objectBuilder << leaderLineOffset; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("LLE"); + objectBuilder << leaderLineExtension; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Cap"); + objectBuilder << displayContents; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("CP"); + objectBuilder << (displayedContentsTopAlign ? WrapName("Top") : WrapName("Inline")); + 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, @@ -910,6 +1031,172 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationLink(PDFObjectReference p } +PDFObjectReference PDFDocumentBuilder::createAnnotationPolygon(PDFObjectReference page, + QPolygonF polygon, + PDFReal borderWidth, + QColor fillColor, + QColor strokeColor, + QString title, + QString subject, + QString contents) +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Type"); + objectBuilder << WrapName("Annot"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Subtype"); + objectBuilder << WrapName("Polygon"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Rect"); + objectBuilder << polygon.boundingRect(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("F"); + objectBuilder << 4; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("P"); + objectBuilder << page; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Vertices"); + objectBuilder << polygon; + 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, borderWidth }; + 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(polygon.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::createAnnotationPolyline(PDFObjectReference page, + QPolygonF polyline, + PDFReal borderWidth, + 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("PolyLine"); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Rect"); + objectBuilder << polyline.boundingRect(); + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("F"); + objectBuilder << 4; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("P"); + objectBuilder << page; + objectBuilder.endDictionaryItem(); + objectBuilder.beginDictionaryItem("Vertices"); + objectBuilder << polyline; + 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, borderWidth }; + 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.beginDictionaryItem(""); + objectBuilder.beginArray(); + objectBuilder << startLineType; + objectBuilder << endLineType; + objectBuilder.endArray(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObjectReference annotationObject = addObject(objectBuilder.takeObject()); + PDFObjectReference popupAnnotation = createAnnotationPopup(page, annotationObject, getPopupWindowRect(polyline.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::createAnnotationPopup(PDFObjectReference page, PDFObjectReference parentAnnotation, QRectF rectangle, diff --git a/PdfForQtLib/sources/pdfdocumentbuilder.h b/PdfForQtLib/sources/pdfdocumentbuilder.h index 0f3c22e..792e0be 100644 --- a/PdfForQtLib/sources/pdfdocumentbuilder.h +++ b/PdfForQtLib/sources/pdfdocumentbuilder.h @@ -105,6 +105,7 @@ public: PDFObjectFactory& operator<<(WrapFreeTextAlignment alignment); PDFObjectFactory& operator<<(WrapString string); PDFObjectFactory& operator<<(AnnotationLineEnding lineEnding); + PDFObjectFactory& operator<<(const QPointF& point); /// Treat containers - write them as array template()))> @@ -320,6 +321,50 @@ public: 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 + /// \param leaderLineLength Length of the leader line. Leader line extends from each endpoint of + /// the line perpendicular to the line itself. Value can be either positive, negative or zero. If + /// positive, then extension is in plane that is above the annotation line (in clockwise order), + /// if negative, then it is below the annotation line. + /// \param leaderLineOffset Length of leader line offset, which is the amount of empty space + /// between the endpoints of the annotation and beginning of leader lines + /// \param leaderLineExtension Length of leader line extension, which extends leader lines in 180° + /// direction from leader lines (so leader lines continues above drawn line) + /// \param displayContents Display contents of the annotation as text along the line + /// \param displayedContentsTopAlign Displayed contents appear above the line, instead inline. + 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, + PDFReal leaderLineLength, + PDFReal leaderLineOffset, + PDFReal leaderLineExtension, + bool displayContents, + bool displayedContentsTopAlign); + + /// 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). @@ -346,6 +391,50 @@ public: LinkHighlightMode highlightMode); + /// Polygon annotation. When opened, they display pop-up window containing the text of associated + /// note (and window title). Polygon border/fill color can be defined, along with border width. + /// \param page Page to which is annotation added + /// \param polygon Polygon + /// \param borderWidth Border line width + /// \param fillColor Fill color + /// \param strokeColor Stroke color + /// \param title Title + /// \param subject Subject + /// \param contents Contents + PDFObjectReference createAnnotationPolygon(PDFObjectReference page, + QPolygonF polygon, + PDFReal borderWidth, + QColor fillColor, + QColor strokeColor, + QString title, + QString subject, + QString contents); + + + /// Polyline annotation. When opened, they display pop-up window containing the text of associated + /// note (and window title). Polyline border/fill color can be defined, along with border width. + /// \param page Page to which is annotation added + /// \param polyline Polyline + /// \param borderWidth Border line width + /// \param fillColor Fill color + /// \param strokeColor Stroke color + /// \param title Title + /// \param subject Subject + /// \param contents Contents + /// \param startLineType Start line ending type + /// \param endLineType End line ending type + PDFObjectReference createAnnotationPolyline(PDFObjectReference page, + QPolygonF polyline, + PDFReal borderWidth, + QColor fillColor, + QColor strokeColor, + QString title, + QString subject, + QString contents, + AnnotationLineEnding startLineType, + AnnotationLineEnding endLineType); + + /// 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 diff --git a/generated_code_definition.xml b/generated_code_definition.xml index 29477e8..358ed70 100644 --- a/generated_code_definition.xml +++ b/generated_code_definition.xml @@ -1221,6 +1221,390 @@ return annotationObject; _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 + + + + + + + + + + + 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 + + + + + leaderLineLength + _PDFReal + Length of the leader line. Leader line extends from each endpoint of the line perpendicular to the line itself. Value can be either positive, negative or zero. If positive, then extension is in plane that is above the annotation line (in clockwise order), if negative, then it is below the annotation line. + + + + + leaderLineOffset + _PDFReal + Length of leader line offset, which is the amount of empty space between the endpoints of the annotation and beginning of leader lines + + + + + leaderLineExtension + _PDFReal + Length of leader line extension, which extends leader lines in 180° direction from leader lines (so leader lines continues above drawn line) + + + + + displayContents + _bool + Display contents of the annotation as text along the line + + + + + displayedContentsTopAlign + _bool + Displayed contents appear above the line, instead inline. + + + 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 + + + + + LL + DictionaryItemSimple + leaderLineLength + + + + + LLO + DictionaryItemSimple + leaderLineOffset + + + + + LLE + DictionaryItemSimple + leaderLineExtension + + + + + Cap + DictionaryItemSimple + displayContents + + + + + CP + DictionaryItemSimple + (displayedContentsTopAlign ? WrapName("Top") : WrapName("Inline")) + + + + 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; @@ -1429,6 +1813,561 @@ return annotationReference; 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 + + + + + polygon + _QPolygonF + Polygon + + + + + borderWidth + _PDFReal + Border line width + + + + + fillColor + _QColor + Fill color + + + + + strokeColor + _QColor + Stroke color + + + + + title + _QString + Title + + + + + subject + _QString + Subject + + + + + contents + _QString + Contents + + + Parameters + + _void + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Annot") + + + + + Subtype + DictionaryItemSimple + WrapName("Polygon") + + + + + Rect + DictionaryItemSimple + polygon.boundingRect() + + + + + F + DictionaryItemSimple + 4 + + + + + P + DictionaryItemSimple + page + + + + + Vertices + DictionaryItemSimple + polygon + + + + + 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(polygon.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 + createAnnotationPolygon + Polygon annotation. When opened, they display pop-up window containing the text of associated note (and window title). Polygon border/fill color can be defined, along with border width. + _PDFObjectReference + + + + + + + + + + + page + _PDFObjectReference + Page to which is annotation added + + + + + polyline + _QPolygonF + Polyline + + + + + borderWidth + _PDFReal + Border line width + + + + + fillColor + _QColor + Fill color + + + + + strokeColor + _QColor + Stroke color + + + + + title + _QString + Title + + + + + subject + _QString + Subject + + + + + contents + _QString + Contents + + + + + startLineType + _AnnotationLineEnding + Start line ending type + + + + + endLineType + _AnnotationLineEnding + End line ending type + + + Parameters + + _void + + + + + + + + + + + + Type + DictionaryItemSimple + WrapName("Annot") + + + + + Subtype + DictionaryItemSimple + WrapName("PolyLine") + + + + + Rect + DictionaryItemSimple + polyline.boundingRect() + + + + + F + DictionaryItemSimple + 4 + + + + + P + DictionaryItemSimple + page + + + + + Vertices + DictionaryItemSimple + polyline + + + + + 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 + + + + + + + + + ArraySimple + startLineType;endLineType + + + + DictionaryItemComplex + + + + + Dictionary + + + + CreateObject + annotationObject + _PDFObjectReference + + + + + + Code + + _void + PDFObjectReference popupAnnotation = createAnnotationPopup(page, annotationObject, getPopupWindowRect(polyline.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 + createAnnotationPolyline + Polyline annotation. When opened, they display pop-up window containing the text of associated note (and window title). Polyline border/fill color can be defined, along with border width. + _PDFObjectReference +