2016-09-05 09:57:16 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions defined in
|
|
|
|
* file 'LICENSE.md', which is part of this source code package.
|
|
|
|
*/
|
|
|
|
|
2016-09-08 17:53:45 +00:00
|
|
|
package model
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
import (
|
2017-03-29 16:02:47 +11:00
|
|
|
"errors"
|
2016-09-05 09:57:16 +00:00
|
|
|
"fmt"
|
2016-09-08 17:53:45 +00:00
|
|
|
|
2016-09-05 09:57:16 +00:00
|
|
|
"github.com/unidoc/unidoc/common"
|
2016-09-08 17:53:45 +00:00
|
|
|
. "github.com/unidoc/unidoc/pdf/core"
|
2016-09-05 09:57:16 +00:00
|
|
|
)
|
|
|
|
|
2017-03-01 16:02:53 +00:00
|
|
|
// PDFAnnotation contains common attributes of an annotation. The context object contains the subannotation,
|
|
|
|
// which can be a markup annotation or other types.
|
2016-09-05 09:57:16 +00:00
|
|
|
type PdfAnnotation struct {
|
2016-09-09 15:02:52 +00:00
|
|
|
context PdfModel // Sub-annotation.
|
2016-09-05 09:57:16 +00:00
|
|
|
Rect PdfObject
|
|
|
|
Contents PdfObject
|
|
|
|
P PdfObject // Reference to page object.
|
|
|
|
NM PdfObject
|
|
|
|
M PdfObject
|
|
|
|
F PdfObject
|
|
|
|
AP PdfObject
|
|
|
|
AS PdfObject
|
|
|
|
Border PdfObject
|
|
|
|
C PdfObject
|
|
|
|
StructParent PdfObject
|
|
|
|
OC PdfObject
|
2016-09-11 23:17:38 +00:00
|
|
|
|
|
|
|
primitive *PdfIndirectObject
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
|
2016-09-12 17:59:45 +00:00
|
|
|
// Context in this case is a reference to the subannotation.
|
2016-09-09 15:02:52 +00:00
|
|
|
func (this *PdfAnnotation) GetContext() PdfModel {
|
2016-09-07 17:56:45 +00:00
|
|
|
return this.context
|
|
|
|
}
|
|
|
|
|
2017-03-08 16:49:23 +00:00
|
|
|
// Set the sub annotation (context).
|
|
|
|
func (this *PdfAnnotation) SetContext(ctx PdfModel) {
|
|
|
|
this.context = ctx
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *PdfAnnotation) String() string {
|
|
|
|
s := ""
|
|
|
|
|
|
|
|
obj, ok := this.ToPdfObject().(*PdfIndirectObject)
|
|
|
|
if ok {
|
|
|
|
s = fmt.Sprintf("%T: %s", this.context, obj.PdfObject.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2016-09-13 13:19:05 +00:00
|
|
|
// Additional elements for mark-up annotations.
|
|
|
|
type PdfAnnotationMarkup struct {
|
|
|
|
T PdfObject
|
2016-12-05 16:21:23 +00:00
|
|
|
Popup *PdfAnnotationPopup
|
2016-09-13 13:19:05 +00:00
|
|
|
CA PdfObject
|
|
|
|
RC PdfObject
|
|
|
|
CreationDate PdfObject
|
|
|
|
IRT PdfObject
|
|
|
|
Subj PdfObject
|
|
|
|
RT PdfObject
|
|
|
|
IT PdfObject
|
|
|
|
ExData PdfObject
|
|
|
|
}
|
|
|
|
|
2016-09-05 09:57:16 +00:00
|
|
|
// Subtype: Text
|
|
|
|
type PdfAnnotationText struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
Open PdfObject
|
|
|
|
Name PdfObject
|
|
|
|
State PdfObject
|
|
|
|
StateModel PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Link
|
|
|
|
type PdfAnnotationLink struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-05 09:57:16 +00:00
|
|
|
A PdfObject
|
|
|
|
Dest PdfObject
|
|
|
|
H PdfObject
|
|
|
|
PA PdfObject
|
|
|
|
QuadPoints PdfObject
|
|
|
|
BS PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: FreeText
|
|
|
|
type PdfAnnotationFreeText struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
DA PdfObject
|
|
|
|
Q PdfObject
|
|
|
|
RC PdfObject
|
|
|
|
DS PdfObject
|
|
|
|
CL PdfObject
|
|
|
|
IT PdfObject
|
|
|
|
BE PdfObject
|
|
|
|
RD PdfObject
|
|
|
|
BS PdfObject
|
|
|
|
LE PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Line
|
|
|
|
type PdfAnnotationLine struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
L PdfObject
|
|
|
|
BS PdfObject
|
|
|
|
LE PdfObject
|
|
|
|
IC PdfObject
|
|
|
|
LL PdfObject
|
|
|
|
LLE PdfObject
|
|
|
|
Cap PdfObject
|
|
|
|
IT PdfObject
|
|
|
|
LLO PdfObject
|
|
|
|
CP PdfObject
|
|
|
|
Measure PdfObject
|
|
|
|
CO PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Square
|
|
|
|
type PdfAnnotationSquare struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
BS PdfObject
|
|
|
|
IC PdfObject
|
|
|
|
BE PdfObject
|
|
|
|
RD PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Circle
|
|
|
|
type PdfAnnotationCircle struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
BS PdfObject
|
|
|
|
IC PdfObject
|
|
|
|
BE PdfObject
|
|
|
|
RD PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Polygon
|
|
|
|
type PdfAnnotationPolygon struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
Vertices PdfObject
|
|
|
|
LE PdfObject
|
|
|
|
BS PdfObject
|
|
|
|
IC PdfObject
|
|
|
|
BE PdfObject
|
|
|
|
IT PdfObject
|
|
|
|
Measure PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: PolyLine
|
|
|
|
type PdfAnnotationPolyLine struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
Vertices PdfObject
|
|
|
|
LE PdfObject
|
|
|
|
BS PdfObject
|
|
|
|
IC PdfObject
|
|
|
|
BE PdfObject
|
|
|
|
IT PdfObject
|
|
|
|
Measure PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Highlight
|
|
|
|
type PdfAnnotationHighlight struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
QuadPoints PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Underline
|
|
|
|
type PdfAnnotationUnderline struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
QuadPoints PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Squiggly
|
|
|
|
type PdfAnnotationSquiggly struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
QuadPoints PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: StrikeOut
|
|
|
|
type PdfAnnotationStrikeOut struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
QuadPoints PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Caret
|
|
|
|
type PdfAnnotationCaret struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
RD PdfObject
|
|
|
|
Sy PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Stamp
|
|
|
|
type PdfAnnotationStamp struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
Name PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Ink
|
|
|
|
type PdfAnnotationInk struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
InkList PdfObject
|
|
|
|
BS PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Popup
|
|
|
|
type PdfAnnotationPopup struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-05 09:57:16 +00:00
|
|
|
Parent PdfObject
|
|
|
|
Open PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: FileAttachment
|
|
|
|
type PdfAnnotationFileAttachment struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
FS PdfObject
|
|
|
|
Name PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Sound
|
|
|
|
type PdfAnnotationSound struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
Sound PdfObject
|
|
|
|
Name PdfObject
|
|
|
|
}
|
|
|
|
|
2016-09-13 13:19:05 +00:00
|
|
|
// Subtype: Rich Media
|
|
|
|
type PdfAnnotationRichMedia struct {
|
|
|
|
*PdfAnnotation
|
|
|
|
RichMediaSettings PdfObject
|
|
|
|
RichMediaContent PdfObject
|
|
|
|
}
|
|
|
|
|
2016-09-05 09:57:16 +00:00
|
|
|
// Subtype: Movie
|
|
|
|
type PdfAnnotationMovie struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-05 09:57:16 +00:00
|
|
|
T PdfObject
|
|
|
|
Movie PdfObject
|
|
|
|
A PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Screen
|
|
|
|
type PdfAnnotationScreen struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-05 09:57:16 +00:00
|
|
|
T PdfObject
|
|
|
|
MK PdfObject
|
|
|
|
A PdfObject
|
|
|
|
AA PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Widget
|
|
|
|
type PdfAnnotationWidget struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-05 09:57:16 +00:00
|
|
|
H PdfObject
|
|
|
|
MK PdfObject
|
|
|
|
A PdfObject
|
|
|
|
AA PdfObject
|
|
|
|
BS PdfObject
|
|
|
|
Parent PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: Watermark
|
|
|
|
type PdfAnnotationWatermark struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-05 09:57:16 +00:00
|
|
|
FixedPrint PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: PrinterMark
|
|
|
|
type PdfAnnotationPrinterMark struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-05 09:57:16 +00:00
|
|
|
MN PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: TrapNet
|
|
|
|
type PdfAnnotationTrapNet struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Subtype: 3D
|
|
|
|
type PdfAnnotation3D struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-05 09:57:16 +00:00
|
|
|
T3DD PdfObject
|
|
|
|
T3DV PdfObject
|
|
|
|
T3DA PdfObject
|
|
|
|
T3DI PdfObject
|
|
|
|
T3DB PdfObject
|
|
|
|
}
|
|
|
|
|
2016-09-13 13:19:05 +00:00
|
|
|
// Subtype: Projection
|
|
|
|
type PdfAnnotationProjection struct {
|
|
|
|
*PdfAnnotation
|
|
|
|
*PdfAnnotationMarkup
|
|
|
|
}
|
|
|
|
|
2016-09-12 17:59:45 +00:00
|
|
|
// Subtype: Redact
|
2016-09-05 09:57:16 +00:00
|
|
|
type PdfAnnotationRedact struct {
|
2016-09-11 23:17:38 +00:00
|
|
|
*PdfAnnotation
|
2016-09-13 13:19:05 +00:00
|
|
|
*PdfAnnotationMarkup
|
2016-09-05 09:57:16 +00:00
|
|
|
QuadPoints PdfObject
|
|
|
|
IC PdfObject
|
|
|
|
RO PdfObject
|
|
|
|
OverlayText PdfObject
|
|
|
|
Repeat PdfObject
|
|
|
|
DA PdfObject
|
|
|
|
Q PdfObject
|
|
|
|
}
|
|
|
|
|
2017-03-08 16:49:23 +00:00
|
|
|
// Construct a new PDF annotation model and initializes the underlying PDF primitive.
|
2016-09-11 23:17:38 +00:00
|
|
|
func NewPdfAnnotation() *PdfAnnotation {
|
|
|
|
annot := &PdfAnnotation{}
|
|
|
|
|
|
|
|
container := &PdfIndirectObject{}
|
2017-07-08 21:04:13 +00:00
|
|
|
container.PdfObject = MakeDict()
|
2016-09-11 23:17:38 +00:00
|
|
|
|
|
|
|
annot.primitive = container
|
|
|
|
return annot
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
|
2017-03-31 22:45:11 +00:00
|
|
|
// Create a new text annotation.
|
|
|
|
func NewPdfAnnotationText() *PdfAnnotationText {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
textAnnotation := &PdfAnnotationText{}
|
|
|
|
textAnnotation.PdfAnnotation = annotation
|
|
|
|
textAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(textAnnotation)
|
|
|
|
return textAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new link annotation.
|
|
|
|
func NewPdfAnnotationLink() *PdfAnnotationLink {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
linkAnnotation := &PdfAnnotationLink{}
|
|
|
|
linkAnnotation.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(linkAnnotation)
|
|
|
|
return linkAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new free text annotation.
|
|
|
|
func NewPdfAnnotationFreeText() *PdfAnnotationFreeText {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
freetextAnnotation := &PdfAnnotationFreeText{}
|
|
|
|
freetextAnnotation.PdfAnnotation = annotation
|
|
|
|
freetextAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(freetextAnnotation)
|
|
|
|
return freetextAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new line annotation.
|
|
|
|
func NewPdfAnnotationLine() *PdfAnnotationLine {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
lineAnnotation := &PdfAnnotationLine{}
|
|
|
|
lineAnnotation.PdfAnnotation = annotation
|
|
|
|
lineAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(lineAnnotation)
|
|
|
|
return lineAnnotation
|
|
|
|
}
|
|
|
|
|
2017-03-24 11:31:20 +00:00
|
|
|
// Create a new square annotation.
|
|
|
|
func NewPdfAnnotationSquare() *PdfAnnotationSquare {
|
|
|
|
annotation := NewPdfAnnotation()
|
2017-03-31 22:45:11 +00:00
|
|
|
rectAnnotation := &PdfAnnotationSquare{}
|
|
|
|
rectAnnotation.PdfAnnotation = annotation
|
|
|
|
rectAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
2017-03-24 11:31:20 +00:00
|
|
|
annotation.SetContext(rectAnnotation)
|
|
|
|
return rectAnnotation
|
|
|
|
}
|
|
|
|
|
2017-03-31 22:45:11 +00:00
|
|
|
// Create a new circle annotation.
|
|
|
|
func NewPdfAnnotationCircle() *PdfAnnotationCircle {
|
2017-03-24 11:31:20 +00:00
|
|
|
annotation := NewPdfAnnotation()
|
2017-03-31 22:45:11 +00:00
|
|
|
circAnnotation := &PdfAnnotationCircle{}
|
|
|
|
circAnnotation.PdfAnnotation = annotation
|
|
|
|
circAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(circAnnotation)
|
|
|
|
return circAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new polygon annotation.
|
|
|
|
func NewPdfAnnotationPolygon() *PdfAnnotationPolygon {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
polygonAnnotation := &PdfAnnotationPolygon{}
|
|
|
|
polygonAnnotation.PdfAnnotation = annotation
|
|
|
|
polygonAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(polygonAnnotation)
|
|
|
|
return polygonAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new polyline annotation.
|
|
|
|
func NewPdfAnnotationPolyLine() *PdfAnnotationPolyLine {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
polylineAnnotation := &PdfAnnotationPolyLine{}
|
|
|
|
polylineAnnotation.PdfAnnotation = annotation
|
|
|
|
polylineAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(polylineAnnotation)
|
|
|
|
return polylineAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new text highlight annotation.
|
|
|
|
func NewPdfAnnotationHighlight() *PdfAnnotationHighlight {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
highlightAnnotation := &PdfAnnotationHighlight{}
|
|
|
|
highlightAnnotation.PdfAnnotation = annotation
|
|
|
|
highlightAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(highlightAnnotation)
|
|
|
|
return highlightAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new text underline annotation.
|
|
|
|
func NewPdfAnnotationUnderline() *PdfAnnotationUnderline {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
underlineAnnotation := &PdfAnnotationUnderline{}
|
|
|
|
underlineAnnotation.PdfAnnotation = annotation
|
|
|
|
underlineAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(underlineAnnotation)
|
|
|
|
return underlineAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new text squiggly annotation.
|
|
|
|
func NewPdfAnnotationSquiggly() *PdfAnnotationSquiggly {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
squigglyAnnotation := &PdfAnnotationSquiggly{}
|
|
|
|
squigglyAnnotation.PdfAnnotation = annotation
|
|
|
|
squigglyAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(squigglyAnnotation)
|
|
|
|
return squigglyAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new text strikeout annotation.
|
|
|
|
func NewPdfAnnotationStrikeOut() *PdfAnnotationStrikeOut {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
strikeoutAnnotation := &PdfAnnotationStrikeOut{}
|
|
|
|
strikeoutAnnotation.PdfAnnotation = annotation
|
|
|
|
strikeoutAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(strikeoutAnnotation)
|
|
|
|
return strikeoutAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new caret annotation.
|
|
|
|
func NewPdfAnnotationCaret() *PdfAnnotationCaret {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
caretAnnotation := &PdfAnnotationCaret{}
|
|
|
|
caretAnnotation.PdfAnnotation = annotation
|
|
|
|
caretAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(caretAnnotation)
|
|
|
|
return caretAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new stamp annotation.
|
|
|
|
func NewPdfAnnotationStamp() *PdfAnnotationStamp {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
stampAnnotation := &PdfAnnotationStamp{}
|
|
|
|
stampAnnotation.PdfAnnotation = annotation
|
|
|
|
stampAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(stampAnnotation)
|
|
|
|
return stampAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new ink annotation.
|
|
|
|
func NewPdfAnnotationInk() *PdfAnnotationInk {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
inkAnnotation := &PdfAnnotationInk{}
|
|
|
|
inkAnnotation.PdfAnnotation = annotation
|
|
|
|
inkAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(inkAnnotation)
|
|
|
|
return inkAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new popup annotation.
|
|
|
|
func NewPdfAnnotationPopup() *PdfAnnotationPopup {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
popupAnnotation := &PdfAnnotationPopup{}
|
|
|
|
popupAnnotation.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(popupAnnotation)
|
|
|
|
return popupAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new file attachment annotation.
|
|
|
|
func NewPdfAnnotationFileAttachment() *PdfAnnotationFileAttachment {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
fileAnnotation := &PdfAnnotationFileAttachment{}
|
|
|
|
fileAnnotation.PdfAnnotation = annotation
|
|
|
|
fileAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(fileAnnotation)
|
|
|
|
return fileAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new sound annotation.
|
|
|
|
func NewPdfAnnotationSound() *PdfAnnotationSound {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
soundAnnotation := &PdfAnnotationSound{}
|
|
|
|
soundAnnotation.PdfAnnotation = annotation
|
|
|
|
soundAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(soundAnnotation)
|
|
|
|
return soundAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new rich media annotation.
|
|
|
|
func NewPdfAnnotationRichMedia() *PdfAnnotationRichMedia {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
richmediaAnnotation := &PdfAnnotationRichMedia{}
|
|
|
|
richmediaAnnotation.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(richmediaAnnotation)
|
|
|
|
return richmediaAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new movie annotation.
|
|
|
|
func NewPdfAnnotationMovie() *PdfAnnotationMovie {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
movieAnnotation := &PdfAnnotationMovie{}
|
|
|
|
movieAnnotation.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(movieAnnotation)
|
|
|
|
return movieAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new screen annotation.
|
|
|
|
func NewPdfAnnotationScreen() *PdfAnnotationScreen {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
screenAnnotation := &PdfAnnotationScreen{}
|
|
|
|
screenAnnotation.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(screenAnnotation)
|
|
|
|
return screenAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new watermark annotation.
|
|
|
|
func NewPdfAnnotationWatermark() *PdfAnnotationWatermark {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
watermarkAnnotation := &PdfAnnotationWatermark{}
|
|
|
|
watermarkAnnotation.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(watermarkAnnotation)
|
|
|
|
return watermarkAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new printermark annotation.
|
|
|
|
func NewPdfAnnotationPrinterMark() *PdfAnnotationPrinterMark {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
printermarkAnnotation := &PdfAnnotationPrinterMark{}
|
|
|
|
printermarkAnnotation.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(printermarkAnnotation)
|
|
|
|
return printermarkAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new trapnet annotation.
|
|
|
|
func NewPdfAnnotationTrapNet() *PdfAnnotationTrapNet {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
trapnetAnnotation := &PdfAnnotationTrapNet{}
|
|
|
|
trapnetAnnotation.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(trapnetAnnotation)
|
|
|
|
return trapnetAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new 3d annotation.
|
|
|
|
func NewPdfAnnotation3D() *PdfAnnotation3D {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
x3dAnnotation := &PdfAnnotation3D{}
|
|
|
|
x3dAnnotation.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(x3dAnnotation)
|
|
|
|
return x3dAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new projection annotation.
|
|
|
|
func NewPdfAnnotationProjection() *PdfAnnotationProjection {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
projectionAnnotation := &PdfAnnotationProjection{}
|
|
|
|
projectionAnnotation.PdfAnnotation = annotation
|
|
|
|
projectionAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(projectionAnnotation)
|
|
|
|
return projectionAnnotation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new redact annotation.
|
|
|
|
func NewPdfAnnotationRedact() *PdfAnnotationRedact {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
redactAnnotation := &PdfAnnotationRedact{}
|
|
|
|
redactAnnotation.PdfAnnotation = annotation
|
|
|
|
redactAnnotation.PdfAnnotationMarkup = &PdfAnnotationMarkup{}
|
|
|
|
annotation.SetContext(redactAnnotation)
|
|
|
|
return redactAnnotation
|
2017-03-24 11:31:20 +00:00
|
|
|
}
|
|
|
|
|
2018-01-28 09:54:01 +01:00
|
|
|
// Create a new annotation widget and initializes the underlying primitive.
|
|
|
|
func NewPdfAnnotationWidget() *PdfAnnotationWidget {
|
|
|
|
annotation := NewPdfAnnotation()
|
|
|
|
annotationWidget := &PdfAnnotationWidget{}
|
|
|
|
annotationWidget.PdfAnnotation = annotation
|
|
|
|
annotation.SetContext(annotationWidget)
|
|
|
|
return annotationWidget
|
|
|
|
}
|
|
|
|
|
2016-09-13 13:19:05 +00:00
|
|
|
// Used for PDF parsing. Loads a PDF annotation model from a PDF primitive dictionary object.
|
|
|
|
// Loads the common PDF annotation dictionary, and anything needed for the annotation subtype.
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationFromIndirectObject(container *PdfIndirectObject) (*PdfAnnotation, error) {
|
|
|
|
d, isDict := container.PdfObject.(*PdfObjectDictionary)
|
|
|
|
if !isDict {
|
|
|
|
return nil, fmt.Errorf("Annotation indirect object not containing a dictionary")
|
|
|
|
}
|
|
|
|
|
2016-09-12 17:59:45 +00:00
|
|
|
// Check if cached, return cached model if exists.
|
|
|
|
if model := r.modelManager.GetModelFromPrimitive(d); model != nil {
|
|
|
|
annot, ok := model.(*PdfAnnotation)
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("Cached model not a PDF annotation")
|
|
|
|
}
|
|
|
|
return annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
annot := &PdfAnnotation{}
|
|
|
|
annot.primitive = container
|
2016-09-12 17:59:45 +00:00
|
|
|
r.modelManager.Register(d, annot)
|
2016-09-05 09:57:16 +00:00
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("Type"); obj != nil {
|
2016-09-07 17:56:45 +00:00
|
|
|
str, ok := obj.(*PdfObjectName)
|
2016-09-05 09:57:16 +00:00
|
|
|
if !ok {
|
2017-03-02 18:06:32 +00:00
|
|
|
common.Log.Trace("Incompatibility! Invalid type of Type (%T) - should be Name", obj)
|
2017-01-14 18:52:45 +00:00
|
|
|
} else {
|
|
|
|
if *str != "Annot" {
|
|
|
|
// Log a debug message.
|
|
|
|
// Not returning an error on this.
|
2017-03-02 18:06:32 +00:00
|
|
|
common.Log.Trace("Unsuspected Type != Annot (%s)", *str)
|
2017-01-14 18:52:45 +00:00
|
|
|
}
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("Rect"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.Rect = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("Contents"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.Contents = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("P"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.P = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("NM"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.NM = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("M"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.M = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("F"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.F = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("AP"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.AP = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("AS"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.AS = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("Border"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.Border = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("C"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.C = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("StructParent"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.StructParent = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("OC"); obj != nil {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot.OC = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
subtypeObj := d.Get("Subtype")
|
|
|
|
if subtypeObj == nil {
|
2017-04-24 18:18:46 +00:00
|
|
|
common.Log.Debug("WARNING: Compatibility issue - annotation Subtype missing - assuming no subtype")
|
|
|
|
annot.context = nil
|
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
subtype, ok := subtypeObj.(*PdfObjectName)
|
|
|
|
if !ok {
|
2017-04-24 18:18:46 +00:00
|
|
|
common.Log.Debug("ERROR: Invalid Subtype object type != name (%T)", subtypeObj)
|
2016-09-05 09:57:16 +00:00
|
|
|
return nil, fmt.Errorf("Invalid Subtype object type != name (%T)", subtypeObj)
|
|
|
|
}
|
|
|
|
switch *subtype {
|
|
|
|
case "Text":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationTextFromDict(d)
|
2016-09-05 09:57:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Link":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationLinkFromDict(d)
|
2016-09-05 09:57:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "FreeText":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationFreeTextFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Line":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationLineFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2017-03-02 18:06:32 +00:00
|
|
|
common.Log.Trace("LINE ANNOTATION: annot (%T): %+v\n", annot, annot)
|
|
|
|
common.Log.Trace("LINE ANNOTATION: ctx (%T): %+v\n", ctx, ctx)
|
|
|
|
common.Log.Trace("LINE ANNOTATION Markup: ctx (%T): %+v\n", ctx.PdfAnnotationMarkup, ctx.PdfAnnotationMarkup)
|
2016-12-05 16:21:23 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Square":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationSquareFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Circle":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationCircleFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Polygon":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationPolygonFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "PolyLine":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationPolyLineFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-06 09:33:58 +00:00
|
|
|
case "Highlight":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationHighlightFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-13 13:19:05 +00:00
|
|
|
case "Underline":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationUnderlineFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
|
|
|
return annot, nil
|
|
|
|
case "Squiggly":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationSquigglyFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
|
|
|
return annot, nil
|
|
|
|
case "StrikeOut":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationStrikeOut(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Caret":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationCaretFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Stamp":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationStampFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Ink":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationInkFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Popup":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationPopupFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "FileAttachment":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationFileAttachmentFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Sound":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationSoundFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-13 13:19:05 +00:00
|
|
|
case "RichMedia":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationRichMediaFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Movie":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationMovieFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Screen":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationScreenFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Widget":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationWidgetFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "PrinterMark":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationPrinterMarkFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "TrapNet":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationTrapNetFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Watermark":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationWatermarkFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "3D":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotation3DFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-13 13:19:05 +00:00
|
|
|
case "Projection":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationProjectionFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
case "Redact":
|
2016-12-05 16:21:23 +00:00
|
|
|
ctx, err := r.newPdfAnnotationRedactFromDict(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.PdfAnnotation = annot
|
|
|
|
annot.context = ctx
|
2016-09-11 23:17:38 +00:00
|
|
|
return annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
err := fmt.Errorf("Unknown annotation (%s)", *subtype)
|
|
|
|
return nil, err
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
|
2016-09-13 13:19:05 +00:00
|
|
|
// Load data for markup annotation subtypes.
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationMarkupFromDict(d *PdfObjectDictionary) (*PdfAnnotationMarkup, error) {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot := &PdfAnnotationMarkup{}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("T"); obj != nil {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot.T = obj
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("Popup"); obj != nil {
|
2016-12-05 16:21:23 +00:00
|
|
|
indObj, isIndirect := obj.(*PdfIndirectObject)
|
|
|
|
if !isIndirect {
|
|
|
|
if _, isNull := obj.(*PdfObjectNull); !isNull {
|
|
|
|
return nil, fmt.Errorf("Popup should point to an indirect object")
|
|
|
|
}
|
2017-08-01 15:21:33 +00:00
|
|
|
} else {
|
|
|
|
popupAnnotObj, err := r.newPdfAnnotationFromIndirectObject(indObj)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
popupAnnot, isPopupAnnot := popupAnnotObj.context.(*PdfAnnotationPopup)
|
|
|
|
if !isPopupAnnot {
|
|
|
|
return nil, fmt.Errorf("Popup not referring to a popup annotation!")
|
|
|
|
}
|
2016-12-05 16:21:23 +00:00
|
|
|
|
2017-08-01 15:21:33 +00:00
|
|
|
annot.Popup = popupAnnot
|
2016-12-05 16:21:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("CA"); obj != nil {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot.CA = obj
|
|
|
|
}
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("RC"); obj != nil {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot.RC = obj
|
|
|
|
}
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("CreationDate"); obj != nil {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot.CreationDate = obj
|
|
|
|
}
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("IRT"); obj != nil {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot.IRT = obj
|
|
|
|
}
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("Subj"); obj != nil {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot.Subj = obj
|
|
|
|
}
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("RT"); obj != nil {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot.RT = obj
|
|
|
|
}
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("IT"); obj != nil {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot.IT = obj
|
|
|
|
}
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("ExData"); obj != nil {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot.ExData = obj
|
|
|
|
}
|
|
|
|
|
|
|
|
return annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationTextFromDict(d *PdfObjectDictionary) (*PdfAnnotationText, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationText{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.Open = d.Get("Open")
|
|
|
|
annot.Name = d.Get("Name")
|
|
|
|
annot.State = d.Get("State")
|
|
|
|
annot.StateModel = d.Get("StateModel")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationLinkFromDict(d *PdfObjectDictionary) (*PdfAnnotationLink, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationLink{}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.A = d.Get("A")
|
|
|
|
annot.Dest = d.Get("Dest")
|
|
|
|
annot.H = d.Get("H")
|
|
|
|
annot.PA = d.Get("PA")
|
|
|
|
annot.QuadPoints = d.Get("QuadPoints")
|
|
|
|
annot.BS = d.Get("BS")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationFreeTextFromDict(d *PdfObjectDictionary) (*PdfAnnotationFreeText, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationFreeText{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.DA = d.Get("DA")
|
|
|
|
annot.Q = d.Get("Q")
|
|
|
|
annot.RC = d.Get("RC")
|
|
|
|
annot.DS = d.Get("DS")
|
|
|
|
annot.CL = d.Get("CL")
|
|
|
|
annot.IT = d.Get("IT")
|
|
|
|
annot.BE = d.Get("BE")
|
|
|
|
annot.RD = d.Get("RD")
|
|
|
|
annot.BS = d.Get("BS")
|
|
|
|
annot.LE = d.Get("LE")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationLineFromDict(d *PdfObjectDictionary) (*PdfAnnotationLine, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationLine{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.L = d.Get("L")
|
|
|
|
annot.BS = d.Get("BS")
|
|
|
|
annot.LE = d.Get("LE")
|
|
|
|
annot.IC = d.Get("IC")
|
|
|
|
annot.LL = d.Get("LL")
|
|
|
|
annot.LLE = d.Get("LLE")
|
|
|
|
annot.Cap = d.Get("Cap")
|
|
|
|
annot.IT = d.Get("IT")
|
|
|
|
annot.LLO = d.Get("LLO")
|
|
|
|
annot.CP = d.Get("CP")
|
|
|
|
annot.Measure = d.Get("Measure")
|
|
|
|
annot.CO = d.Get("CO")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationSquareFromDict(d *PdfObjectDictionary) (*PdfAnnotationSquare, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationSquare{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.BS = d.Get("BS")
|
|
|
|
annot.IC = d.Get("IC")
|
|
|
|
annot.BE = d.Get("BE")
|
|
|
|
annot.RD = d.Get("RD")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationCircleFromDict(d *PdfObjectDictionary) (*PdfAnnotationCircle, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationCircle{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.BS = d.Get("BS")
|
|
|
|
annot.IC = d.Get("IC")
|
|
|
|
annot.BE = d.Get("BE")
|
|
|
|
annot.RD = d.Get("RD")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationPolygonFromDict(d *PdfObjectDictionary) (*PdfAnnotationPolygon, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationPolygon{}
|
2016-09-07 17:56:45 +00:00
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.Vertices = d.Get("Vertices")
|
|
|
|
annot.LE = d.Get("LE")
|
|
|
|
annot.BS = d.Get("BS")
|
|
|
|
annot.IC = d.Get("IC")
|
|
|
|
annot.BE = d.Get("BE")
|
|
|
|
annot.IT = d.Get("IT")
|
|
|
|
annot.Measure = d.Get("Measure")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationPolyLineFromDict(d *PdfObjectDictionary) (*PdfAnnotationPolyLine, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationPolyLine{}
|
2016-09-07 17:56:45 +00:00
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.Vertices = d.Get("Vertices")
|
|
|
|
annot.LE = d.Get("LE")
|
|
|
|
annot.BS = d.Get("BS")
|
|
|
|
annot.IC = d.Get("IC")
|
|
|
|
annot.BE = d.Get("BE")
|
|
|
|
annot.IT = d.Get("IT")
|
|
|
|
annot.Measure = d.Get("Measure")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationHighlightFromDict(d *PdfObjectDictionary) (*PdfAnnotationHighlight, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationHighlight{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.QuadPoints = d.Get("QuadPoints")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationUnderlineFromDict(d *PdfObjectDictionary) (*PdfAnnotationUnderline, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationUnderline{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.QuadPoints = d.Get("QuadPoints")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationSquigglyFromDict(d *PdfObjectDictionary) (*PdfAnnotationSquiggly, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationSquiggly{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.QuadPoints = d.Get("QuadPoints")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationStrikeOut(d *PdfObjectDictionary) (*PdfAnnotationStrikeOut, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationStrikeOut{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.QuadPoints = d.Get("QuadPoints")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationCaretFromDict(d *PdfObjectDictionary) (*PdfAnnotationCaret, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationCaret{}
|
2016-09-13 13:19:05 +00:00
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.RD = d.Get("RD")
|
|
|
|
annot.Sy = d.Get("Sy")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationStampFromDict(d *PdfObjectDictionary) (*PdfAnnotationStamp, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationStamp{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.Name = d.Get("Name")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationInkFromDict(d *PdfObjectDictionary) (*PdfAnnotationInk, error) {
|
2016-09-05 09:57:16 +00:00
|
|
|
annot := PdfAnnotationInk{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.InkList = d.Get("InkList")
|
|
|
|
annot.BS = d.Get("BS")
|
2016-09-05 09:57:16 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationPopupFromDict(d *PdfObjectDictionary) (*PdfAnnotationPopup, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationPopup{}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.Parent = d.Get("Parent")
|
|
|
|
annot.Open = d.Get("Open")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationFileAttachmentFromDict(d *PdfObjectDictionary) (*PdfAnnotationFileAttachment, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationFileAttachment{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.FS = d.Get("FS")
|
|
|
|
annot.Name = d.Get("Name")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationSoundFromDict(d *PdfObjectDictionary) (*PdfAnnotationSound, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationSound{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.Name = d.Get("Name")
|
|
|
|
annot.Sound = d.Get("Sound")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationRichMediaFromDict(d *PdfObjectDictionary) (*PdfAnnotationRichMedia, error) {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot := &PdfAnnotationRichMedia{}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.RichMediaSettings = d.Get("RichMediaSettings")
|
|
|
|
annot.RichMediaContent = d.Get("RichMediaContent")
|
2016-09-13 13:19:05 +00:00
|
|
|
|
|
|
|
return annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationMovieFromDict(d *PdfObjectDictionary) (*PdfAnnotationMovie, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationMovie{}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.T = d.Get("T")
|
|
|
|
annot.Movie = d.Get("Movie")
|
|
|
|
annot.A = d.Get("A")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationScreenFromDict(d *PdfObjectDictionary) (*PdfAnnotationScreen, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationScreen{}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.T = d.Get("T")
|
|
|
|
annot.MK = d.Get("MK")
|
|
|
|
annot.A = d.Get("A")
|
|
|
|
annot.AA = d.Get("AA")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationWidgetFromDict(d *PdfObjectDictionary) (*PdfAnnotationWidget, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationWidget{}
|
2016-09-07 17:56:45 +00:00
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.H = d.Get("H")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.MK = d.Get("MK")
|
|
|
|
// MK can be an indirect object...
|
|
|
|
// Expected to be a dictionary.
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.A = d.Get("A")
|
|
|
|
annot.AA = d.Get("AA")
|
|
|
|
annot.BS = d.Get("BS")
|
|
|
|
annot.Parent = d.Get("Parent")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationPrinterMarkFromDict(d *PdfObjectDictionary) (*PdfAnnotationPrinterMark, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationPrinterMark{}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.MN = d.Get("MN")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationTrapNetFromDict(d *PdfObjectDictionary) (*PdfAnnotationTrapNet, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationTrapNet{}
|
|
|
|
// empty?e
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationWatermarkFromDict(d *PdfObjectDictionary) (*PdfAnnotationWatermark, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationWatermark{}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.FixedPrint = d.Get("FixedPrint")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotation3DFromDict(d *PdfObjectDictionary) (*PdfAnnotation3D, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotation3D{}
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.T3DD = d.Get("3DD")
|
|
|
|
annot.T3DV = d.Get("3DV")
|
|
|
|
annot.T3DA = d.Get("3DA")
|
|
|
|
annot.T3DI = d.Get("3DI")
|
|
|
|
annot.T3DB = d.Get("3DB")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationProjectionFromDict(d *PdfObjectDictionary) (*PdfAnnotationProjection, error) {
|
2016-09-13 13:19:05 +00:00
|
|
|
annot := &PdfAnnotationProjection{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
|
|
|
return annot, nil
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
func (r *PdfReader) newPdfAnnotationRedactFromDict(d *PdfObjectDictionary) (*PdfAnnotationRedact, error) {
|
2016-09-06 09:33:58 +00:00
|
|
|
annot := PdfAnnotationRedact{}
|
|
|
|
|
2016-12-05 16:21:23 +00:00
|
|
|
markup, err := r.newPdfAnnotationMarkupFromDict(d)
|
2016-09-13 13:19:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
annot.PdfAnnotationMarkup = markup
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
annot.QuadPoints = d.Get("QuadPoints")
|
|
|
|
annot.IC = d.Get("IC")
|
|
|
|
annot.RO = d.Get("RO")
|
|
|
|
annot.OverlayText = d.Get("OverlayText")
|
|
|
|
annot.Repeat = d.Get("Repeat")
|
|
|
|
annot.DA = d.Get("DA")
|
|
|
|
annot.Q = d.Get("Q")
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return &annot, nil
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotation) GetContainingPdfObject() PdfObject {
|
|
|
|
return this.primitive
|
2016-09-08 17:53:45 +00:00
|
|
|
}
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2017-04-24 18:18:46 +00:00
|
|
|
// Note: Call the sub-annotation's ToPdfObject to set both the generic and non-generic information.
|
|
|
|
// TODO/FIXME: Consider doing it here instead.
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotation) ToPdfObject() PdfObject {
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
|
|
|
|
2017-07-08 21:04:13 +00:00
|
|
|
d.Set("Type", MakeName("Annot"))
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Rect", this.Rect)
|
|
|
|
d.SetIfNotNil("Contents", this.Contents)
|
|
|
|
d.SetIfNotNil("P", this.P)
|
|
|
|
d.SetIfNotNil("NM", this.NM)
|
|
|
|
d.SetIfNotNil("M", this.M)
|
|
|
|
d.SetIfNotNil("F", this.F)
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("AP", this.AP)
|
|
|
|
d.SetIfNotNil("AS", this.AS)
|
|
|
|
d.SetIfNotNil("Border", this.Border)
|
|
|
|
d.SetIfNotNil("C", this.C)
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("StructParent", this.StructParent)
|
|
|
|
d.SetIfNotNil("OC", this.OC)
|
2016-09-06 09:33:58 +00:00
|
|
|
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-13 13:19:05 +00:00
|
|
|
// Markup portion of the annotation.
|
|
|
|
func (this *PdfAnnotationMarkup) appendToPdfDictionary(d *PdfObjectDictionary) {
|
|
|
|
d.SetIfNotNil("T", this.T)
|
2016-12-05 16:21:23 +00:00
|
|
|
if this.Popup != nil {
|
|
|
|
d.Set("Popup", this.Popup.ToPdfObject())
|
|
|
|
}
|
2016-09-13 13:19:05 +00:00
|
|
|
d.SetIfNotNil("CA", this.CA)
|
|
|
|
d.SetIfNotNil("RC", this.RC)
|
|
|
|
d.SetIfNotNil("CreationDate", this.CreationDate)
|
|
|
|
d.SetIfNotNil("IRT", this.IRT)
|
|
|
|
d.SetIfNotNil("Subj", this.Subj)
|
|
|
|
d.SetIfNotNil("RT", this.RT)
|
|
|
|
d.SetIfNotNil("IT", this.IT)
|
|
|
|
d.SetIfNotNil("ExData", this.ExData)
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationText) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2017-03-08 16:49:23 +00:00
|
|
|
if this.PdfAnnotationMarkup != nil {
|
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
|
|
|
}
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Text"))
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("Open", this.Open)
|
|
|
|
d.SetIfNotNil("Name", this.Name)
|
|
|
|
d.SetIfNotNil("State", this.State)
|
|
|
|
d.SetIfNotNil("StateModel", this.StateModel)
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationLink) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Link"))
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("A", this.A)
|
|
|
|
d.SetIfNotNil("Dest", this.Dest)
|
|
|
|
d.SetIfNotNil("H", this.H)
|
|
|
|
d.SetIfNotNil("PA", this.PA)
|
|
|
|
d.SetIfNotNil("QuadPoints", this.QuadPoints)
|
|
|
|
d.SetIfNotNil("BS", this.BS)
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationFreeText) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("FreeText"))
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("DA", this.DA)
|
|
|
|
d.SetIfNotNil("Q", this.Q)
|
|
|
|
d.SetIfNotNil("RC", this.RC)
|
|
|
|
d.SetIfNotNil("DS", this.DS)
|
|
|
|
d.SetIfNotNil("CL", this.CL)
|
|
|
|
d.SetIfNotNil("IT", this.IT)
|
|
|
|
d.SetIfNotNil("BE", this.BE)
|
|
|
|
d.SetIfNotNil("RD", this.RD)
|
|
|
|
d.SetIfNotNil("BS", this.BS)
|
|
|
|
d.SetIfNotNil("LE", this.LE)
|
|
|
|
|
|
|
|
return container
|
|
|
|
}
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationLine) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Line"))
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("L", this.L)
|
|
|
|
d.SetIfNotNil("BS", this.BS)
|
|
|
|
d.SetIfNotNil("LE", this.LE)
|
|
|
|
d.SetIfNotNil("IC", this.IC)
|
|
|
|
d.SetIfNotNil("LL", this.LL)
|
|
|
|
d.SetIfNotNil("LLE", this.LLE)
|
|
|
|
d.SetIfNotNil("Cap", this.Cap)
|
|
|
|
d.SetIfNotNil("IT", this.IT)
|
|
|
|
d.SetIfNotNil("LLO", this.LLO)
|
|
|
|
d.SetIfNotNil("CP", this.CP)
|
|
|
|
d.SetIfNotNil("Measure", this.Measure)
|
|
|
|
d.SetIfNotNil("CO", this.CO)
|
|
|
|
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationSquare) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2017-03-24 11:31:20 +00:00
|
|
|
if this.PdfAnnotationMarkup != nil {
|
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
|
|
|
}
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Square"))
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("BS", this.BS)
|
|
|
|
d.SetIfNotNil("IC", this.IC)
|
|
|
|
d.SetIfNotNil("BE", this.BE)
|
|
|
|
d.SetIfNotNil("RD", this.RD)
|
|
|
|
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationCircle) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Circle"))
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("BS", this.BS)
|
|
|
|
d.SetIfNotNil("IC", this.IC)
|
|
|
|
d.SetIfNotNil("BE", this.BE)
|
|
|
|
d.SetIfNotNil("RD", this.RD)
|
|
|
|
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationPolygon) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Polygon"))
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("Vertices", this.Vertices)
|
|
|
|
d.SetIfNotNil("LE", this.LE)
|
|
|
|
d.SetIfNotNil("BS", this.BS)
|
|
|
|
d.SetIfNotNil("IC", this.IC)
|
|
|
|
d.SetIfNotNil("BE", this.BE)
|
|
|
|
d.SetIfNotNil("IT", this.IT)
|
|
|
|
d.SetIfNotNil("Measure", this.Measure)
|
|
|
|
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationPolyLine) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("PolyLine"))
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("Vertices", this.Vertices)
|
|
|
|
d.SetIfNotNil("LE", this.LE)
|
|
|
|
d.SetIfNotNil("BS", this.BS)
|
|
|
|
d.SetIfNotNil("IC", this.IC)
|
|
|
|
d.SetIfNotNil("BE", this.BE)
|
|
|
|
d.SetIfNotNil("IT", this.IT)
|
|
|
|
d.SetIfNotNil("Measure", this.Measure)
|
|
|
|
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationHighlight) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 09:33:58 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 09:33:58 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Highlight"))
|
2016-09-06 09:33:58 +00:00
|
|
|
d.SetIfNotNil("QuadPoints", this.QuadPoints)
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationUnderline) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 13:51:28 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Underline"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("QuadPoints", this.QuadPoints)
|
|
|
|
return container
|
2016-09-06 09:33:58 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationSquiggly) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 13:51:28 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Squiggly"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("QuadPoints", this.QuadPoints)
|
|
|
|
return container
|
2016-09-06 09:33:58 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationStrikeOut) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 13:51:28 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("StrikeOut"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("QuadPoints", this.QuadPoints)
|
|
|
|
return container
|
2016-09-06 09:33:58 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationCaret) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 13:51:28 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Caret"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("RD", this.RD)
|
|
|
|
d.SetIfNotNil("Sy", this.Sy)
|
|
|
|
return container
|
2016-09-06 09:33:58 +00:00
|
|
|
}
|
2016-09-06 13:51:28 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationStamp) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 13:51:28 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Stamp"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("Name", this.Name)
|
|
|
|
return container
|
2016-09-06 09:33:58 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationInk) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 13:51:28 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Ink"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("InkList", this.InkList)
|
|
|
|
d.SetIfNotNil("BS", this.BS)
|
|
|
|
return container
|
2016-09-06 09:33:58 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationPopup) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Popup"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("Parent", this.Parent)
|
|
|
|
d.SetIfNotNil("Open", this.Open)
|
|
|
|
return container
|
2016-09-06 09:33:58 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationFileAttachment) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-06 13:51:28 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("FileAttachment"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("FS", this.FS)
|
|
|
|
d.SetIfNotNil("Name", this.Name)
|
|
|
|
return container
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-13 13:19:05 +00:00
|
|
|
func (this *PdfAnnotationRichMedia) ToPdfObject() PdfObject {
|
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
|
|
|
|
|
|
|
d.SetIfNotNil("Subtype", MakeName("RichMedia"))
|
|
|
|
d.SetIfNotNil("RichMediaSettings", this.RichMediaSettings)
|
|
|
|
d.SetIfNotNil("RichMediaContent", this.RichMediaContent)
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationSound) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-05 09:57:16 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Sound"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("Sound", this.Sound)
|
|
|
|
d.SetIfNotNil("Name", this.Name)
|
|
|
|
return container
|
2016-09-06 09:33:58 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationMovie) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-05 09:57:16 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Movie"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("T", this.T)
|
|
|
|
d.SetIfNotNil("Movie", this.Movie)
|
|
|
|
d.SetIfNotNil("A", this.A)
|
|
|
|
return container
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationScreen) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-05 09:57:16 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Screen"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("T", this.T)
|
|
|
|
d.SetIfNotNil("MK", this.MK)
|
|
|
|
d.SetIfNotNil("A", this.A)
|
|
|
|
d.SetIfNotNil("AA", this.AA)
|
|
|
|
return container
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationWidget) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Widget"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("H", this.H)
|
|
|
|
d.SetIfNotNil("MK", this.MK)
|
|
|
|
d.SetIfNotNil("A", this.A)
|
|
|
|
d.SetIfNotNil("AA", this.AA)
|
|
|
|
d.SetIfNotNil("BS", this.BS)
|
|
|
|
d.SetIfNotNil("Parent", this.Parent)
|
2016-09-08 17:53:45 +00:00
|
|
|
|
2016-09-06 13:51:28 +00:00
|
|
|
return container
|
2016-09-06 09:33:58 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationPrinterMark) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("PrinterMark"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("MN", this.MN)
|
|
|
|
return container
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
2016-09-06 13:51:28 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationTrapNet) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-07 17:56:45 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2017-03-08 16:49:23 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("TrapNet"))
|
2016-09-06 13:51:28 +00:00
|
|
|
return container
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationWatermark) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Watermark"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("FixedPrint", this.FixedPrint)
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-06 13:51:28 +00:00
|
|
|
return container
|
2016-09-05 09:57:16 +00:00
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotation3D) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("3D"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("3DD", this.T3DD)
|
|
|
|
d.SetIfNotNil("3DV", this.T3DV)
|
|
|
|
d.SetIfNotNil("3DA", this.T3DA)
|
|
|
|
d.SetIfNotNil("3DI", this.T3DI)
|
|
|
|
d.SetIfNotNil("3DB", this.T3DB)
|
|
|
|
return container
|
|
|
|
}
|
2016-09-12 17:59:45 +00:00
|
|
|
|
2016-09-13 13:19:05 +00:00
|
|
|
func (this *PdfAnnotationProjection) ToPdfObject() PdfObject {
|
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:17:38 +00:00
|
|
|
func (this *PdfAnnotationRedact) ToPdfObject() PdfObject {
|
2016-09-12 17:59:45 +00:00
|
|
|
this.PdfAnnotation.ToPdfObject()
|
|
|
|
container := this.primitive
|
2016-09-06 13:51:28 +00:00
|
|
|
d := container.PdfObject.(*PdfObjectDictionary)
|
2016-09-13 13:19:05 +00:00
|
|
|
this.PdfAnnotationMarkup.appendToPdfDictionary(d)
|
2016-09-05 09:57:16 +00:00
|
|
|
|
2016-09-07 17:56:45 +00:00
|
|
|
d.SetIfNotNil("Subtype", MakeName("Redact"))
|
2016-09-06 13:51:28 +00:00
|
|
|
d.SetIfNotNil("QuadPoints", this.QuadPoints)
|
|
|
|
d.SetIfNotNil("IC", this.IC)
|
|
|
|
d.SetIfNotNil("RO", this.RO)
|
|
|
|
d.SetIfNotNil("OverlayText", this.OverlayText)
|
|
|
|
d.SetIfNotNil("Repeat", this.Repeat)
|
|
|
|
d.SetIfNotNil("DA", this.DA)
|
|
|
|
d.SetIfNotNil("Q", this.Q)
|
|
|
|
return container
|
|
|
|
}
|
2017-03-24 11:31:20 +00:00
|
|
|
|
|
|
|
// Border definitions.
|
|
|
|
|
|
|
|
type BorderStyle int
|
|
|
|
|
|
|
|
const (
|
|
|
|
BorderStyleSolid BorderStyle = iota
|
|
|
|
BorderStyleDashed BorderStyle = iota
|
|
|
|
BorderStyleBeveled BorderStyle = iota
|
|
|
|
BorderStyleInset BorderStyle = iota
|
|
|
|
BorderStyleUnderline BorderStyle = iota
|
|
|
|
)
|
|
|
|
|
|
|
|
func (this *BorderStyle) GetPdfName() string {
|
|
|
|
switch *this {
|
|
|
|
case BorderStyleSolid:
|
|
|
|
return "S"
|
|
|
|
case BorderStyleDashed:
|
|
|
|
return "D"
|
|
|
|
case BorderStyleBeveled:
|
|
|
|
return "B"
|
|
|
|
case BorderStyleInset:
|
|
|
|
return "I"
|
|
|
|
case BorderStyleUnderline:
|
|
|
|
return "U"
|
|
|
|
}
|
|
|
|
|
|
|
|
return "" // Should not happen.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Border style
|
|
|
|
type PdfBorderStyle struct {
|
|
|
|
W *float64 // Border width
|
|
|
|
S *BorderStyle // Border style
|
|
|
|
D *[]int // Dash array.
|
|
|
|
|
|
|
|
container PdfObject
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewBorderStyle() *PdfBorderStyle {
|
|
|
|
bs := &PdfBorderStyle{}
|
|
|
|
return bs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *PdfBorderStyle) SetBorderWidth(width float64) {
|
|
|
|
this.W = &width
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *PdfBorderStyle) GetBorderWidth() float64 {
|
|
|
|
if this.W == nil {
|
|
|
|
return 1 // Default.
|
|
|
|
}
|
|
|
|
return *this.W
|
|
|
|
}
|
|
|
|
|
|
|
|
func newPdfBorderStyleFromPdfObject(obj PdfObject) (*PdfBorderStyle, error) {
|
|
|
|
bs := &PdfBorderStyle{}
|
|
|
|
bs.container = obj
|
|
|
|
|
|
|
|
var d *PdfObjectDictionary
|
|
|
|
obj = TraceToDirectObject(obj)
|
|
|
|
d, ok := obj.(*PdfObjectDictionary)
|
|
|
|
if !ok {
|
|
|
|
return nil, errors.New("Type check")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type.
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("Type"); obj != nil {
|
2017-03-24 11:31:20 +00:00
|
|
|
name, ok := obj.(*PdfObjectName)
|
|
|
|
if !ok {
|
|
|
|
common.Log.Debug("Incompatibility with Type not a name object: %T", obj)
|
|
|
|
} else {
|
|
|
|
if *name != "Border" {
|
|
|
|
common.Log.Debug("Warning, Type != Border: %s", *name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Border width.
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("W"); obj != nil {
|
2018-07-25 12:00:49 +10:00
|
|
|
val, err := GetNumberAsFloat(obj)
|
2017-03-24 11:31:20 +00:00
|
|
|
if err != nil {
|
|
|
|
common.Log.Debug("Error retrieving W: %v", err)
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
bs.W = &val
|
|
|
|
}
|
|
|
|
|
|
|
|
// Border style.
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("S"); obj != nil {
|
2017-03-24 11:31:20 +00:00
|
|
|
name, ok := obj.(*PdfObjectName)
|
|
|
|
if !ok {
|
|
|
|
return nil, errors.New("Border S not a name object")
|
|
|
|
}
|
|
|
|
|
|
|
|
var style BorderStyle
|
|
|
|
switch *name {
|
|
|
|
case "S":
|
|
|
|
style = BorderStyleSolid
|
|
|
|
case "D":
|
|
|
|
style = BorderStyleDashed
|
|
|
|
case "B":
|
|
|
|
style = BorderStyleBeveled
|
|
|
|
case "I":
|
|
|
|
style = BorderStyleInset
|
|
|
|
case "U":
|
|
|
|
style = BorderStyleUnderline
|
|
|
|
default:
|
|
|
|
common.Log.Debug("Invalid style name %s", *name)
|
|
|
|
return nil, errors.New("Style type range check")
|
|
|
|
}
|
|
|
|
|
|
|
|
bs.S = &style
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dash array.
|
2017-07-08 21:04:13 +00:00
|
|
|
if obj := d.Get("D"); obj != nil {
|
2017-03-24 11:31:20 +00:00
|
|
|
vec, ok := obj.(*PdfObjectArray)
|
|
|
|
if !ok {
|
|
|
|
common.Log.Debug("Border D dash not an array: %T", obj)
|
|
|
|
return nil, errors.New("Border D type check error")
|
|
|
|
}
|
|
|
|
|
|
|
|
vals, err := vec.ToIntegerArray()
|
|
|
|
if err != nil {
|
|
|
|
common.Log.Debug("Border D Problem converting to integer array: %v", err)
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
bs.D = &vals
|
|
|
|
}
|
|
|
|
|
|
|
|
return bs, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *PdfBorderStyle) ToPdfObject() PdfObject {
|
2017-07-08 21:04:13 +00:00
|
|
|
d := MakeDict()
|
2017-03-24 11:31:20 +00:00
|
|
|
if this.container != nil {
|
|
|
|
if indObj, is := this.container.(*PdfIndirectObject); is {
|
|
|
|
indObj.PdfObject = d
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d.Set("Subtype", MakeName("Border"))
|
|
|
|
if this.W != nil {
|
|
|
|
d.Set("W", MakeFloat(*this.W))
|
|
|
|
}
|
|
|
|
if this.S != nil {
|
|
|
|
d.Set("S", MakeName(this.S.GetPdfName()))
|
|
|
|
}
|
|
|
|
if this.D != nil {
|
|
|
|
d.Set("D", MakeArrayFromIntegers(*this.D))
|
|
|
|
}
|
|
|
|
|
|
|
|
if this.container != nil {
|
|
|
|
return this.container
|
|
|
|
} else {
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Border effect
|
|
|
|
type BorderEffect int
|
|
|
|
|
|
|
|
const (
|
|
|
|
BorderEffectNoEffect BorderEffect = iota
|
|
|
|
BorderEffectCloudy BorderEffect = iota
|
|
|
|
)
|
|
|
|
|
|
|
|
type PdfBorderEffect struct {
|
|
|
|
S *BorderEffect // Border effect type
|
|
|
|
I *float64 // Intensity of the effect
|
|
|
|
}
|