Issue #40: Sanitize document

This commit is contained in:
Jakub Melka
2023-02-19 18:36:46 +01:00
parent 4a603c80c0
commit 361ee247e5
19 changed files with 1089 additions and 243 deletions

View File

@ -323,6 +323,9 @@ public:
/// Creates a new document as modification of old document
explicit PDFDocumentBuilder(const PDFDocument* document);
/// Creates a new document from storage
explicit PDFDocumentBuilder(const PDFObjectStorage& storage, PDFVersion version);
/// Resets the object to the initial state.
/// \warning All data are lost
void reset();
@ -491,8 +494,8 @@ public:
PDFObjectReference createActionGoToDocumentPart(PDFObjectReference documentPart);
/// Creates embedded GoTo action. When executed, action points to destination in another document,
/// which is embedded in this document.
/// Creates embedded GoTo action. When executed, action points to destination in another document, which
/// is embedded in this document.
/// \param fileSpecification File specification
/// \param destination Destination in a embedded document
/// \param newWindow Open document in new window
@ -541,8 +544,8 @@ public:
bool newWindow);
/// Creates launch action. Launch action executes document opening or printing. This variant for
/// Windows operating system, where additional parameters can be specified.
/// Creates launch action. Launch action executes document opening or printing. This variant for Windows
/// operating system, where additional parameters can be specified.
/// \param fileName File name
/// \param defaultDirectory Default directory
/// \param action Action to be performed. Valid values are 'open' or 'print'.
@ -555,8 +558,8 @@ public:
bool newWindow);
/// Creates named action. Named actions are some predefined actions that interactive PDF processor
/// shall support. Valid values are NextPage, PrevPage, FirstPage, LastPage.
/// Creates named action. Named actions are some predefined actions that interactive PDF processor shall
/// support. Valid values are NextPage, PrevPage, FirstPage, LastPage.
/// \param name Predefined name
PDFObjectReference createActionNamed(QByteArray name);
@ -581,8 +584,7 @@ public:
PDFObjectReference createActionResetForm();
/// Creates reset interactive form action, which resets all fields except those specified in a given list of
/// fields.
/// Creates reset interactive form action, which resets all fields except those specified in a given list of fields.
/// \param fields Fields to be excluded from reset
PDFObjectReference createActionResetFormExcludedFields(PDFObjectReferenceVector fields);
@ -641,9 +643,8 @@ public:
PDFObjectReference createActionURI(QString URL);
/// Caret annotations are used to indicate, where text should be inserted (for example, if reviewer
/// reviews the document, and he wants to mark, that some text should be inserted, he uses this
/// annotation).
/// Caret annotations are used to indicate, where text should be inserted (for example, if reviewer reviews the
/// document, and he wants to mark, that some text should be inserted, he uses this annotation).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is caret displayed
/// \param borderWidth Border width
@ -660,15 +661,15 @@ public:
QString contents);
/// Circle annotation displays ellipse (or circle). Circle border/fill color can be defined, along with
/// border width. Popup annotation can be attached to this annotation.
/// Circle annotation displays ellipse (or circle). Circle border/fill color can be defined, along with border
/// width. Popup annotation can be attached to this annotation.
/// \param page Page to which is annotation added
/// \param rectangle Area in which is circle/ellipse displayed
/// \param borderWidth Width of the border line of circle/ellipse
/// \param fillColor Fill color of rectangle (interior color). If you do not want to have area color filled,
/// \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 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)
@ -697,15 +698,15 @@ public:
QString description);
/// 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.
/// 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 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)
@ -729,9 +730,9 @@ public:
AnnotationLineEnding endLineType);
/// 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.
/// 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
@ -746,15 +747,15 @@ public:
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.
/// 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 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)
@ -776,9 +777,9 @@ public:
AnnotationLineEnding endLineType);
/// Text markup annotation is used to highlight text. It is a markup annotation, so it can contain
/// window to be opened (and commented). This annotation is usually used to highlight text, but can
/// also highlight other things, such as images, or other graphics.
/// Text markup annotation is used to highlight text. It is a markup annotation, so it can contain window to
/// be opened (and commented). This annotation is usually used to highlight text, but can also highlight
/// other things, such as images, or other graphics.
/// \param page Page to which is annotation added
/// \param rectangle Area in which is highlight displayed
/// \param color Color
@ -793,9 +794,9 @@ public:
QString contents);
/// Text markup annotation is used to highlight text. It is a markup annotation, so it can contain
/// window to be opened (and commented). This annotation is usually used to highlight text, but can
/// also highlight other things, such as images, or other graphics.
/// Text markup annotation is used to highlight text. It is a markup annotation, so it can contain window to
/// be opened (and commented). This annotation is usually used to highlight text, but can also highlight
/// other things, such as images, or other graphics.
/// \param page Page to which is annotation added
/// \param rectangle Area in which is highlight displayed
/// \param color Color
@ -804,9 +805,9 @@ public:
QColor color);
/// Text markup annotation is used to highlight text. It is a markup annotation, so it can contain
/// window to be opened (and commented). This annotation is usually used to highlight text, but can
/// also highlight other things, such as images, or other graphics.
/// Text markup annotation is used to highlight text. It is a markup annotation, so it can contain window to
/// be opened (and commented). This annotation is usually used to highlight text, but can also highlight
/// other things, such as images, or other graphics.
/// \param page Page to which is annotation added
/// \param quadrilaterals Area in which is highlight displayed
/// \param color Color
@ -849,9 +850,9 @@ public:
QString contents);
/// 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.
/// 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
@ -878,9 +879,9 @@ 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.
/// 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
@ -893,12 +894,12 @@ public:
/// \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 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
@ -922,9 +923,9 @@ public:
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).
/// 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
@ -935,9 +936,9 @@ public:
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).
/// 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
@ -948,9 +949,9 @@ public:
LinkHighlightMode highlightMode);
/// Polygon annotation. When opened, they display pop-up window containing the text of associated
/// note (and window title), if popup annotation is attached. Polygon border/fill color can be defined,
/// along with border width.
/// Polygon annotation. When opened, they display pop-up window containing the text of associated note
/// (and window title), if popup annotation is attached. 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
@ -969,9 +970,9 @@ public:
QString contents);
/// Polyline annotation. When opened, they display pop-up window containing the text of associated
/// note (and window title), if popup annotation is attached. Polyline border/fill color can be defined,
/// along with border width.
/// Polyline annotation. When opened, they display pop-up window containing the text of associated note
/// (and window title), if popup annotation is attached. 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
@ -995,9 +996,9 @@ public:
/// 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.
/// 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
@ -1026,16 +1027,16 @@ public:
QColor color);
/// Square annotation displays rectangle (or square). When opened, they display pop-up window
/// containing the text of associated note (and window title), if popup annotation is attached. Square
/// border/fill color can be defined, along with border width.
/// Square annotation displays rectangle (or square). When opened, they display pop-up window containing
/// the text of associated note (and window title), if popup annotation is attached. 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,
/// \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 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)
@ -1049,8 +1050,8 @@ public:
QString contents);
/// Text markup annotation is used to squiggly underline text. It is a markup annotation, so it can
/// contain window to be opened (and commented).
/// Text markup annotation is used to squiggly underline text. It is a markup annotation, so it can contain
/// window to be opened (and commented).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is markup displayed
/// \param color Color
@ -1059,8 +1060,8 @@ public:
QColor color);
/// Text markup annotation is used to squiggly underline text. It is a markup annotation, so it can
/// contain window to be opened (and commented).
/// Text markup annotation is used to squiggly underline text. It is a markup annotation, so it can contain
/// window to be opened (and commented).
/// \param page Page to which is annotation added
/// \param quadrilaterals Area in which is markup displayed
/// \param color Color
@ -1069,8 +1070,8 @@ public:
QColor color);
/// Text markup annotation is used to squiggly underline text. It is a markup annotation, so it can
/// contain window to be opened (and commented).
/// Text markup annotation is used to squiggly underline text. It is a markup annotation, so it can contain
/// window to be opened (and commented).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is markup displayed
/// \param color Color
@ -1100,8 +1101,8 @@ public:
QString contents);
/// Text markup annotation is used to strikeout text. It is a markup annotation, so it can contain
/// window to be opened (and commented).
/// Text markup annotation is used to strikeout text. It is a markup annotation, so it can contain window to
/// be opened (and commented).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is markup displayed
/// \param color Color
@ -1116,8 +1117,8 @@ public:
QString contents);
/// Text markup annotation is used to strikeout text. It is a markup annotation, so it can contain
/// window to be opened (and commented).
/// Text markup annotation is used to strikeout text. It is a markup annotation, so it can contain window to
/// be opened (and commented).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is markup displayed
/// \param color Color
@ -1126,8 +1127,8 @@ public:
QColor color);
/// Text markup annotation is used to strikeout text. It is a markup annotation, so it can contain
/// window to be opened (and commented).
/// Text markup annotation is used to strikeout text. It is a markup annotation, so it can contain window to
/// be opened (and commented).
/// \param page Page to which is annotation added
/// \param quadrilaterals Area in which is markup displayed
/// \param color Color
@ -1136,11 +1137,10 @@ public:
QColor color);
/// 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. Popup annotation is automatically created
/// for this annotation.
/// 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. Popup annotation is automatically created for this annotation.
/// \param page Page to which is annotation added
/// \param rectangle Area in which is icon displayed
/// \param iconType Icon type
@ -1157,8 +1157,8 @@ public:
bool open);
/// Text markup annotation is used to underline text. It is a markup annotation, so it can contain
/// window to be opened (and commented).
/// Text markup annotation is used to underline text. It is a markup annotation, so it can contain window to
/// be opened (and commented).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is markup displayed
/// \param color Color
@ -1167,8 +1167,8 @@ public:
QColor color);
/// Text markup annotation is used to underline text. It is a markup annotation, so it can contain
/// window to be opened (and commented).
/// Text markup annotation is used to underline text. It is a markup annotation, so it can contain window to
/// be opened (and commented).
/// \param page Page to which is annotation added
/// \param quadrilaterals Area in which is markup displayed
/// \param color Color
@ -1177,8 +1177,8 @@ public:
QColor color);
/// Text markup annotation is used to underline text. It is a markup annotation, so it can contain
/// window to be opened (and commented).
/// Text markup annotation is used to underline text. It is a markup annotation, so it can contain window to
/// be opened (and commented).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is markup displayed
/// \param color Color
@ -1193,13 +1193,13 @@ public:
QString contents);
/// Creates empty catalog. This function is used, when a new document is being created. Do not call
/// this function manually.
/// 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.
/// 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();
@ -1258,8 +1258,7 @@ public:
/// Creates signature dictionary used for preparation in signing process. Can define parameters of the
/// signature.
/// \param filter Filter (for example, Adobe.PPKLite, Entrust.PPKEF, CiCi.SignIt, ...)
/// \param subfilter Subfilter (for example, adbe.pkcs7.detached, adbe.pkcs7.sha1,
/// ETSI.CAdES.detached, ...)
/// \param subfilter Subfilter (for example, adbe.pkcs7.detached, adbe.pkcs7.sha1, ETSI.CAdES.detached, ...)
/// \param contents Contents (reserved data for signature).
/// \param signingTime Signing date/time
/// \param byteRangeItem Item which will fill byte range array.
@ -1270,8 +1269,8 @@ public:
PDFInteger byteRangeItem);
/// This function is used to create a new trailer dictionary, when blank document is created. Do not
/// call this function manually.
/// 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);
@ -1358,9 +1357,9 @@ public:
bool isOpen);
/// Sets annotation quadrilaterals. Quadrilaterals are sequence of 4 points, where first two points are
/// on the upper side of quadrilateral, and the last two points are on the lower side of quadrilateral.
/// Quadrilaterals are represented as unclosed polygon with 4 * n vertices.
/// Sets annotation quadrilaterals. Quadrilaterals are sequence of 4 points, where first two points are on the
/// upper side of quadrilateral, and the last two points are on the lower side of quadrilateral. Quadrilaterals
/// are represented as unclosed polygon with 4 * n vertices.
/// \param annotation Annotation
/// \param quadrilaterals Quadrilaterals
void setAnnotationQuadPoints(PDFObjectReference annotation,
@ -1461,9 +1460,9 @@ public:
PDFInteger topIndex);
/// Sets form field value. Value must be correct for this form field, no checking is performed. Also, if
/// you use this function, annotation widgets, which are attached to this form field, should also be
/// updated (for example, appearance state and sometimes appearance streams).
/// Sets form field value. Value must be correct for this form field, no checking is performed. Also, if you use
/// this function, annotation widgets, which are attached to this form field, should also be updated (for
/// example, appearance state and sometimes appearance streams).
/// \param formField Form field
/// \param value Value
void setFormFieldValue(PDFObjectReference formField,
@ -1476,9 +1475,9 @@ public:
/// Set document language.
/// \param language Document language. It should be a language identifier, as defined in ISO 639
/// and ISO 3166. For example, "en-US", where first two letter means language code (en =
/// english), and the latter two is country code (US - United States).
/// \param language Document language. It should be a language identifier, as defined in ISO 639 and
/// ISO 3166. For example, "en-US", where first two letter means language code (en = english), and
/// the latter two is country code (US - United States).
void setLanguage(QString language);
@ -1494,17 +1493,16 @@ public:
QRectF box);
/// Sets bleed box to the page. Bleed box is, basically, a clipping box for output in a production
/// environment. Default value is the page's crop box.
/// Sets bleed box to the page. Bleed box is, basically, a clipping box for output in a production environment.
/// Default value is the page's crop box.
/// \param page Page
/// \param box Box
void setPageBleedBox(PDFObjectReference page,
QRectF box);
/// Sets crop box to the page. Crop box defines clipping region of the page. Page contents are clipped
/// to this region, graphics outside of clipping box will not be printed. Default value is same, as media
/// box.
/// Sets crop box to the page. Crop box defines clipping region of the page. Page contents are clipped to
/// this region, graphics outside of clipping box will not be printed. Default value is same, as media box.
/// \param page Page
/// \param box Box
void setPageCropBox(PDFObjectReference page,
@ -1518,8 +1516,8 @@ public:
PDFObjectReference documentPart);
/// Sets media box to the page. The media box defines size of physical medium, onto which the page
/// is to be printed.
/// Sets media box to the page. The media box defines size of physical medium, onto which the page is to be
/// printed.
/// \param page Page
/// \param box Box
void setPageMediaBox(PDFObjectReference page,
@ -1561,12 +1559,17 @@ public:
QString reasonText);
/// This function is used to update trailer dictionary. Must be called each time the final document is
/// being built.
/// 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);
///
/// \param pageReference Removes page thumbnail.
void removePageThumbnail(PDFObjectReference pageReference);
/* END GENERATED CODE */
private: