Some more actions

This commit is contained in:
Jakub Melka 2020-11-14 18:38:39 +01:00
parent 9a8429123b
commit e06148fa8c
4 changed files with 2750 additions and 881 deletions

View File

@ -141,6 +141,8 @@ public:
_PDFObjectReference, _PDFObjectReference,
_PDFObject, _PDFObject,
_PDFIntegerVector, _PDFIntegerVector,
_PDFObjectReferenceVector,
_PDFFormSubmitFlags,
_QString, _QString,
_QPointF, _QPointF,
_QRectF, _QRectF,

View File

@ -1460,6 +1460,94 @@ PDFObjectReference PDFDocumentBuilder::createActionGoToRemote(PDFObjectReference
} }
PDFObjectReference PDFDocumentBuilder::createActionHide(PDFObjectReference annotation,
bool hide)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Hide");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("T");
objectBuilder << annotation;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("H");
objectBuilder << hide;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionHide(QString field,
bool hide)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Hide");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("T");
objectBuilder << field;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("H");
objectBuilder << hide;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionImportData(PDFObjectReference fileSpecification)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("ImportData");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("F");
objectBuilder << fileSpecification;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionJavaScript(QString code)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("JavaScript");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("JS");
objectBuilder << code;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionLaunch(PDFObjectReference fileSpecification, PDFObjectReference PDFDocumentBuilder::createActionLaunch(PDFObjectReference fileSpecification,
bool newWindow) bool newWindow)
{ {
@ -1524,6 +1612,322 @@ PDFObjectReference PDFDocumentBuilder::createActionLaunchWin(QByteArray fileName
} }
PDFObjectReference PDFDocumentBuilder::createActionNamed(QByteArray name)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Named");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("N");
objectBuilder << WrapName(name);
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionNavigateFirstPage()
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Named");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("N");
objectBuilder << WrapName("FirstPage");
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionNavigateLastPage()
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Named");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("N");
objectBuilder << WrapName("LastPage");
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionNavigateNextPage()
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Named");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("N");
objectBuilder << WrapName("NextPage");
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionNavigatePrevPage()
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Named");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("N");
objectBuilder << WrapName("PrevPage");
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionResetForm()
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("ResetForm");
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionResetFormExcludedFields(PDFObjectReferenceVector fields)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("ResetForm");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Fields");
objectBuilder << fields;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Flags");
objectBuilder << 1;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionResetFormFields(PDFObjectReferenceVector fields)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("ResetForm");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Fields");
objectBuilder << fields;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionSubmitForm(QString URL,
PDFFormSubmitFlags flags)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("SubmitForm");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("F");
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("UF");
objectBuilder << URL;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Flags");
objectBuilder << flags;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionSubmitForm(QString URL,
PDFObjectReferenceVector fields,
PDFFormSubmitFlags flags)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("SubmitForm");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("F");
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("UF");
objectBuilder << URL;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Fields");
objectBuilder << fields;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Flags");
objectBuilder << flags;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionThread(PDFObjectReference thread,
PDFObjectReference bead)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Thread");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("D");
objectBuilder << thread;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("B");
objectBuilder << bead;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionThread(PDFObjectReference fileSpecification,
PDFInteger thread,
PDFInteger bead)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Thread");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("F");
objectBuilder << fileSpecification;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("D");
objectBuilder << thread;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("B");
objectBuilder << bead;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionThread(PDFObjectReference fileSpecification,
PDFInteger thread)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Thread");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("F");
objectBuilder << fileSpecification;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("D");
objectBuilder << thread;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionThread(PDFObjectReference thread)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Action");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("S");
objectBuilder << WrapName("Thread");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("D");
objectBuilder << thread;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference actionReference = addObject(objectBuilder.takeObject());
return actionReference;
}
PDFObjectReference PDFDocumentBuilder::createActionURI(QString URL) PDFObjectReference PDFDocumentBuilder::createActionURI(QString URL)
{ {
PDFObjectFactory objectBuilder; PDFObjectFactory objectBuilder;
@ -1724,68 +2128,6 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationFileAttachment(PDFObjectR
} }
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);
updateAnnotationAppearanceStreams(annotationObject);
return annotationObject;
}
PDFObjectReference PDFDocumentBuilder::createAnnotationFreeText(PDFObjectReference page, PDFObjectReference PDFDocumentBuilder::createAnnotationFreeText(PDFObjectReference page,
QRectF boundingRectangle, QRectF boundingRectangle,
QRectF textRectangle, QRectF textRectangle,
@ -1952,6 +2294,68 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationFreeText(PDFObjectReferen
} }
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);
updateAnnotationAppearanceStreams(annotationObject);
return annotationObject;
}
PDFObjectReference PDFDocumentBuilder::createAnnotationHighlight(PDFObjectReference page, PDFObjectReference PDFDocumentBuilder::createAnnotationHighlight(PDFObjectReference page,
QRectF rectangle, QRectF rectangle,
QColor color, QColor color,
@ -2389,6 +2793,17 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationLine(PDFObjectReference p
} }
PDFObjectReference PDFDocumentBuilder::createAnnotationLink(PDFObjectReference page,
QRectF linkRectangle,
QString URL,
LinkHighlightMode highlightMode)
{
PDFObjectFactory objectBuilder;
return createAnnotationLink(page, linkRectangle, createActionURI(URL), highlightMode);
}
PDFObjectReference PDFDocumentBuilder::createAnnotationLink(PDFObjectReference page, PDFObjectReference PDFDocumentBuilder::createAnnotationLink(PDFObjectReference page,
QRectF linkRectangle, QRectF linkRectangle,
PDFObjectReference action, PDFObjectReference action,
@ -2431,17 +2846,6 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationLink(PDFObjectReference p
} }
PDFObjectReference PDFDocumentBuilder::createAnnotationLink(PDFObjectReference page,
QRectF linkRectangle,
QString URL,
LinkHighlightMode highlightMode)
{
PDFObjectFactory objectBuilder;
return createAnnotationLink(page, linkRectangle, createActionURI(URL), highlightMode);
}
PDFObjectReference PDFDocumentBuilder::createAnnotationPolygon(PDFObjectReference page, PDFObjectReference PDFDocumentBuilder::createAnnotationPolygon(PDFObjectReference page,
QPolygonF polygon, QPolygonF polygon,
PDFReal borderWidth, PDFReal borderWidth,
@ -2697,6 +3101,55 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationSquare(PDFObjectReference
} }
PDFObjectReference PDFDocumentBuilder::createAnnotationSquiggly(PDFObjectReference page,
QRectF rectangle,
QColor color)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Annot");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Subtype");
objectBuilder << WrapName("Squiggly");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Rect");
objectBuilder << rectangle;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("P");
objectBuilder << page;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("CreationDate");
objectBuilder << WrapCurrentDateTime();
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("C");
objectBuilder << color;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("QuadPoints");
objectBuilder.beginArray();
objectBuilder << rectangle.bottomLeft();
objectBuilder << rectangle.bottomRight();
objectBuilder << rectangle.topLeft();
objectBuilder << rectangle.topRight();
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);
updateAnnotationAppearanceStreams(annotationObject);
return annotationObject;
}
PDFObjectReference PDFDocumentBuilder::createAnnotationSquiggly(PDFObjectReference page, PDFObjectReference PDFDocumentBuilder::createAnnotationSquiggly(PDFObjectReference page,
QRectF rectangle, QRectF rectangle,
QColor color, QColor color,
@ -2761,55 +3214,6 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationSquiggly(PDFObjectReferen
} }
PDFObjectReference PDFDocumentBuilder::createAnnotationSquiggly(PDFObjectReference page,
QRectF rectangle,
QColor color)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Annot");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Subtype");
objectBuilder << WrapName("Squiggly");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Rect");
objectBuilder << rectangle;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("P");
objectBuilder << page;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("CreationDate");
objectBuilder << WrapCurrentDateTime();
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("C");
objectBuilder << color;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("QuadPoints");
objectBuilder.beginArray();
objectBuilder << rectangle.bottomLeft();
objectBuilder << rectangle.bottomRight();
objectBuilder << rectangle.topLeft();
objectBuilder << rectangle.topRight();
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);
updateAnnotationAppearanceStreams(annotationObject);
return annotationObject;
}
PDFObjectReference PDFDocumentBuilder::createAnnotationStamp(PDFObjectReference page, PDFObjectReference PDFDocumentBuilder::createAnnotationStamp(PDFObjectReference page,
QRectF rectangle, QRectF rectangle,
Stamp stampType, Stamp stampType,
@ -3052,55 +3456,6 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationText(PDFObjectReference p
} }
PDFObjectReference PDFDocumentBuilder::createAnnotationUnderline(PDFObjectReference page,
QRectF rectangle,
QColor color)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Annot");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Subtype");
objectBuilder << WrapName("Underline");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Rect");
objectBuilder << rectangle;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("P");
objectBuilder << page;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("CreationDate");
objectBuilder << WrapCurrentDateTime();
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("C");
objectBuilder << color;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("QuadPoints");
objectBuilder.beginArray();
objectBuilder << rectangle.bottomLeft();
objectBuilder << rectangle.bottomRight();
objectBuilder << rectangle.topLeft();
objectBuilder << rectangle.topRight();
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);
updateAnnotationAppearanceStreams(annotationObject);
return annotationObject;
}
PDFObjectReference PDFDocumentBuilder::createAnnotationUnderline(PDFObjectReference page, PDFObjectReference PDFDocumentBuilder::createAnnotationUnderline(PDFObjectReference page,
QRectF rectangle, QRectF rectangle,
QColor color, QColor color,
@ -3165,6 +3520,55 @@ PDFObjectReference PDFDocumentBuilder::createAnnotationUnderline(PDFObjectRefere
} }
PDFObjectReference PDFDocumentBuilder::createAnnotationUnderline(PDFObjectReference page,
QRectF rectangle,
QColor color)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("Type");
objectBuilder << WrapName("Annot");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Subtype");
objectBuilder << WrapName("Underline");
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("Rect");
objectBuilder << rectangle;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("P");
objectBuilder << page;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("CreationDate");
objectBuilder << WrapCurrentDateTime();
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("C");
objectBuilder << color;
objectBuilder.endDictionaryItem();
objectBuilder.beginDictionaryItem("QuadPoints");
objectBuilder.beginArray();
objectBuilder << rectangle.bottomLeft();
objectBuilder << rectangle.bottomRight();
objectBuilder << rectangle.topLeft();
objectBuilder << rectangle.topRight();
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);
updateAnnotationAppearanceStreams(annotationObject);
return annotationObject;
}
PDFObjectReference PDFDocumentBuilder::createCatalog() PDFObjectReference PDFDocumentBuilder::createCatalog()
{ {
PDFObjectFactory objectBuilder; PDFObjectFactory objectBuilder;
@ -3264,20 +3668,6 @@ PDFObjectReference PDFDocumentBuilder::createDocumentPartRoot()
} }
PDFObjectReference PDFDocumentBuilder::createFileSpecification(QString fileName)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("UF");
objectBuilder << fileName;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference fileSpecification = addObject(objectBuilder.takeObject());
return fileSpecification;
}
PDFObjectReference PDFDocumentBuilder::createFileSpecification(QString fileName, PDFObjectReference PDFDocumentBuilder::createFileSpecification(QString fileName,
QString description) QString description)
{ {
@ -3296,6 +3686,20 @@ PDFObjectReference PDFDocumentBuilder::createFileSpecification(QString fileName,
} }
PDFObjectReference PDFDocumentBuilder::createFileSpecification(QString fileName)
{
PDFObjectFactory objectBuilder;
objectBuilder.beginDictionary();
objectBuilder.beginDictionaryItem("UF");
objectBuilder << fileName;
objectBuilder.endDictionaryItem();
objectBuilder.endDictionary();
PDFObjectReference fileSpecification = addObject(objectBuilder.takeObject());
return fileSpecification;
}
PDFObject PDFDocumentBuilder::createTrailerDictionary(PDFObjectReference catalog) PDFObject PDFDocumentBuilder::createTrailerDictionary(PDFObjectReference catalog)
{ {
PDFObjectFactory objectBuilder; PDFObjectFactory objectBuilder;

View File

@ -28,6 +28,8 @@ namespace pdf
{ {
using PDFIntegerVector = std::vector<PDFInteger>; using PDFIntegerVector = std::vector<PDFInteger>;
using PDFObjectReferenceVector = std::vector<PDFObjectReference>;
using PDFFormSubmitFlags = PDFActionSubmitForm::SubmitFlags;
struct WrapName struct WrapName
{ {
@ -397,6 +399,30 @@ public:
bool newWindow); bool newWindow);
/// Creates hide action. Hide action toggles hide/show state of field or annotation.
/// \param annotation Annotation
/// \param hide Hide (true) or show (false)
PDFObjectReference createActionHide(PDFObjectReference annotation,
bool hide);
/// Creates hide action. Hide action toggles hide/show state of field or annotation.
/// \param field Fully qualified name of a form field
/// \param hide Hide (true) or show (false)
PDFObjectReference createActionHide(QString field,
bool hide);
/// Creates import data action for interactive form.
/// \param fileSpecification Data file
PDFObjectReference createActionImportData(PDFObjectReference fileSpecification);
/// Creates JavaScript action.
/// \param code JavaScript code
PDFObjectReference createActionJavaScript(QString code);
/// Creates launch action. Launch action executes document opening or printing. /// Creates launch action. Launch action executes document opening or printing.
/// \param fileSpecification File specification /// \param fileSpecification File specification
/// \param newWindow Open document in new window /// \param newWindow Open document in new window
@ -418,6 +444,87 @@ public:
bool newWindow); bool newWindow);
/// 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);
/// Creates action which navigates to a first page.
PDFObjectReference createActionNavigateFirstPage();
/// Creates action which navigates to a last page.
PDFObjectReference createActionNavigateLastPage();
/// Creates action which navigates to a next page.
PDFObjectReference createActionNavigateNextPage();
/// Creates action which navigates to a previous page.
PDFObjectReference createActionNavigatePrevPage();
/// Creates reset interactive form action.
PDFObjectReference createActionResetForm();
/// 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);
/// Creates reset interactive form action, which resets a given list of fields.
/// \param fields Fields to be reset
PDFObjectReference createActionResetFormFields(PDFObjectReferenceVector fields);
/// Creates submit form action.
/// \param URL Web link to server script, which will process the form
/// \param flags Flags
PDFObjectReference createActionSubmitForm(QString URL,
PDFFormSubmitFlags flags);
/// Creates submit form action.
/// \param URL Web link to server script, which will process the form
/// \param fields Sumbitted fields
/// \param flags Flags
PDFObjectReference createActionSubmitForm(QString URL,
PDFObjectReferenceVector fields,
PDFFormSubmitFlags flags);
/// Creates thread action for thread in current file. When executed, viewer jumps to a specific thread.
/// \param thread Thread
/// \param bead Bead
PDFObjectReference createActionThread(PDFObjectReference thread,
PDFObjectReference bead);
/// Creates thread action. When executed, viewer jumps to a specific thread.
/// \param fileSpecification File containing the thread
/// \param thread Thread index
/// \param bead Bead index
PDFObjectReference createActionThread(PDFObjectReference fileSpecification,
PDFInteger thread,
PDFInteger bead);
/// Creates thread action. When executed, viewer jumps to a specific thread.
/// \param fileSpecification File containing the thread
/// \param thread Thread index
PDFObjectReference createActionThread(PDFObjectReference fileSpecification,
PDFInteger thread);
/// Creates thread action for thread in current file. When executed, viewer jumps to a specific thread.
/// \param thread Thread
PDFObjectReference createActionThread(PDFObjectReference thread);
/// Creates URI action. /// Creates URI action.
/// \param URL Target URL /// \param URL Target URL
PDFObjectReference createActionURI(QString URL); PDFObjectReference createActionURI(QString URL);
@ -479,23 +586,6 @@ public:
QString description); 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.
/// \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 /// 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 /// 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 /// the document. Free text annotation can also have callout line, with, or without a knee. Specify
@ -558,6 +648,23 @@ public:
AnnotationLineEnding endLineType); 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.
/// \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);
/// Text markup annotation is used to highlight text. It is a markup annotation, so it can contain /// 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 /// 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. /// also highlight other things, such as images, or other graphics.
@ -698,11 +805,11 @@ public:
/// location in document). /// location in document).
/// \param page Page to which is annotation added /// \param page Page to which is annotation added
/// \param linkRectangle Link rectangle /// \param linkRectangle Link rectangle
/// \param action Action to be performed when user clicks on a link /// \param URL URL to be launched when user clicks on the link
/// \param highlightMode Highlight mode /// \param highlightMode Highlight mode
PDFObjectReference createAnnotationLink(PDFObjectReference page, PDFObjectReference createAnnotationLink(PDFObjectReference page,
QRectF linkRectangle, QRectF linkRectangle,
PDFObjectReference action, QString URL,
LinkHighlightMode highlightMode); LinkHighlightMode highlightMode);
@ -711,11 +818,11 @@ public:
/// location in document). /// location in document).
/// \param page Page to which is annotation added /// \param page Page to which is annotation added
/// \param linkRectangle Link rectangle /// \param linkRectangle Link rectangle
/// \param URL URL to be launched when user clicks on the link /// \param action Action to be performed when user clicks on a link
/// \param highlightMode Highlight mode /// \param highlightMode Highlight mode
PDFObjectReference createAnnotationLink(PDFObjectReference page, PDFObjectReference createAnnotationLink(PDFObjectReference page,
QRectF linkRectangle, QRectF linkRectangle,
QString URL, PDFObjectReference action,
LinkHighlightMode highlightMode); LinkHighlightMode highlightMode);
@ -802,6 +909,16 @@ public:
QString contents); 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).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is markup displayed
/// \param color Color
PDFObjectReference createAnnotationSquiggly(PDFObjectReference page,
QRectF rectangle,
QColor color);
/// Text markup annotation is used to squiggly underline text. It is a markup annotation, so it can /// Text markup annotation is used to squiggly underline text. It is a markup annotation, so it can
/// contain window to be opened (and commented). /// contain window to be opened (and commented).
/// \param page Page to which is annotation added /// \param page Page to which is annotation added
@ -818,16 +935,6 @@ public:
QString contents); 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).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is markup displayed
/// \param color Color
PDFObjectReference createAnnotationSquiggly(PDFObjectReference page,
QRectF rectangle,
QColor color);
/// Stamp annotation /// Stamp annotation
/// \param page Page to which is annotation added /// \param page Page to which is annotation added
/// \param rectangle Stamp area /// \param rectangle Stamp area
@ -890,16 +997,6 @@ public:
bool open); 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).
/// \param page Page to which is annotation added
/// \param rectangle Area in which is markup displayed
/// \param color Color
PDFObjectReference createAnnotationUnderline(PDFObjectReference page,
QRectF rectangle,
QColor color);
/// Text markup annotation is used to underline text. It is a markup annotation, so it can contain /// Text markup annotation is used to underline text. It is a markup annotation, so it can contain
/// window to be opened (and commented). /// window to be opened (and commented).
/// \param page Page to which is annotation added /// \param page Page to which is annotation added
@ -916,6 +1013,16 @@ public:
QString contents); QString contents);
/// 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
PDFObjectReference createAnnotationUnderline(PDFObjectReference page,
QRectF rectangle,
QColor color);
/// Creates empty catalog. This function is used, when a new document is being created. Do not call /// Creates empty catalog. This function is used, when a new document is being created. Do not call
/// this function manually. /// this function manually.
PDFObjectReference createCatalog(); PDFObjectReference createCatalog();
@ -941,14 +1048,14 @@ public:
/// Creates file specification for external file. /// Creates file specification for external file.
/// \param fileName File name /// \param fileName File name
PDFObjectReference createFileSpecification(QString fileName); /// \param description Description
PDFObjectReference createFileSpecification(QString fileName,
QString description);
/// Creates file specification for external file. /// Creates file specification for external file.
/// \param fileName File name /// \param fileName File name
/// \param description Description PDFObjectReference createFileSpecification(QString fileName);
PDFObjectReference createFileSpecification(QString fileName,
QString description);
/// This function is used to create a new trailer dictionary, when blank document is created. Do not /// This function is used to create a new trailer dictionary, when blank document is created. Do not

File diff suppressed because it is too large Load Diff