Documentation
¶
Index ¶
- Constants
- Variables
- func AddFontFile(path string)
- func AddFontFolder(path string)
- func AddSystemFonts()
- func ClearFontSources()
- func Encrypt(inputPath, outputPath, userPassword, ownerPassword string) error
- type Action
- type ActionType
- type Annotation
- type AnnotationCollection
- func (c *AnnotationCollection) Add(a Annotation) error
- func (c *AnnotationCollection) All() []Annotation
- func (c *AnnotationCollection) At(index int) Annotation
- func (c *AnnotationCollection) Count() int
- func (c *AnnotationCollection) Delete(a Annotation) bool
- func (c *AnnotationCollection) DeleteAt(index int) error
- func (c *AnnotationCollection) Flatten() error
- type AnnotationType
- type BmpDevice
- type BorderEffect
- type BorderInfo
- type BorderSide
- type BorderStyle
- type ButtonAppearance
- type ButtonField
- func (b *ButtonField) Flatten() error
- func (b *ButtonField) FullName() string
- func (b *ButtonField) IsReadOnly() bool
- func (b *ButtonField) IsRequired() bool
- func (b *ButtonField) PageIndex() int
- func (b *ButtonField) PartialName() string
- func (b *ButtonField) Rect() Rectangle
- func (f *ButtonField) SetAppearance(a ButtonAppearance) error
- func (f *ButtonField) SetReadOnly(v bool)
- func (b *ButtonField) SetStyle(s FieldStyle) error
- func (f *ButtonField) SetValue(s string) error
- func (b *ButtonField) Style() FieldStyle
- func (f *ButtonField) Value() string
- type ButtonIconPosition
- type Cell
- func (c *Cell) Background() *Color
- func (c *Cell) Border() *BorderInfo
- func (c *Cell) ColSpan() int
- func (c *Cell) Image() (path string, hasImage bool)
- func (c *Cell) Margin() *MarginInfo
- func (c *Cell) Row() *Row
- func (c *Cell) RowSpan() int
- func (c *Cell) SetBackground(col *Color) *Cell
- func (c *Cell) SetBorder(b BorderInfo) *Cell
- func (c *Cell) SetColSpan(n int) *Cell
- func (c *Cell) SetHAlign(h HAlign) *Cell
- func (c *Cell) SetImage(path string) *Cell
- func (c *Cell) SetImageFromStream(r io.Reader) *Cell
- func (c *Cell) SetMargin(m MarginInfo) *Cell
- func (c *Cell) SetRowSpan(n int) *Cell
- func (c *Cell) SetText(text string) *Cell
- func (c *Cell) SetTextStyle(s TextStyle) *Cell
- func (c *Cell) SetVAlign(v VAlign) *Cell
- func (c *Cell) Text() string
- func (c *Cell) TextStyle() *TextStyle
- type CheckboxField
- func (f *CheckboxField) Checked() bool
- func (b *CheckboxField) Flatten() error
- func (b *CheckboxField) FullName() string
- func (b *CheckboxField) IsReadOnly() bool
- func (b *CheckboxField) IsRequired() bool
- func (b *CheckboxField) PageIndex() int
- func (b *CheckboxField) PartialName() string
- func (b *CheckboxField) Rect() Rectangle
- func (f *CheckboxField) SetChecked(v bool)
- func (f *CheckboxField) SetReadOnly(v bool)
- func (f *CheckboxField) SetRequired(v bool)
- func (b *CheckboxField) SetStyle(s FieldStyle) error
- func (f *CheckboxField) SetValue(s string) error
- func (b *CheckboxField) Style() FieldStyle
- func (f *CheckboxField) Value() string
- type ChoiceOption
- type CircleAnnotation
- func (a *CircleAnnotation) AnnotationType() AnnotationType
- func (d *CircleAnnotation) BorderStyle() BorderStyle
- func (d *CircleAnnotation) BorderWidth() float64
- func (d *CircleAnnotation) DashPattern() []float64
- func (a *CircleAnnotation) InteriorColor() *Color
- func (a *CircleAnnotation) RegenerateAppearance()
- func (d *CircleAnnotation) SetBorderStyle(s BorderStyle)
- func (d *CircleAnnotation) SetBorderWidth(w float64)
- func (d *CircleAnnotation) SetColor(c *Color)
- func (d *CircleAnnotation) SetDashPattern(p []float64)
- func (a *CircleAnnotation) SetInteriorColor(c *Color)
- func (d *CircleAnnotation) SetRect(r Rectangle)
- type Color
- type ComboBoxField
- func (f *ComboBoxField) AddOption(o ChoiceOption)
- func (b *ComboBoxField) Flatten() error
- func (b *ComboBoxField) FullName() string
- func (b *ComboBoxField) IsReadOnly() bool
- func (b *ComboBoxField) IsRequired() bool
- func (f *ComboBoxField) Options() []ChoiceOption
- func (b *ComboBoxField) PageIndex() int
- func (b *ComboBoxField) PartialName() string
- func (b *ComboBoxField) Rect() Rectangle
- func (f *ComboBoxField) RemoveOption(index int) error
- func (f *ComboBoxField) Selected() int
- func (f *ComboBoxField) SetEditable(v bool)
- func (f *ComboBoxField) SetReadOnly(v bool)
- func (f *ComboBoxField) SetRequired(v bool)
- func (f *ComboBoxField) SetSelected(index int) error
- func (b *ComboBoxField) SetStyle(s FieldStyle) error
- func (f *ComboBoxField) SetValue(s string) error
- func (b *ComboBoxField) Style() FieldStyle
- func (f *ComboBoxField) Value() string
- type Destination
- type DestinationFit
- type DestinationFitB
- type DestinationFitBH
- type DestinationFitBV
- type DestinationFitH
- type DestinationFitR
- type DestinationFitV
- type DestinationType
- type DestinationXYZ
- func (d *DestinationXYZ) DestinationType() DestinationType
- func (d *DestinationXYZ) HasLeft() bool
- func (d *DestinationXYZ) HasTop() bool
- func (d *DestinationXYZ) HasZoom() bool
- func (d *DestinationXYZ) Left() float64
- func (d *DestinationXYZ) Page() *Page
- func (d *DestinationXYZ) Top() float64
- func (d *DestinationXYZ) Zoom() float64
- type Document
- func ImageToDocument(path string, opts ...ImageToDocumentOptions) (*Document, error)
- func ImageToDocumentFromStream(r io.Reader, opts ...ImageToDocumentOptions) (*Document, error)
- func NewDocument(width, height float64) *Document
- func NewDocumentFromFormat(format PageFormat) *Document
- func Open(path string) (*Document, error)
- func OpenStream(r io.Reader) (*Document, error)
- func OpenStreamWithPassword(r io.Reader, password string) (*Document, error)
- func OpenWithPassword(path, password string) (*Document, error)
- func (d *Document) AddBlankPage(width, height float64) error
- func (d *Document) AddBlankPageFromFormat(format PageFormat) error
- func (d *Document) AddSVGObjectWatermark(svg *SVG, pageNums ...int) error
- func (d *Document) AddSVGWatermark(path string, pageNums ...int) error
- func (d *Document) AddSVGWatermarkFromStream(r io.Reader, pageNums ...int) error
- func (d *Document) AddTextWatermark(text string, style TextStyle, pageNums ...int) error
- func (d *Document) Append(others ...*Document)
- func (d *Document) ApplyRedactions() error
- func (d *Document) ClearInfo()
- func (d *Document) ClearPageLabels()
- func (d *Document) ClearXMP()
- func (d *Document) DeletePage(n int) error
- func (d *Document) DeletePages(pageNums ...int) error
- func (d *Document) Extract(ranges ...PageRange) (*Document, error)
- func (d *Document) ExtractImages() ([][]Image, error)
- func (d *Document) ExtractText() ([]string, error)
- func (d *Document) ExtractTextWithLayout() ([][]TextLine, error)
- func (d *Document) Flatten() error
- func (d *Document) Form() *Form
- func (d *Document) ImageInfos() ([][]ImageInfo, error)
- func (d *Document) Info() (DocumentInfo, error)
- func (d *Document) InsertBlankPage(position int, width, height float64) error
- func (d *Document) InsertBlankPageFromFormat(position int, format PageFormat) error
- func (d *Document) LoadFont(path string) (Font, error)
- func (d *Document) LoadFontFromStream(r io.Reader) (Font, error)
- func (d *Document) LoadSVG(path string) (*SVG, error)
- func (d *Document) LoadSVGFromStream(r io.Reader) (*SVG, error)
- func (d *Document) NamedDestinations() *NamedDestinations
- func (d *Document) OptimizeImages(opts OptimizeImageOptions) (int, error)
- func (d *Document) Outlines() *OutlineItemCollection
- func (d *Document) Page(n int) (*Page, error)
- func (d *Document) PageCount() int
- func (d *Document) Pages() []*Page
- func (d *Document) Permissions() (Permissions, bool)
- func (d *Document) RemoveEncryption()
- func (d *Document) RemoveUnusedObjects() int
- func (d *Document) RenderImage(pageNum int, opts RenderOptions) (image.Image, error)
- func (d *Document) RenderTIFF(w io.Writer, opts RenderOptions, pageNums ...int) error
- func (d *Document) Reorder(order []int) error
- func (d *Document) Rotate(angle RotationAngle, pageNums ...int) error
- func (d *Document) Save(outputPath string) error
- func (d *Document) SearchText(query string, opts ...SearchOptions) ([]TextMatch, error)
- func (d *Document) SetEncryption(opts EncryptionOptions)
- func (d *Document) SetInfo(info DocumentInfo)
- func (d *Document) SetPageLabels(ranges []PageLabelRange) error
- func (d *Document) SetPassword(userPassword, ownerPassword string)
- func (d *Document) SetPermissions(p Permissions)
- func (d *Document) SetRotation(angle RotationAngle, pageNums ...int) error
- func (d *Document) SetSVGFontResolver(fn SVGFontResolver)
- func (d *Document) SetXMP(meta XMPMetadata) error
- func (d *Document) SetXMPRaw(data []byte) error
- func (d *Document) Split() ([]*Document, error)
- func (d *Document) SubsetFonts() (int, error)
- func (d *Document) SyncInfoToXMP() error
- func (d *Document) ValidateRedactions() error
- func (d *Document) WriteTo(w io.Writer) (int64, error)
- func (d *Document) XMP() (XMPMetadata, error)
- func (d *Document) XMPRaw() ([]byte, error)
- type DocumentInfo
- type EncryptionAlgorithm
- type EncryptionOptions
- type Field
- type FieldStyle
- type FileAttachmentAnnotation
- func (a *FileAttachmentAnnotation) AnnotationType() AnnotationType
- func (b *FileAttachmentAnnotation) Color() *Color
- func (b *FileAttachmentAnnotation) Contents() string
- func (a *FileAttachmentAnnotation) FileBytes() []byte
- func (a *FileAttachmentAnnotation) FileDescription() string
- func (a *FileAttachmentAnnotation) FileMIMEType() string
- func (a *FileAttachmentAnnotation) FileName() string
- func (a *FileAttachmentAnnotation) FileSize() int
- func (b *FileAttachmentAnnotation) Flatten() error
- func (a *FileAttachmentAnnotation) HasFile() bool
- func (a *FileAttachmentAnnotation) Icon() FileAttachmentIcon
- func (b *FileAttachmentAnnotation) PageIndex() int
- func (b *FileAttachmentAnnotation) Rect() Rectangle
- func (a *FileAttachmentAnnotation) RegenerateAppearance()
- func (b *FileAttachmentAnnotation) SetColor(c *Color)
- func (b *FileAttachmentAnnotation) SetContents(s string)
- func (a *FileAttachmentAnnotation) SetFile(path string) error
- func (a *FileAttachmentAnnotation) SetFileDescription(s string)
- func (a *FileAttachmentAnnotation) SetFileFromStream(r io.Reader, name string) error
- func (a *FileAttachmentAnnotation) SetIcon(i FileAttachmentIcon)
- func (b *FileAttachmentAnnotation) SetRect(r Rectangle)
- func (b *FileAttachmentAnnotation) SetTitle(s string)
- func (b *FileAttachmentAnnotation) Title() string
- type FileAttachmentIcon
- type Font
- type Form
- func (f *Form) AddCheckbox(pageNum int, rect Rectangle, name string) (*CheckboxField, error)
- func (f *Form) AddComboBox(pageNum int, rect Rectangle, name string, options []ChoiceOption) (*ComboBoxField, error)
- func (f *Form) AddListBox(pageNum int, rect Rectangle, name string, options []ChoiceOption) (*ListBoxField, error)
- func (f *Form) AddPushButton(pageNum int, rect Rectangle, name string, caption string) (*ButtonField, error)
- func (f *Form) AddRadioGroup(name string, items []RadioItem) (*RadioButtonField, error)
- func (f *Form) AddTextField(pageNum int, rect Rectangle, name string) (*TextBoxField, error)
- func (f *Form) Field(name string) Field
- func (f *Form) Fields() []Field
- func (f *Form) Flatten() error
- func (f *Form) HasField(name string) bool
- func (f *Form) NeedAppearances() bool
- func (f *Form) RemoveField(name string) bool
- func (f *Form) SetNeedAppearances(v bool)
- type FormFieldType
- type FreeTextAnnotation
- func (a *FreeTextAnnotation) AnnotationType() AnnotationType
- func (a *FreeTextAnnotation) BorderEffect() BorderEffect
- func (a *FreeTextAnnotation) BorderEffectIntensity() float64
- func (d *FreeTextAnnotation) BorderStyle() BorderStyle
- func (d *FreeTextAnnotation) BorderWidth() float64
- func (a *FreeTextAnnotation) CalloutPoints() []Point
- func (a *FreeTextAnnotation) Contents() string
- func (d *FreeTextAnnotation) DashPattern() []float64
- func (a *FreeTextAnnotation) EndLineEnding() LineEndingStyle
- func (a *FreeTextAnnotation) InnerRect() Rectangle
- func (a *FreeTextAnnotation) Intent() FreeTextIntent
- func (a *FreeTextAnnotation) RegenerateAppearance()
- func (a *FreeTextAnnotation) SetBorderEffect(e BorderEffect)
- func (a *FreeTextAnnotation) SetBorderEffectIntensity(i float64)
- func (d *FreeTextAnnotation) SetBorderStyle(s BorderStyle)
- func (d *FreeTextAnnotation) SetBorderWidth(w float64)
- func (a *FreeTextAnnotation) SetCalloutPoints(pts []Point)
- func (d *FreeTextAnnotation) SetColor(c *Color)
- func (a *FreeTextAnnotation) SetContents(s string)
- func (d *FreeTextAnnotation) SetDashPattern(p []float64)
- func (a *FreeTextAnnotation) SetEndLineEnding(s LineEndingStyle)
- func (a *FreeTextAnnotation) SetInnerRect(inner Rectangle)
- func (a *FreeTextAnnotation) SetIntent(i FreeTextIntent)
- func (d *FreeTextAnnotation) SetRect(r Rectangle)
- func (a *FreeTextAnnotation) SetTextStyle(s TextStyle)
- func (a *FreeTextAnnotation) TextStyle() TextStyle
- type FreeTextIntent
- type GenericAnnotation
- func (a *GenericAnnotation) AnnotationType() AnnotationType
- func (b *GenericAnnotation) Color() *Color
- func (b *GenericAnnotation) Contents() string
- func (b *GenericAnnotation) Flatten() error
- func (b *GenericAnnotation) PageIndex() int
- func (b *GenericAnnotation) Rect() Rectangle
- func (b *GenericAnnotation) SetColor(c *Color)
- func (b *GenericAnnotation) SetContents(s string)
- func (b *GenericAnnotation) SetRect(r Rectangle)
- func (b *GenericAnnotation) SetTitle(s string)
- func (b *GenericAnnotation) Title() string
- type GifDevice
- type GoToAction
- type GoToURIAction
- type Gradient
- type GradientStop
- type HAlign
- type HighlightAnnotation
- func (a *HighlightAnnotation) AnnotationType() AnnotationType
- func (b *HighlightAnnotation) Color() *Color
- func (b *HighlightAnnotation) Contents() string
- func (b *HighlightAnnotation) Flatten() error
- func (b *HighlightAnnotation) PageIndex() int
- func (a *HighlightAnnotation) QuadPoints() []QuadPoint
- func (b *HighlightAnnotation) Rect() Rectangle
- func (b *HighlightAnnotation) SetColor(c *Color)
- func (b *HighlightAnnotation) SetContents(s string)
- func (a *HighlightAnnotation) SetQuadPoints(qp []QuadPoint)
- func (b *HighlightAnnotation) SetRect(r Rectangle)
- func (b *HighlightAnnotation) SetTitle(s string)
- func (b *HighlightAnnotation) Title() string
- type Image
- type ImageColorSpace
- type ImageFormat
- type ImageInfo
- type ImageToDocumentOptions
- type InkAnnotation
- func (a *InkAnnotation) AddStroke(stroke []Point)
- func (a *InkAnnotation) AnnotationType() AnnotationType
- func (d *InkAnnotation) BorderStyle() BorderStyle
- func (d *InkAnnotation) BorderWidth() float64
- func (d *InkAnnotation) DashPattern() []float64
- func (a *InkAnnotation) RegenerateAppearance()
- func (d *InkAnnotation) SetBorderStyle(s BorderStyle)
- func (a *InkAnnotation) SetBorderWidth(w float64)
- func (d *InkAnnotation) SetColor(c *Color)
- func (d *InkAnnotation) SetDashPattern(p []float64)
- func (d *InkAnnotation) SetRect(r Rectangle)
- func (a *InkAnnotation) SetStrokes(strokes [][]Point)
- func (a *InkAnnotation) Strokes() [][]Point
- type JavaScriptAction
- type JpegDevice
- type LineAnnotation
- func (a *LineAnnotation) AnnotationType() AnnotationType
- func (d *LineAnnotation) BorderStyle() BorderStyle
- func (d *LineAnnotation) BorderWidth() float64
- func (d *LineAnnotation) DashPattern() []float64
- func (a *LineAnnotation) End() Point
- func (a *LineAnnotation) EndLineEnding() LineEndingStyle
- func (a *LineAnnotation) InteriorColor() *Color
- func (a *LineAnnotation) LeaderLineLength() float64
- func (a *LineAnnotation) RegenerateAppearance()
- func (d *LineAnnotation) SetBorderStyle(s BorderStyle)
- func (a *LineAnnotation) SetBorderWidth(w float64)
- func (d *LineAnnotation) SetColor(c *Color)
- func (d *LineAnnotation) SetDashPattern(p []float64)
- func (a *LineAnnotation) SetEnd(p Point)
- func (a *LineAnnotation) SetEndLineEnding(s LineEndingStyle)
- func (a *LineAnnotation) SetInteriorColor(c *Color)
- func (a *LineAnnotation) SetLeaderLineLength(l float64)
- func (d *LineAnnotation) SetRect(r Rectangle)
- func (a *LineAnnotation) SetStart(p Point)
- func (a *LineAnnotation) SetStartLineEnding(s LineEndingStyle)
- func (a *LineAnnotation) Start() Point
- func (a *LineAnnotation) StartLineEnding() LineEndingStyle
- type LineCap
- type LineEndingStyle
- type LineJoin
- type LineStyle
- type LinearGradient
- type LinkAnnotation
- func (a *LinkAnnotation) Action() Action
- func (a *LinkAnnotation) AnnotationType() AnnotationType
- func (a *LinkAnnotation) BorderWidth() float64
- func (b *LinkAnnotation) Color() *Color
- func (b *LinkAnnotation) Contents() string
- func (b *LinkAnnotation) Flatten() error
- func (a *LinkAnnotation) Highlight() LinkHighlightMode
- func (b *LinkAnnotation) PageIndex() int
- func (b *LinkAnnotation) Rect() Rectangle
- func (a *LinkAnnotation) SetAction(act Action)
- func (a *LinkAnnotation) SetBorderWidth(width float64)
- func (b *LinkAnnotation) SetColor(c *Color)
- func (b *LinkAnnotation) SetContents(s string)
- func (a *LinkAnnotation) SetHighlight(h LinkHighlightMode)
- func (b *LinkAnnotation) SetRect(r Rectangle)
- func (b *LinkAnnotation) SetTitle(s string)
- func (b *LinkAnnotation) Title() string
- type LinkHighlightMode
- type ListBoxField
- func (f *ListBoxField) AddOption(o ChoiceOption)
- func (b *ListBoxField) Flatten() error
- func (b *ListBoxField) FullName() string
- func (b *ListBoxField) IsReadOnly() bool
- func (b *ListBoxField) IsRequired() bool
- func (f *ListBoxField) MultiSelect() bool
- func (f *ListBoxField) Options() []ChoiceOption
- func (b *ListBoxField) PageIndex() int
- func (b *ListBoxField) PartialName() string
- func (b *ListBoxField) Rect() Rectangle
- func (f *ListBoxField) RemoveOption(index int) error
- func (f *ListBoxField) Selected() []int
- func (f *ListBoxField) SetMultiSelect(v bool)
- func (f *ListBoxField) SetReadOnly(v bool)
- func (f *ListBoxField) SetRequired(v bool)
- func (f *ListBoxField) SetSelected(indices ...int) error
- func (b *ListBoxField) SetStyle(s FieldStyle) error
- func (f *ListBoxField) SetValue(s string) error
- func (b *ListBoxField) Style() FieldStyle
- func (f *ListBoxField) Value() string
- type MarginInfo
- type NamedAction
- type NamedActionType
- type NamedDestination
- type NamedDestinations
- func (n *NamedDestinations) Add(name string, dest Destination) error
- func (n *NamedDestinations) All() map[string]Destination
- func (n *NamedDestinations) Clear()
- func (n *NamedDestinations) Count() int
- func (n *NamedDestinations) Document() *Document
- func (n *NamedDestinations) Get(name string) Destination
- func (n *NamedDestinations) Has(name string) bool
- func (n *NamedDestinations) Names() []string
- func (n *NamedDestinations) Remove(name string) bool
- type OptimizeImageOptions
- type OutlineItemCollection
- func (o *OutlineItemCollection) Action() Action
- func (o *OutlineItemCollection) Add(child *OutlineItemCollection) error
- func (o *OutlineItemCollection) All() []*OutlineItemCollection
- func (o *OutlineItemCollection) At(index int) *OutlineItemCollection
- func (o *OutlineItemCollection) Bold() bool
- func (o *OutlineItemCollection) Color() *Color
- func (o *OutlineItemCollection) Count() int
- func (o *OutlineItemCollection) Destination() Destination
- func (o *OutlineItemCollection) Document() *Document
- func (o *OutlineItemCollection) Insert(index int, child *OutlineItemCollection) error
- func (o *OutlineItemCollection) IsExpanded() bool
- func (o *OutlineItemCollection) Italic() bool
- func (o *OutlineItemCollection) Parent() *OutlineItemCollection
- func (o *OutlineItemCollection) Remove(child *OutlineItemCollection) bool
- func (o *OutlineItemCollection) RemoveAt(index int) error
- func (o *OutlineItemCollection) SetAction(a Action)
- func (o *OutlineItemCollection) SetBold(b bool)
- func (o *OutlineItemCollection) SetColor(c *Color)
- func (o *OutlineItemCollection) SetDestination(d Destination)
- func (o *OutlineItemCollection) SetIsExpanded(b bool)
- func (o *OutlineItemCollection) SetItalic(b bool)
- func (o *OutlineItemCollection) SetTitle(s string)
- func (o *OutlineItemCollection) Title() string
- type Page
- func (p *Page) AddImage(path string, rect Rectangle) error
- func (p *Page) AddImageFromStream(r io.Reader, rect Rectangle) error
- func (p *Page) AddSVG(path string, rect Rectangle) error
- func (p *Page) AddSVGFromStream(r io.Reader, rect Rectangle) error
- func (p *Page) AddSVGObject(svg *SVG, rect Rectangle) error
- func (p *Page) AddTable(t *Table, rect Rectangle) (int, error)
- func (p *Page) AddText(text string, style TextStyle, rect Rectangle) error
- func (p *Page) Annotations() *AnnotationCollection
- func (p *Page) ArtBox() (Rectangle, error)
- func (p *Page) BleedBox() (Rectangle, error)
- func (p *Page) CropBox() (Rectangle, error)
- func (p *Page) DrawCircle(center Point, radius float64, style ShapeStyle) error
- func (p *Page) DrawEllipse(center Point, rx, ry float64, style ShapeStyle) error
- func (p *Page) DrawLine(from, to Point, style LineStyle) error
- func (p *Page) DrawPath(path *Path, style ShapeStyle) error
- func (p *Page) DrawPolygon(points []Point, style ShapeStyle) error
- func (p *Page) DrawPolyline(points []Point, style LineStyle) error
- func (p *Page) DrawRectangle(rect Rectangle, style ShapeStyle) error
- func (p *Page) DrawRoundedRectangle(rect Rectangle, radius float64, style ShapeStyle) error
- func (p *Page) ExtractImages() ([]Image, error)
- func (p *Page) ExtractText() (string, error)
- func (p *Page) ExtractTextWithLayout() ([]TextLine, error)
- func (p *Page) ImageInfos() ([]ImageInfo, error)
- func (p *Page) Label() string
- func (p *Page) MediaBox() (Rectangle, error)
- func (p *Page) Number() int
- func (p *Page) RenderBMP(w io.Writer, opts RenderOptions) error
- func (p *Page) RenderGIF(w io.Writer, opts RenderOptions) error
- func (p *Page) RenderImage(opts RenderOptions) (image.Image, error)
- func (p *Page) RenderJPEG(w io.Writer, opts RenderOptions, quality int) error
- func (p *Page) RenderPNG(w io.Writer, opts RenderOptions) error
- func (p *Page) RenderTIFF(w io.Writer, opts RenderOptions) error
- func (p *Page) Rotation() RotationAngle
- func (p *Page) SearchText(query string, opts ...SearchOptions) ([]TextMatch, error)
- func (p *Page) SetArtBox(rect Rectangle) error
- func (p *Page) SetBleedBox(rect Rectangle) error
- func (p *Page) SetCropBox(rect Rectangle) error
- func (p *Page) SetMediaBox(rect Rectangle) error
- func (p *Page) SetPageSize(width, height float64) error
- func (p *Page) SetTrimBox(rect Rectangle) error
- func (p *Page) Size() (PageSize, error)
- func (p *Page) TrimBox() (Rectangle, error)
- type PageFormat
- type PageLabelRange
- type PageLabelStyle
- type PageRange
- type PageSize
- type Path
- type Permissions
- type PngDevice
- type Point
- type QuadPoint
- type RadialGradient
- type RadioButtonField
- func (b *RadioButtonField) Flatten() error
- func (b *RadioButtonField) FullName() string
- func (b *RadioButtonField) IsReadOnly() bool
- func (b *RadioButtonField) IsRequired() bool
- func (f *RadioButtonField) Options() []*RadioButtonOptionField
- func (b *RadioButtonField) PageIndex() int
- func (b *RadioButtonField) PartialName() string
- func (b *RadioButtonField) Rect() Rectangle
- func (f *RadioButtonField) SetReadOnly(v bool)
- func (f *RadioButtonField) SetRequired(v bool)
- func (b *RadioButtonField) SetStyle(s FieldStyle) error
- func (f *RadioButtonField) SetValue(s string) error
- func (b *RadioButtonField) Style() FieldStyle
- func (f *RadioButtonField) Value() string
- type RadioButtonOptionField
- type RadioItem
- type Rectangle
- type RedactAnnotation
- func (a *RedactAnnotation) AnnotationType() AnnotationType
- func (d *RedactAnnotation) BorderStyle() BorderStyle
- func (d *RedactAnnotation) BorderWidth() float64
- func (d *RedactAnnotation) DashPattern() []float64
- func (a *RedactAnnotation) InteriorColor() *Color
- func (a *RedactAnnotation) OverlayText() string
- func (a *RedactAnnotation) OverlayTextStyle() TextStyle
- func (a *RedactAnnotation) QuadPoints() []QuadPoint
- func (a *RedactAnnotation) RegenerateAppearance()
- func (a *RedactAnnotation) RepeatOverlayText() bool
- func (d *RedactAnnotation) SetBorderStyle(s BorderStyle)
- func (d *RedactAnnotation) SetBorderWidth(w float64)
- func (d *RedactAnnotation) SetColor(c *Color)
- func (d *RedactAnnotation) SetDashPattern(p []float64)
- func (a *RedactAnnotation) SetInteriorColor(c *Color)
- func (a *RedactAnnotation) SetOverlayText(s string)
- func (a *RedactAnnotation) SetOverlayTextStyle(s TextStyle)
- func (a *RedactAnnotation) SetQuadPoints(qp []QuadPoint)
- func (d *RedactAnnotation) SetRect(r Rectangle)
- func (a *RedactAnnotation) SetRepeatOverlayText(repeat bool)
- type RenderOptions
- type ResetFormAction
- type Resolution
- type RotationAngle
- type Row
- func (r *Row) AddCell(text string) *Cell
- func (r *Row) AddCells(texts ...string) []*Cell
- func (r *Row) Background() *Color
- func (r *Row) Border() *BorderInfo
- func (r *Row) CellCount() int
- func (r *Row) Cells() []*Cell
- func (r *Row) Height() float64
- func (r *Row) Margin() *MarginInfo
- func (r *Row) SetBackground(col *Color) *Row
- func (r *Row) SetBorder(b BorderInfo) *Row
- func (r *Row) SetHeight(h float64) *Row
- func (r *Row) SetMargin(m MarginInfo) *Row
- func (r *Row) SetTextStyle(s TextStyle) *Row
- func (r *Row) Table() *Table
- func (r *Row) TextStyle() *TextStyle
- type SVG
- type SVGFontResolver
- type SearchOptions
- type ShapeStyle
- type SquareAnnotation
- func (a *SquareAnnotation) AnnotationType() AnnotationType
- func (d *SquareAnnotation) BorderStyle() BorderStyle
- func (d *SquareAnnotation) BorderWidth() float64
- func (d *SquareAnnotation) DashPattern() []float64
- func (a *SquareAnnotation) InteriorColor() *Color
- func (a *SquareAnnotation) RegenerateAppearance()
- func (d *SquareAnnotation) SetBorderStyle(s BorderStyle)
- func (d *SquareAnnotation) SetBorderWidth(w float64)
- func (d *SquareAnnotation) SetColor(c *Color)
- func (d *SquareAnnotation) SetDashPattern(p []float64)
- func (a *SquareAnnotation) SetInteriorColor(c *Color)
- func (d *SquareAnnotation) SetRect(r Rectangle)
- type SquigglyAnnotation
- func (a *SquigglyAnnotation) AnnotationType() AnnotationType
- func (b *SquigglyAnnotation) Color() *Color
- func (b *SquigglyAnnotation) Contents() string
- func (b *SquigglyAnnotation) Flatten() error
- func (b *SquigglyAnnotation) PageIndex() int
- func (a *SquigglyAnnotation) QuadPoints() []QuadPoint
- func (b *SquigglyAnnotation) Rect() Rectangle
- func (b *SquigglyAnnotation) SetColor(c *Color)
- func (b *SquigglyAnnotation) SetContents(s string)
- func (a *SquigglyAnnotation) SetQuadPoints(qp []QuadPoint)
- func (b *SquigglyAnnotation) SetRect(r Rectangle)
- func (b *SquigglyAnnotation) SetTitle(s string)
- func (b *SquigglyAnnotation) Title() string
- type StampAnnotation
- func (a *StampAnnotation) AnnotationType() AnnotationType
- func (d *StampAnnotation) BorderStyle() BorderStyle
- func (d *StampAnnotation) BorderWidth() float64
- func (a *StampAnnotation) ClearCustomImage()
- func (d *StampAnnotation) DashPattern() []float64
- func (a *StampAnnotation) HasCustomImage() bool
- func (a *StampAnnotation) Name() StampName
- func (a *StampAnnotation) RawName() string
- func (a *StampAnnotation) RegenerateAppearance()
- func (d *StampAnnotation) SetBorderStyle(s BorderStyle)
- func (d *StampAnnotation) SetBorderWidth(w float64)
- func (d *StampAnnotation) SetColor(c *Color)
- func (a *StampAnnotation) SetCustomImage(path string) error
- func (a *StampAnnotation) SetCustomImageFromStream(r io.Reader) error
- func (d *StampAnnotation) SetDashPattern(p []float64)
- func (a *StampAnnotation) SetName(n StampName)
- func (a *StampAnnotation) SetRawName(s string)
- func (d *StampAnnotation) SetRect(r Rectangle)
- type StampName
- type StrikeOutAnnotation
- func (a *StrikeOutAnnotation) AnnotationType() AnnotationType
- func (b *StrikeOutAnnotation) Color() *Color
- func (b *StrikeOutAnnotation) Contents() string
- func (b *StrikeOutAnnotation) Flatten() error
- func (b *StrikeOutAnnotation) PageIndex() int
- func (a *StrikeOutAnnotation) QuadPoints() []QuadPoint
- func (b *StrikeOutAnnotation) Rect() Rectangle
- func (b *StrikeOutAnnotation) SetColor(c *Color)
- func (b *StrikeOutAnnotation) SetContents(s string)
- func (a *StrikeOutAnnotation) SetQuadPoints(qp []QuadPoint)
- func (b *StrikeOutAnnotation) SetRect(r Rectangle)
- func (b *StrikeOutAnnotation) SetTitle(s string)
- func (b *StrikeOutAnnotation) Title() string
- type SubmitFormAction
- func (a *SubmitFormAction) ActionType() ActionType
- func (a *SubmitFormAction) FieldNames() []string
- func (a *SubmitFormAction) Flags() SubmitFormFlags
- func (a *SubmitFormAction) SetFieldNames(f []string)
- func (a *SubmitFormAction) SetFlags(f SubmitFormFlags)
- func (a *SubmitFormAction) SetURL(u string)
- func (a *SubmitFormAction) URL() string
- type SubmitFormFlags
- type Table
- func (t *Table) AddRow() *Row
- func (t *Table) AddRows(rows [][]string) []*Row
- func (t *Table) Border() BorderInfo
- func (t *Table) ColumnWidths() []float64
- func (t *Table) DefaultCellBorder() BorderInfo
- func (t *Table) DefaultCellMargin() MarginInfo
- func (t *Table) DefaultCellStyle() TextStyle
- func (t *Table) OverflowMargins() (top, bottom float64)
- func (t *Table) RepeatingRowsCount() int
- func (t *Table) RowCount() int
- func (t *Table) Rows() []*Row
- func (t *Table) SetBorder(b BorderInfo) *Table
- func (t *Table) SetColumnWidths(widths []float64) *Table
- func (t *Table) SetDefaultCellBorder(b BorderInfo) *Table
- func (t *Table) SetDefaultCellMargin(m MarginInfo) *Table
- func (t *Table) SetDefaultCellStyle(s TextStyle) *Table
- func (t *Table) SetOverflowMargins(top, bottom float64) *Table
- func (t *Table) SetRepeatingRowsCount(n int) *Table
- type TextAnnotation
- func (a *TextAnnotation) AnnotationType() AnnotationType
- func (b *TextAnnotation) Color() *Color
- func (b *TextAnnotation) Contents() string
- func (b *TextAnnotation) Flatten() error
- func (a *TextAnnotation) Icon() TextIcon
- func (a *TextAnnotation) Open() bool
- func (b *TextAnnotation) PageIndex() int
- func (b *TextAnnotation) Rect() Rectangle
- func (a *TextAnnotation) RegenerateAppearance()
- func (b *TextAnnotation) SetColor(c *Color)
- func (b *TextAnnotation) SetContents(s string)
- func (a *TextAnnotation) SetIcon(t TextIcon)
- func (a *TextAnnotation) SetOpen(open bool)
- func (b *TextAnnotation) SetRect(r Rectangle)
- func (b *TextAnnotation) SetTitle(s string)
- func (b *TextAnnotation) Title() string
- type TextBoxField
- func (b *TextBoxField) Flatten() error
- func (b *TextBoxField) FullName() string
- func (f *TextBoxField) IsMultiline() bool
- func (f *TextBoxField) IsPassword() bool
- func (b *TextBoxField) IsReadOnly() bool
- func (b *TextBoxField) IsRequired() bool
- func (f *TextBoxField) MaxLen() int
- func (b *TextBoxField) PageIndex() int
- func (b *TextBoxField) PartialName() string
- func (b *TextBoxField) Rect() Rectangle
- func (f *TextBoxField) SetMaxLen(n int)
- func (f *TextBoxField) SetMultiline(v bool)
- func (f *TextBoxField) SetPassword(v bool)
- func (f *TextBoxField) SetReadOnly(v bool)
- func (f *TextBoxField) SetRequired(v bool)
- func (b *TextBoxField) SetStyle(s FieldStyle) error
- func (f *TextBoxField) SetValue(s string) error
- func (b *TextBoxField) Style() FieldStyle
- func (f *TextBoxField) Value() string
- type TextFragment
- type TextIcon
- type TextLine
- type TextMatch
- type TextStyle
- type TiffDevice
- type UnderlineAnnotation
- func (a *UnderlineAnnotation) AnnotationType() AnnotationType
- func (b *UnderlineAnnotation) Color() *Color
- func (b *UnderlineAnnotation) Contents() string
- func (b *UnderlineAnnotation) Flatten() error
- func (b *UnderlineAnnotation) PageIndex() int
- func (a *UnderlineAnnotation) QuadPoints() []QuadPoint
- func (b *UnderlineAnnotation) Rect() Rectangle
- func (b *UnderlineAnnotation) SetColor(c *Color)
- func (b *UnderlineAnnotation) SetContents(s string)
- func (a *UnderlineAnnotation) SetQuadPoints(qp []QuadPoint)
- func (b *UnderlineAnnotation) SetRect(r Rectangle)
- func (b *UnderlineAnnotation) SetTitle(s string)
- func (b *UnderlineAnnotation) Title() string
- type VAlign
- type ValidationIssue
- type ValidationReport
- type WidgetAnnotation
- func (a *WidgetAnnotation) AnnotationType() AnnotationType
- func (b *WidgetAnnotation) Color() *Color
- func (b *WidgetAnnotation) Contents() string
- func (b *WidgetAnnotation) Flatten() error
- func (b *WidgetAnnotation) PageIndex() int
- func (b *WidgetAnnotation) Rect() Rectangle
- func (b *WidgetAnnotation) SetColor(c *Color)
- func (b *WidgetAnnotation) SetContents(s string)
- func (b *WidgetAnnotation) SetRect(r Rectangle)
- func (b *WidgetAnnotation) SetTitle(s string)
- func (b *WidgetAnnotation) Title() string
- type XMPMetadata
- type XMPProperty
Examples ¶
- Document.AddSVGWatermark
- Document.AddTextWatermark
- Document.Append
- Document.Extract
- Document.ExtractText
- Document.Rotate
- Document.SetEncryption
- Document.Split
- ImageToDocument
- NewDocumentFromFormat
- NewLinkAnnotation
- NewTable
- Open
- OpenWithPassword
- Page.AddImage
- Page.AddText
- Page.DrawRectangle
- Validate
Constants ¶
const DefaultDPI = 150
DefaultDPI is the rendering resolution used when RenderOptions.DPI is unset. 150 matches Aspose.PDF for .NET's default Resolution.
Variables ¶
var ( PageFormatA3 = PageFormat{Width: 842, Height: 1191} PageFormatA4 = PageFormat{Width: 595, Height: 842} PageFormatLetter = PageFormat{Width: 612, Height: 792} PageFormatLegal = PageFormat{Width: 612, Height: 1008} )
Predefined page formats (portrait orientation).
var ErrEncrypted = errors.New("PDF is encrypted; use OpenWithPassword")
ErrEncrypted is returned by Open / OpenStream when the input PDF carries an /Encrypt dictionary. Callers should retry with OpenWithPassword or OpenStreamWithPassword to supply a user or owner password.
Functions ¶
func AddFontFile ¶ added in v0.3.0
func AddFontFile(path string)
AddFontFile registers a single font file. Mirrors a FileFontSource.
func AddFontFolder ¶ added in v0.3.0
func AddFontFolder(path string)
AddFontFolder registers a directory searched (recursively) for fonts when rendering. Mirrors adding a FolderFontSource in Aspose.PDF for .NET.
func AddSystemFonts ¶ added in v0.3.0
func AddSystemFonts()
AddSystemFonts registers the operating system's standard font directories. Mirrors adding a SystemFontSource. Not enabled by default — call it to let the renderer use installed fonts (e.g. real Arial / Times New Roman).
func ClearFontSources ¶ added in v0.3.0
func ClearFontSources()
ClearFontSources removes all registered folders and files.
func Encrypt ¶
Encrypt writes a password-protected copy of inputPath to outputPath. The document is encrypted using RC4-128 (PDF 1.4 Standard Security Handler, revision 3). userPassword is required to open the document; ownerPassword controls permission settings. If ownerPassword is empty, it defaults to userPassword.
Example:
err := asposepdf.Encrypt("input.pdf", "output.pdf", "secret", "")
Types ¶
type Action ¶
type Action interface {
ActionType() ActionType
// contains filtered or unexported methods
}
Action is the common interface implemented by every concrete action type. Action values are inline within the parent annotation's /A dict — they are not separately addressable PDF objects.
type ActionType ¶
type ActionType int
ActionType identifies the kind of action attached to an annotation (typically a LinkAnnotation's /A entry).
const ( ActionTypeUnknown ActionType = iota ActionTypeGoToURI ActionTypeGoTo ActionTypeNamed ActionTypeSubmitForm ActionTypeResetForm ActionTypeJavaScript )
type Annotation ¶
type Annotation interface {
AnnotationType() AnnotationType
Rect() Rectangle
SetRect(r Rectangle)
Color() *Color
SetColor(c *Color)
Title() string
SetTitle(s string)
Contents() string
SetContents(s string)
PageIndex() int
// Flatten bakes this annotation's normal appearance into the page
// content and removes the annotation, making it non-interactive. See
// (*annotationBase).Flatten in flatten.go.
Flatten() error
// contains filtered or unexported methods
}
Annotation is the common interface implemented by every concrete annotation type. Page-scoped — annotations belong to a specific page and are managed through that page's AnnotationCollection.
type AnnotationCollection ¶
type AnnotationCollection struct {
// contains filtered or unexported fields
}
AnnotationCollection is the live, ordered set of annotations attached to a single page. Mutations through Add / Delete propagate to the page dict's /Annots array and to the document's object table; the next Save writes them out.
func (*AnnotationCollection) Add ¶
func (c *AnnotationCollection) Add(a Annotation) error
Add attaches an annotation to this page. Errors if the annotation is already attached to a different page; idempotent same-page Add returns nil. Panics on nil annotation (programmer error).
func (*AnnotationCollection) All ¶
func (c *AnnotationCollection) All() []Annotation
All returns the page's annotations as a slice. Each Annotation in the slice is a live handle: mutations write through to the underlying pdfDict and are visible to callers holding the same handle.
func (*AnnotationCollection) At ¶
func (c *AnnotationCollection) At(index int) Annotation
At returns the annotation at the given index. Panics if out of range.
func (*AnnotationCollection) Count ¶
func (c *AnnotationCollection) Count() int
Count reports how many annotations live on this page.
func (*AnnotationCollection) Delete ¶
func (c *AnnotationCollection) Delete(a Annotation) bool
Delete removes the annotation from this page. Returns true if found, false otherwise. The annotation handle becomes dangling after Delete: mutations through it write to an unlinked dict that is no longer reachable from the document and are silently dropped on next Save.
func (*AnnotationCollection) DeleteAt ¶
func (c *AnnotationCollection) DeleteAt(index int) error
DeleteAt removes the annotation at the given index. Errors on out-of-range index. The annotation handle becomes dangling after DeleteAt — see Delete for the dangling-handle semantics.
func (*AnnotationCollection) Flatten ¶ added in v0.3.0
func (c *AnnotationCollection) Flatten() error
Flatten bakes every annotation on the page into the page content and removes it. Widget annotations (form-field widgets) are skipped — flatten those via (*Document).Flatten or (*Form).Flatten so the /AcroForm is cleaned up too.
type AnnotationType ¶
type AnnotationType int
AnnotationType identifies the kind of annotation. Returned by Annotation.AnnotationType() so callers can switch on type without a type-assertion ladder.
const ( AnnotationTypeUnknown AnnotationType = iota AnnotationTypeLink AnnotationTypeHighlight AnnotationTypeUnderline AnnotationTypeStrikeOut AnnotationTypeSquiggly AnnotationTypeWidget AnnotationTypeSquare AnnotationTypeCircle AnnotationTypeLine AnnotationTypeInk AnnotationTypeText AnnotationTypeFreeText AnnotationTypeStamp AnnotationTypeFileAttachment AnnotationTypeRedact )
type BmpDevice ¶ added in v0.3.0
type BmpDevice struct {
// contains filtered or unexported fields
}
BmpDevice renders a page to BMP. Mirrors Aspose.PDF for .NET's BmpDevice.
func NewBmpDevice ¶ added in v0.3.0
func NewBmpDevice(res Resolution) *BmpDevice
NewBmpDevice returns a BmpDevice for the given resolution.
type BorderEffect ¶
type BorderEffect int
BorderEffect controls the /BE/S entry per ISO 32000-1 §12.5.4 Table 167.
const ( BorderEffectNone BorderEffect = iota // /S = /S (default) BorderEffectCloudy // /S = /C — wavy "cloud" border )
type BorderInfo ¶
type BorderInfo struct {
Sides BorderSide
Width float64 // in points; 0 means no border regardless of Sides
Color *Color // nil → black (R:0 G:0 B:0 A:1)
}
BorderInfo describes a border drawn around a table or cell. Mirrors Aspose.PDF for .NET's BorderInfo. Zero value means "no border".
type BorderSide ¶
type BorderSide int
BorderSide is a bitmask selecting which sides of a rectangular border are drawn.
const ( BorderSideNone BorderSide = 0 BorderSideTop BorderSide = 1 BorderSideRight BorderSide = 2 BorderSideBottom BorderSide = 4 BorderSideLeft BorderSide = 8 BorderSideAll = BorderSideTop | BorderSideRight | BorderSideBottom | BorderSideLeft )
type BorderStyle ¶
type BorderStyle int
BorderStyle controls the /BS dict for drawing annotations per ISO 32000-1 §12.5.4 Table 168.
const ( BorderSolid BorderStyle = iota // /S = /S BorderDashed // /S = /D + /D dash array BorderBeveled // /S = /B (3D raised effect) BorderInset // /S = /I (3D recessed effect) BorderUnderline // /S = /U (only the bottom edge) )
type ButtonAppearance ¶ added in v0.3.0
type ButtonAppearance struct {
Caption string // /MK/CA — normal-state caption
RolloverText string // /MK/RC — caption while hovered (falls back to Caption)
DownText string // /MK/AC — caption while pressed (falls back to Caption)
IconPath string // optional icon image (PNG/JPEG), baked into the /AP streams
IconPosition ButtonIconPosition // /MK/TP — icon vs caption layout
TextColor *Color // caption colour (default dark grey)
FaceColor *Color // button face fill (default light grey)
BorderColor *Color // button border (default grey)
}
ButtonAppearance configures a push button's rich appearance: separate captions for the normal / rollover / down states, an optional icon image, and face/border/text colours. Applied via (*ButtonField).SetAppearance, which writes the /MK appearance- characteristics dict and bakes /AP/N, /AP/R, and /AP/D appearance streams so the button reacts to hover and press in every viewer.
Out of scope (follow-up): caption rotation (/MK/R) and exposing the icon as a /MK/I Form XObject for viewer-side regeneration — the icon is rendered directly into the /AP streams here, which renders in any viewer without relying on regeneration.
type ButtonField ¶
type ButtonField struct {
// contains filtered or unexported fields
}
ButtonField is a push button — action only, no value semantics.
func (*ButtonField) Flatten ¶ added in v0.3.0
func (b *ButtonField) Flatten() error
Flatten bakes this single field's appearance (each of its widgets) into the owning page content and removes the field, leaving every other field and the /AcroForm dict intact. Mirrors Aspose.PDF for .NET's Field.Flatten.
After Flatten the field handle is dangling and must not be used.
func (*ButtonField) IsReadOnly ¶
func (b *ButtonField) IsReadOnly() bool
func (*ButtonField) IsRequired ¶
func (b *ButtonField) IsRequired() bool
func (*ButtonField) PartialName ¶
func (b *ButtonField) PartialName() string
func (*ButtonField) SetAppearance ¶ added in v0.3.0
func (f *ButtonField) SetAppearance(a ButtonAppearance) error
SetAppearance applies a ButtonAppearance to the push button: it writes the /MK characteristics (/CA, /RC, /AC, /TP) and regenerates the widget's /AP with distinct /N (normal), /R (rollover), and /D (down) appearance streams. Returns an error if the field has no widget or the icon image cannot be read.
func (*ButtonField) SetReadOnly ¶
func (f *ButtonField) SetReadOnly(v bool)
func (*ButtonField) SetStyle ¶ added in v0.3.0
func (b *ButtonField) SetStyle(s FieldStyle) error
SetStyle applies s to the field, writing /MK, /BS, /DA, and /Q on the field and its widgets and regenerating each widget's /AP appearance so the new look is visible immediately in every viewer. Returns an error only if the field is detached or a styled font cannot be registered.
func (*ButtonField) SetValue ¶
func (f *ButtonField) SetValue(s string) error
func (*ButtonField) Style ¶ added in v0.3.0
func (b *ButtonField) Style() FieldStyle
Style reads back the field's current styling from /DA, /Q, /MK, and /BS. Properties never set return their zero/default value. The first widget is used for /MK and /BS.
func (*ButtonField) Value ¶
func (f *ButtonField) Value() string
type ButtonIconPosition ¶ added in v0.3.0
type ButtonIconPosition int
ButtonIconPosition controls how a push button lays out its icon and caption — the /MK /TP entry per ISO 32000-1 §12.5.6.19 Table 189.
const ( ButtonCaptionOnly ButtonIconPosition = 0 // /TP 0 — caption only, no icon ButtonIconOnly ButtonIconPosition = 1 // /TP 1 — icon only, no caption ButtonIconAboveCaption ButtonIconPosition = 2 // /TP 2 — caption below the icon ButtonCaptionOverIcon ButtonIconPosition = 6 // /TP 6 — caption overlaid on the icon )
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
Cell is a single cell within a Row.
func (*Cell) Background ¶
func (*Cell) Border ¶
func (c *Cell) Border() *BorderInfo
func (*Cell) Image ¶
Image returns the configured image source. path is empty when the image was set from a stream. hasImage is true when any image source is set.
func (*Cell) Margin ¶
func (c *Cell) Margin() *MarginInfo
func (*Cell) SetBackground ¶
func (*Cell) SetBorder ¶
func (c *Cell) SetBorder(b BorderInfo) *Cell
func (*Cell) SetColSpan ¶
SetColSpan sets the column span (cells the cell occupies horizontally). Default 1. Mirrors Aspose.PDF for .NET's Cell.ColSpan.
When colSpan > 1, the caller does NOT add cells for the positions covered by the span — the row simply has fewer cells.
func (*Cell) SetImage ¶
SetImage configures the cell to render the named image instead of text. PNG and JPEG supported (format auto-detected by magic bytes).
If both SetText and SetImage are configured, the image wins.
The image is auto-sized to fit the cell's interior width (sum of spanned column widths minus padding), preserving aspect ratio. Row height auto-fit computes the resulting image height plus margins. Use Row.SetHeight to override row height; the image then scales down to fit if needed.
Mirrors Aspose.PDF for .NET's Cell.Image property.
func (*Cell) SetImageFromStream ¶
SetImageFromStream is the io.Reader-based counterpart. The full stream is buffered immediately so that the table renderer can measure and draw later.
func (*Cell) SetMargin ¶
func (c *Cell) SetMargin(m MarginInfo) *Cell
func (*Cell) SetRowSpan ¶
SetRowSpan sets the row span (rows the cell occupies vertically). Default 1. Mirrors Aspose.PDF for .NET's Cell.RowSpan.
When rowSpan > 1, the caller does NOT add cells in subsequent rows for the positions covered by the span — those rows simply have fewer cells.
func (*Cell) SetTextStyle ¶
SetTextStyle overrides the table's DefaultCellStyle for this cell.
type CheckboxField ¶
type CheckboxField struct {
// contains filtered or unexported fields
}
CheckboxField is a checkbox with on/off state.
func (*CheckboxField) Checked ¶
func (f *CheckboxField) Checked() bool
func (*CheckboxField) Flatten ¶ added in v0.3.0
func (b *CheckboxField) Flatten() error
Flatten bakes this single field's appearance (each of its widgets) into the owning page content and removes the field, leaving every other field and the /AcroForm dict intact. Mirrors Aspose.PDF for .NET's Field.Flatten.
After Flatten the field handle is dangling and must not be used.
func (*CheckboxField) IsReadOnly ¶
func (b *CheckboxField) IsReadOnly() bool
func (*CheckboxField) IsRequired ¶
func (b *CheckboxField) IsRequired() bool
func (*CheckboxField) PartialName ¶
func (b *CheckboxField) PartialName() string
func (*CheckboxField) SetChecked ¶
func (f *CheckboxField) SetChecked(v bool)
SetChecked sets the checkbox state. The "checked" /V is the kid widget's /AS export value (typically /Yes); the "unchecked" /V is /Off.
func (*CheckboxField) SetReadOnly ¶
func (f *CheckboxField) SetReadOnly(v bool)
func (*CheckboxField) SetRequired ¶
func (f *CheckboxField) SetRequired(v bool)
func (*CheckboxField) SetStyle ¶ added in v0.3.0
func (b *CheckboxField) SetStyle(s FieldStyle) error
SetStyle applies s to the field, writing /MK, /BS, /DA, and /Q on the field and its widgets and regenerating each widget's /AP appearance so the new look is visible immediately in every viewer. Returns an error only if the field is detached or a styled font cannot be registered.
func (*CheckboxField) SetValue ¶
func (f *CheckboxField) SetValue(s string) error
func (*CheckboxField) Style ¶ added in v0.3.0
func (b *CheckboxField) Style() FieldStyle
Style reads back the field's current styling from /DA, /Q, /MK, and /BS. Properties never set return their zero/default value. The first widget is used for /MK and /BS.
func (*CheckboxField) Value ¶
func (f *CheckboxField) Value() string
type ChoiceOption ¶
type ChoiceOption struct {
Value string // displayed text
Export string // export value when distinct from Value
}
ChoiceOption is one option of a ComboBoxField or ListBoxField.
type CircleAnnotation ¶
type CircleAnnotation struct {
// contains filtered or unexported fields
}
CircleAnnotation draws an elliptical annotation. Mirrors SquareAnnotation API; only the rendered shape and /Subtype differ. Border styles (Solid/Dashed/Beveled/Inset/Underline) and BorderWidth/Color/DashPattern are inherited from drawingAnnotationBase.
func NewCircleAnnotation ¶
func NewCircleAnnotation(page *Page, rect Rectangle) *CircleAnnotation
NewCircleAnnotation builds an unbound circle annotation. Page must be non-nil. The ellipse is inscribed in the given rectangle.
func (*CircleAnnotation) AnnotationType ¶
func (a *CircleAnnotation) AnnotationType() AnnotationType
func (*CircleAnnotation) BorderStyle ¶
func (d *CircleAnnotation) BorderStyle() BorderStyle
BorderStyle returns the /BS/S style. Defaults to BorderSolid if absent.
func (*CircleAnnotation) BorderWidth ¶
func (d *CircleAnnotation) BorderWidth() float64
BorderWidth returns the stroke line width. Reads /BS/W (preferred) or /Border[2] (legacy fallback). Defaults to 1 if neither is present.
func (*CircleAnnotation) DashPattern ¶
func (d *CircleAnnotation) DashPattern() []float64
DashPattern returns a defensive copy of the dash array. Reads /BS/D (preferred) or falls back to the legacy /Border[3] entry per ISO 32000-1 §12.5.4. Returns nil if neither is present.
func (*CircleAnnotation) InteriorColor ¶
func (a *CircleAnnotation) InteriorColor() *Color
InteriorColor returns the /IC fill color, or nil if absent.
func (*CircleAnnotation) RegenerateAppearance ¶
func (a *CircleAnnotation) RegenerateAppearance()
RegenerateAppearance forces /AP/N to be rebuilt from current properties.
func (*CircleAnnotation) SetBorderStyle ¶
func (d *CircleAnnotation) SetBorderStyle(s BorderStyle)
SetBorderStyle writes /BS/S using the PDF spec name codes.
func (*CircleAnnotation) SetBorderWidth ¶
func (d *CircleAnnotation) SetBorderWidth(w float64)
SetBorderWidth writes /BS/W and clears any legacy /Border array.
func (*CircleAnnotation) SetColor ¶
func (d *CircleAnnotation) SetColor(c *Color)
SetColor overrides annotationBase.SetColor to regenerate /AP/N after the stroke color changes.
func (*CircleAnnotation) SetDashPattern ¶
func (d *CircleAnnotation) SetDashPattern(p []float64)
SetDashPattern writes /BS/D. The slice is copied; the caller may safely mutate p after this returns.
func (*CircleAnnotation) SetInteriorColor ¶
func (a *CircleAnnotation) SetInteriorColor(c *Color)
SetInteriorColor writes /IC as an RGB array; nil removes the entry.
type ComboBoxField ¶
type ComboBoxField struct {
// contains filtered or unexported fields
}
ComboBoxField is a single-select dropdown choice field.
func (*ComboBoxField) AddOption ¶
func (f *ComboBoxField) AddOption(o ChoiceOption)
AddOption appends a ChoiceOption to /Opt.
func (*ComboBoxField) Flatten ¶ added in v0.3.0
func (b *ComboBoxField) Flatten() error
Flatten bakes this single field's appearance (each of its widgets) into the owning page content and removes the field, leaving every other field and the /AcroForm dict intact. Mirrors Aspose.PDF for .NET's Field.Flatten.
After Flatten the field handle is dangling and must not be used.
func (*ComboBoxField) IsReadOnly ¶
func (b *ComboBoxField) IsReadOnly() bool
func (*ComboBoxField) IsRequired ¶
func (b *ComboBoxField) IsRequired() bool
func (*ComboBoxField) Options ¶
func (f *ComboBoxField) Options() []ChoiceOption
func (*ComboBoxField) PartialName ¶
func (b *ComboBoxField) PartialName() string
func (*ComboBoxField) RemoveOption ¶
func (f *ComboBoxField) RemoveOption(index int) error
RemoveOption removes the option at index. Errors on out-of-range.
func (*ComboBoxField) Selected ¶
func (f *ComboBoxField) Selected() int
func (*ComboBoxField) SetEditable ¶
func (f *ComboBoxField) SetEditable(v bool)
SetEditable toggles bit 19 (/Ff Edit). When true, the combo accepts arbitrary user-typed text instead of restricting to /Opt entries.
func (*ComboBoxField) SetReadOnly ¶
func (f *ComboBoxField) SetReadOnly(v bool)
SetReadOnly/SetRequired on choice types.
func (*ComboBoxField) SetRequired ¶
func (f *ComboBoxField) SetRequired(v bool)
func (*ComboBoxField) SetSelected ¶
func (f *ComboBoxField) SetSelected(index int) error
func (*ComboBoxField) SetStyle ¶ added in v0.3.0
func (b *ComboBoxField) SetStyle(s FieldStyle) error
SetStyle applies s to the field, writing /MK, /BS, /DA, and /Q on the field and its widgets and regenerating each widget's /AP appearance so the new look is visible immediately in every viewer. Returns an error only if the field is detached or a styled font cannot be registered.
func (*ComboBoxField) SetValue ¶
func (f *ComboBoxField) SetValue(s string) error
func (*ComboBoxField) Style ¶ added in v0.3.0
func (b *ComboBoxField) Style() FieldStyle
Style reads back the field's current styling from /DA, /Q, /MK, and /BS. Properties never set return their zero/default value. The first widget is used for /MK and /BS.
func (*ComboBoxField) Value ¶
func (f *ComboBoxField) Value() string
type Destination ¶
type Destination interface {
DestinationType() DestinationType
Page() *Page
}
Destination is the common interface for all explicit destinations. Per ISO 32000-1 §12.3.2.2.
type DestinationFit ¶
type DestinationFit struct {
// contains filtered or unexported fields
}
DestinationFit — [page /Fit]
func NewDestinationFit ¶
func NewDestinationFit(page *Page) *DestinationFit
func (*DestinationFit) DestinationType ¶
func (d *DestinationFit) DestinationType() DestinationType
func (*DestinationFit) Page ¶
func (d *DestinationFit) Page() *Page
type DestinationFitB ¶
type DestinationFitB struct {
// contains filtered or unexported fields
}
DestinationFitB — [page /FitB]
func NewDestinationFitB ¶
func NewDestinationFitB(page *Page) *DestinationFitB
func (*DestinationFitB) DestinationType ¶
func (d *DestinationFitB) DestinationType() DestinationType
func (*DestinationFitB) Page ¶
func (d *DestinationFitB) Page() *Page
type DestinationFitBH ¶
type DestinationFitBH struct {
// contains filtered or unexported fields
}
DestinationFitBH — [page /FitBH top]
func NewDestinationFitBH ¶
func NewDestinationFitBH(page *Page, top float64) *DestinationFitBH
func NewDestinationFitBHUnchanged ¶
func NewDestinationFitBHUnchanged(page *Page) *DestinationFitBH
func (*DestinationFitBH) DestinationType ¶
func (d *DestinationFitBH) DestinationType() DestinationType
func (*DestinationFitBH) HasTop ¶
func (d *DestinationFitBH) HasTop() bool
func (*DestinationFitBH) Page ¶
func (d *DestinationFitBH) Page() *Page
func (*DestinationFitBH) Top ¶
func (d *DestinationFitBH) Top() float64
type DestinationFitBV ¶
type DestinationFitBV struct {
// contains filtered or unexported fields
}
DestinationFitBV — [page /FitBV left]
func NewDestinationFitBV ¶
func NewDestinationFitBV(page *Page, left float64) *DestinationFitBV
func NewDestinationFitBVUnchanged ¶
func NewDestinationFitBVUnchanged(page *Page) *DestinationFitBV
func (*DestinationFitBV) DestinationType ¶
func (d *DestinationFitBV) DestinationType() DestinationType
func (*DestinationFitBV) HasLeft ¶
func (d *DestinationFitBV) HasLeft() bool
func (*DestinationFitBV) Left ¶
func (d *DestinationFitBV) Left() float64
func (*DestinationFitBV) Page ¶
func (d *DestinationFitBV) Page() *Page
type DestinationFitH ¶
type DestinationFitH struct {
// contains filtered or unexported fields
}
DestinationFitH — [page /FitH top]
func NewDestinationFitH ¶
func NewDestinationFitH(page *Page, top float64) *DestinationFitH
func NewDestinationFitHUnchanged ¶
func NewDestinationFitHUnchanged(page *Page) *DestinationFitH
func (*DestinationFitH) DestinationType ¶
func (d *DestinationFitH) DestinationType() DestinationType
func (*DestinationFitH) HasTop ¶
func (d *DestinationFitH) HasTop() bool
func (*DestinationFitH) Page ¶
func (d *DestinationFitH) Page() *Page
func (*DestinationFitH) Top ¶
func (d *DestinationFitH) Top() float64
type DestinationFitR ¶
type DestinationFitR struct {
// contains filtered or unexported fields
}
DestinationFitR — [page /FitR left bottom right top]
func NewDestinationFitR ¶
func NewDestinationFitR(page *Page, left, bottom, right, top float64) *DestinationFitR
func (*DestinationFitR) Bottom ¶
func (d *DestinationFitR) Bottom() float64
func (*DestinationFitR) DestinationType ¶
func (d *DestinationFitR) DestinationType() DestinationType
func (*DestinationFitR) Left ¶
func (d *DestinationFitR) Left() float64
func (*DestinationFitR) Page ¶
func (d *DestinationFitR) Page() *Page
func (*DestinationFitR) Right ¶
func (d *DestinationFitR) Right() float64
func (*DestinationFitR) Top ¶
func (d *DestinationFitR) Top() float64
type DestinationFitV ¶
type DestinationFitV struct {
// contains filtered or unexported fields
}
DestinationFitV — [page /FitV left]
func NewDestinationFitV ¶
func NewDestinationFitV(page *Page, left float64) *DestinationFitV
func NewDestinationFitVUnchanged ¶
func NewDestinationFitVUnchanged(page *Page) *DestinationFitV
func (*DestinationFitV) DestinationType ¶
func (d *DestinationFitV) DestinationType() DestinationType
func (*DestinationFitV) HasLeft ¶
func (d *DestinationFitV) HasLeft() bool
func (*DestinationFitV) Left ¶
func (d *DestinationFitV) Left() float64
func (*DestinationFitV) Page ¶
func (d *DestinationFitV) Page() *Page
type DestinationType ¶
type DestinationType int
DestinationType identifies the destination flavor.
const ( DestinationTypeXYZ DestinationType = iota DestinationTypeFit DestinationTypeFitH DestinationTypeFitV DestinationTypeFitR DestinationTypeFitB DestinationTypeFitBH DestinationTypeFitBV DestinationTypeNamed // named destination reference via collection lookup )
type DestinationXYZ ¶
type DestinationXYZ struct {
// contains filtered or unexported fields
}
DestinationXYZ — [page /XYZ left top zoom]. Any of left/top/zoom may be left "unchanged" (encoded as /null in PDF) via the Has* flags.
func NewDestinationXYZ ¶
func NewDestinationXYZ(page *Page, left, top, zoom float64) *DestinationXYZ
func (*DestinationXYZ) DestinationType ¶
func (d *DestinationXYZ) DestinationType() DestinationType
func (*DestinationXYZ) HasLeft ¶
func (d *DestinationXYZ) HasLeft() bool
func (*DestinationXYZ) HasTop ¶
func (d *DestinationXYZ) HasTop() bool
func (*DestinationXYZ) HasZoom ¶
func (d *DestinationXYZ) HasZoom() bool
func (*DestinationXYZ) Left ¶
func (d *DestinationXYZ) Left() float64
func (*DestinationXYZ) Page ¶
func (d *DestinationXYZ) Page() *Page
func (*DestinationXYZ) Top ¶
func (d *DestinationXYZ) Top() float64
func (*DestinationXYZ) Zoom ¶
func (d *DestinationXYZ) Zoom() float64
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is a PDF document. Operations directly mutate the receiver.
func ImageToDocument ¶
func ImageToDocument(path string, opts ...ImageToDocumentOptions) (*Document, error)
ImageToDocument creates a new Document with a single page containing the image. Page size is determined by image dimensions and DPI metadata (default 72 DPI).
Example ¶
Convert a standalone image into a single-page PDF.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc, err := pdf.ImageToDocument("testdata/Koala.jpg")
if err != nil {
log.Fatal(err)
}
fmt.Println("pages:", doc.PageCount())
}
Output: pages: 1
func ImageToDocumentFromStream ¶
func ImageToDocumentFromStream(r io.Reader, opts ...ImageToDocumentOptions) (*Document, error)
ImageToDocumentFromStream creates a new Document from an image reader. Format is detected by magic bytes.
func NewDocument ¶
NewDocument creates a single-page blank document with the given dimensions in points.
func NewDocumentFromFormat ¶
func NewDocumentFromFormat(format PageFormat) *Document
NewDocumentFromFormat creates a single-page blank document using a predefined page format.
Example ¶
Create a blank A4 document in memory.
package main
import (
"fmt"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc := pdf.NewDocumentFromFormat(pdf.PageFormatA4)
page, _ := doc.Page(1)
size, _ := page.Size()
fmt.Printf("%.0fx%.0f pt\n", size.Width, size.Height)
}
Output: 595x842 pt
func Open ¶
Open opens a PDF file and returns a Document.
Example:
doc, err := asposepdf.Open("input.pdf")
Example ¶
Open a PDF file and inspect its page count.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc, err := pdf.Open("testdata/4pages.pdf")
if err != nil {
log.Fatal(err)
}
fmt.Println(doc.PageCount(), "pages")
}
Output: 4 pages
func OpenStream ¶
OpenStream reads a PDF from r and returns a Document. Returns ErrEncrypted if the input is password-protected; in that case retry with OpenStreamWithPassword.
Example:
doc, err := asposepdf.OpenStream(file)
func OpenStreamWithPassword ¶
OpenStreamWithPassword reads a password-protected PDF from r. Plain (unencrypted) PDFs are also accepted — the password is silently ignored — so this method is a safe drop-in for code that doesn't know up front whether the input is encrypted.
See OpenWithPassword for the edit-in-place preservation semantics.
func OpenWithPassword ¶
OpenWithPassword opens a password-protected PDF file. Use Open for unencrypted files. The password is tried as both user and owner password; either unlocks the document for editing.
Edit-in-place: the original /O, /U, /P, and /ID bytes from the file are preserved on the returned Document so a subsequent Save reuses them verbatim — BOTH the original user and owner passwords continue to work after re-save, and permissions are preserved bit-for-bit. If you call SetPassword, SetPermissions, SetEncryption, or RemoveEncryption after open, the preserved state is discarded and the document is re-encrypted from the new configuration.
Example:
doc, err := asposepdf.OpenWithPassword("locked.pdf", "secret")
Example ¶
Open an encrypted PDF by trying the password as both user and owner password.
package main
import (
"bytes"
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
// Build an encrypted document in memory so the example is self-contained.
src := pdf.NewDocumentFromFormat(pdf.PageFormatA4)
src.SetEncryption(pdf.EncryptionOptions{UserPassword: "secret"})
var buf bytes.Buffer
if _, err := src.WriteTo(&buf); err != nil {
log.Fatal(err)
}
doc, err := pdf.OpenStreamWithPassword(&buf, "secret")
if err != nil {
log.Fatal(err)
}
fmt.Println("opened:", doc.PageCount(), "pages")
}
Output: opened: 1 pages
func (*Document) AddBlankPage ¶
AddBlankPage appends a blank page to the end of the document.
func (*Document) AddBlankPageFromFormat ¶
func (d *Document) AddBlankPageFromFormat(format PageFormat) error
AddBlankPageFromFormat appends a blank page using a predefined page format.
func (*Document) AddSVGObjectWatermark ¶ added in v0.2.0
AddSVGObjectWatermark uses a pre-parsed *SVG for the watermark content. Renders into each target page's full MediaBox.
func (*Document) AddSVGWatermark ¶ added in v0.2.0
AddSVGWatermark applies an SVG watermark to all pages (when pageNums is empty) or to the specified 1-based page numbers. The SVG is positioned to fill each page's MediaBox honoring its own preserveAspectRatio attribute.
Example ¶
Stamp an SVG logo as a watermark on every page.
package main
import (
"bytes"
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc, err := pdf.Open("testdata/4pages.pdf")
if err != nil {
log.Fatal(err)
}
if err := doc.AddSVGWatermark("testdata/aspose-logo.svg"); err != nil {
log.Fatal(err)
}
var buf bytes.Buffer
if _, err := doc.WriteTo(&buf); err != nil {
log.Fatal(err)
}
fmt.Println("watermarked:", buf.Len() > 0)
}
Output: watermarked: true
func (*Document) AddSVGWatermarkFromStream ¶ added in v0.2.0
AddSVGWatermarkFromStream is the io.Reader variant of AddSVGWatermark.
func (*Document) AddTextWatermark ¶
AddTextWatermark adds a text watermark to selected pages of the document. If no page numbers are given, the watermark is applied to all pages. Page numbers are 1-based. The watermark covers the full page area (MediaBox). The caller controls all styling via TextStyle (rotation, behind, color, etc.).
Example ¶
Apply a diagonal "DRAFT" text watermark behind the content of every page.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc, err := pdf.Open("testdata/4pages.pdf")
if err != nil {
log.Fatal(err)
}
style := pdf.TextStyle{
Font: pdf.FontHelveticaBold,
Size: 72,
Color: &pdf.Color{R: 0.85, G: 0.85, B: 0.85, A: 0.5},
Rotation: 45,
HAlign: pdf.HAlignCenter,
VAlign: pdf.VAlignMiddle,
Behind: true,
}
if err := doc.AddTextWatermark("DRAFT", style); err != nil {
log.Fatal(err)
}
fmt.Println("ok")
}
Output: ok
func (*Document) Append ¶
Append adds all pages from others to this document, merging their objects. Nil arguments are silently skipped.
Example:
doc1, _ := asposepdf.Open("part1.pdf")
doc2, _ := asposepdf.Open("part2.pdf")
doc1.Append(doc2)
doc1.Save("combined.pdf")
Example ¶
Merge two documents by appending all pages of one into another.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
a, err := pdf.Open("testdata/4pages.pdf")
if err != nil {
log.Fatal(err)
}
b, err := pdf.Open("testdata/4pages.pdf")
if err != nil {
log.Fatal(err)
}
a.Append(b)
fmt.Println("merged:", a.PageCount(), "pages")
}
Output: merged: 8 pages
func (*Document) ApplyRedactions ¶
ApplyRedactions destructively removes content (text glyphs, image XObjects, paths) inside every /Redact annotation's /QuadPoints (or /Rect if /QuadPoints is empty). Renders /OverlayText if set, then removes the redact annotations from the page.
Best-effort semantics: partial state on failure. Call ValidateRedactions first to surface parse errors before mutating.
func (*Document) ClearInfo ¶ added in v0.3.0
func (d *Document) ClearInfo()
ClearInfo removes the Info dictionary entirely.
func (*Document) ClearPageLabels ¶ added in v0.3.0
func (d *Document) ClearPageLabels()
ClearPageLabels removes the document's /PageLabels entry. (*Page).Label() then falls back to the decimal page number.
func (*Document) ClearXMP ¶ added in v0.3.0
func (d *Document) ClearXMP()
ClearXMP removes the /Catalog/Metadata entry. The underlying stream object becomes unreferenced; call RemoveUnusedObjects to reclaim it.
func (*Document) DeletePage ¶ added in v0.3.0
DeletePage removes the page at the given 1-based number. Mirrors Aspose.PDF for .NET's Document.Pages.Delete(int).
Example:
err = doc.DeletePage(2) // drop the second page
func (*Document) DeletePages ¶ added in v0.3.0
DeletePages removes the pages at the given 1-based page numbers. Repeated numbers are de-duplicated and argument order does not matter; the surviving pages keep their relative order. Every number is validated before any page is removed, so on error the document is left unchanged. Mirrors Aspose.PDF for .NET's Document.Pages.Delete(int[]).
A document must keep at least one page: a call that would remove every page returns an error and changes nothing. Passing no page numbers is an error (unlike .NET's parameterless Pages.Delete(), which clears all pages — that would leave an unusable zero-page document).
Removed pages no longer appear in the document or in saved output. The underlying objects are not eagerly reclaimed (matching Reorder); they fall out of the written page tree and can be garbage-collected by the writer's reachability pass.
Example:
err = doc.DeletePages(1, 3) // drop the first and third pages
func (*Document) Extract ¶
Extract returns a new Document containing only the pages in the specified ranges. Ranges are 1-based and inclusive. Pages appear in the order the ranges are listed.
Example:
extracted, err := doc.Extract(asposepdf.PageRange{1, 3}, asposepdf.PageRange{5, 5})
extracted.Save("output.pdf")
Example ¶
Extract selected page ranges into a new document.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc, err := pdf.Open("testdata/4pages.pdf")
if err != nil {
log.Fatal(err)
}
out, err := doc.Extract(
pdf.PageRange{From: 1, To: 2},
pdf.PageRange{From: 4, To: 4},
)
if err != nil {
log.Fatal(err)
}
fmt.Println("extracted:", out.PageCount(), "pages")
}
Output: extracted: 3 pages
func (*Document) ExtractImages ¶
ExtractImages returns images from all pages (one slice per page).
func (*Document) ExtractText ¶
ExtractText returns the text content of each page. The returned slice has one entry per page (0-indexed).
Example ¶
Extract text from every page in visual reading order.
package main
import (
"fmt"
"log"
"strings"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc, err := pdf.Open("testdata/Hello world.pdf")
if err != nil {
log.Fatal(err)
}
pages, err := doc.ExtractText()
if err != nil {
log.Fatal(err)
}
fmt.Println(strings.TrimSpace(pages[0]))
}
Output: Hello, world!
func (*Document) ExtractTextWithLayout ¶
ExtractTextWithLayout returns structured text lines for each page. The returned slice has one entry per page (0-indexed).
func (*Document) Flatten ¶ added in v0.3.0
Flatten bakes the document's interactive form fields into static page content and removes the AcroForm, so the result renders identically but is no longer fillable. Equivalent to (*Document).Form().Flatten().
Mirrors Aspose.PDF for .NET's Document.Flatten (which flattens form fields). Annotations are not affected here — flatten those via a page's AnnotationCollection.Flatten or an individual Annotation.Flatten.
func (*Document) Form ¶
Form returns the document's AcroForm. Always non-nil; for a document without /AcroForm, an empty Form is returned (Fields() is empty, Field(name) returns nil, HasField returns false).
func (*Document) ImageInfos ¶
ImageInfos returns image metadata for all pages (one slice per page) without decoding pixel data.
func (*Document) Info ¶ added in v0.3.0
func (d *Document) Info() (DocumentInfo, error)
Info returns the Info-dictionary metadata from this document. Mirrors Aspose.PDF for .NET's Document.Info; the XMP store is XMP().
func (*Document) InsertBlankPage ¶
InsertBlankPage inserts a blank page at the given 1-based position. Existing pages at and after that position shift by one.
func (*Document) InsertBlankPageFromFormat ¶
func (d *Document) InsertBlankPageFromFormat(position int, format PageFormat) error
InsertBlankPageFromFormat inserts a blank page at the given position using a predefined page format.
func (*Document) LoadFont ¶
LoadFont reads a TTF file, parses it, embeds it into the document, and returns a Font that can be used in TextStyle.Font. The full TTF is embedded without subsetting, so large fonts increase output size. The returned Font is bound to this document and must not be used with pages from other documents.
func (*Document) LoadFontFromStream ¶
LoadFontFromStream is like LoadFont but reads from an io.Reader.
func (*Document) LoadSVG ¶ added in v0.2.0
LoadSVG reads and parses an SVG file once, returning a *SVG that can be passed to Page.AddSVGObject or Document.AddSVGObjectWatermark multiple times without re-parsing.
func (*Document) LoadSVGFromStream ¶ added in v0.2.0
LoadSVGFromStream is the io.Reader variant of LoadSVG.
func (*Document) NamedDestinations ¶
func (d *Document) NamedDestinations() *NamedDestinations
NamedDestinations returns the document's named-destination collection. Always non-nil. Lazy-initialized on first call from /Catalog/Names/Dests (modern PDF 1.2+ name tree) merged with legacy /Catalog/Dests; on collision the /Names/Dests entry wins.
Mirrors Aspose.PDF for .NET's Document.NamedDestinations property.
func (*Document) OptimizeImages ¶
func (d *Document) OptimizeImages(opts OptimizeImageOptions) (int, error)
OptimizeImages optimizes all images in the document to reduce file size. Returns the number of images optimized.
func (*Document) Outlines ¶
func (d *Document) Outlines() *OutlineItemCollection
Outlines returns the document's root outline collection. Always non-nil — an empty collection is returned for documents without outline content. Mirrors Aspose.PDF for .NET's Document.Outlines.
func (*Document) Permissions ¶
func (d *Document) Permissions() (Permissions, bool)
Permissions returns the viewer-permission settings currently configured on this document, plus a boolean indicating whether the document is configured for encryption at all. For a document opened via OpenWithPassword, the permissions reflect the /P value read from the original file. Returns the zero Permissions and false for unencrypted documents.
func (*Document) RemoveEncryption ¶
func (d *Document) RemoveEncryption()
RemoveEncryption clears any previously configured encryption (passwords and permissions) so the next Save produces a plaintext PDF. This is the way to "decrypt" an encrypted file via the public API: open with a password, call RemoveEncryption, save.
Example:
doc, _ := asposepdf.OpenWithPassword("locked.pdf", "secret")
doc.RemoveEncryption()
doc.Save("plain.pdf")
func (*Document) RemoveUnusedObjects ¶
RemoveUnusedObjects removes objects from the document that are not reachable from any page. Returns the number of objects removed.
func (*Document) RenderImage ¶ added in v0.3.0
RenderImage renders the 1-based page number to an image.
func (*Document) RenderTIFF ¶ added in v0.3.0
RenderTIFF renders the document to a single multi-page TIFF written to w. With no pageNums every page is rendered in order; otherwise just the listed 1-based pages, in the given order. Pages are rendered one at a time, so peak memory is a single page image. Mirrors Aspose.PDF for .NET's TiffDevice whole-document output.
func (*Document) Reorder ¶
Reorder rearranges pages according to order, a slice of 1-based page numbers. Pages may be repeated or omitted.
Example — reverse a 4-page document:
err = doc.Reorder([]int{4, 3, 2, 1})
func (*Document) Rotate ¶
func (d *Document) Rotate(angle RotationAngle, pageNums ...int) error
Rotate rotates selected pages clockwise by angle (Rotate90, Rotate180, or Rotate270). The rotation is added to any existing rotation. If no page numbers are given, all pages are rotated. Page numbers are 1-based.
Example:
err = doc.Rotate(asposepdf.Rotate90) // rotate all pages err = doc.Rotate(asposepdf.Rotate180, 1, 3) // rotate pages 1 and 3
Example ¶
Rotate selected pages by 90 degrees clockwise. Subsequent calls accumulate.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc, err := pdf.Open("testdata/4pages.pdf")
if err != nil {
log.Fatal(err)
}
if err := doc.Rotate(pdf.Rotate90, 1, 3); err != nil {
log.Fatal(err)
}
p1, _ := doc.Page(1)
p2, _ := doc.Page(2)
fmt.Println("page1:", p1.Rotation(), "page2:", p2.Rotation())
}
Output: page1: 90 page2: 0
func (*Document) SearchText ¶ added in v0.3.0
func (d *Document) SearchText(query string, opts ...SearchOptions) ([]TextMatch, error)
SearchText finds every occurrence of query across all pages of the document, returning matches page by page in reading order. Each TextMatch carries the page it was found on. See (*Page).SearchText for matching semantics.
func (*Document) SetEncryption ¶
func (d *Document) SetEncryption(opts EncryptionOptions)
SetEncryption configures every encryption-related setting at once from an EncryptionOptions struct. It replaces any prior configuration set by SetPassword or SetPermissions. See EncryptionOptions for field-level semantics; nil Permissions means "grant all".
SetPassword and SetPermissions remain convenient for one-liner updates and compose cleanly either before or after SetEncryption.
Example:
doc.SetEncryption(asposepdf.EncryptionOptions{
UserPassword: "user",
OwnerPassword: "owner",
Permissions: &asposepdf.Permissions{AllowPrint: true, AllowCopy: true},
})
doc.Save("restricted.pdf")
Example ¶
Encrypt a document with AES-128 and a user password.
package main
import (
"bytes"
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc := pdf.NewDocumentFromFormat(pdf.PageFormatA4)
doc.SetEncryption(pdf.EncryptionOptions{
UserPassword: "secret",
OwnerPassword: "owner-secret",
Permissions: &pdf.Permissions{AllowPrint: true, AllowCopy: true},
Algorithm: pdf.EncryptionAlgAES128,
})
var buf bytes.Buffer
if _, err := doc.WriteTo(&buf); err != nil {
log.Fatal(err)
}
// The file is now encrypted; Open returns ErrEncrypted.
if _, err := pdf.OpenStream(&buf); err != nil {
fmt.Println("encrypted")
}
}
Output: encrypted
func (*Document) SetInfo ¶ added in v0.3.0
func (d *Document) SetInfo(info DocumentInfo)
SetInfo replaces the document's Info dictionary with the given metadata. Empty string fields are omitted. This is a full replacement. Mirrors assigning Aspose.PDF for .NET's Document.Info.
func (*Document) SetPageLabels ¶ added in v0.3.0
func (d *Document) SetPageLabels(ranges []PageLabelRange) error
SetPageLabels installs the document's /PageLabels number tree so PDF viewers display labels like "i, ii, 1, 2, …" in the navigation pane and page indicators. (*Page).Label() also reads from this tree.
Ranges must be sorted by StartPage in strictly ascending order and the first range must begin at page 1; otherwise an error is returned. Passing a nil/empty slice clears any existing labels.
Per PDF spec §12.4.2, /PageLabels is a number tree keyed by 0-based page index. This implementation emits a single-leaf number tree with one /Nums array, which is valid for any number of ranges.
func (*Document) SetPassword ¶
SetPassword configures the document to be encrypted when saved. userPassword is required to open; ownerPassword controls permissions. If ownerPassword is empty, it defaults to userPassword.
Password encoding: The password bytes are passed unchanged to the PDF Standard Security Handler (RC4-128, V=2 R=3). For ASCII passwords this matches both the PDF specification and every major PDF viewer. For non-ASCII passwords the raw UTF-8 bytes are used, which is compatible with pypdf 6.x and Adobe Acrobat DC but may not be accepted by strictly legacy PDFDocEncoding-only viewers (e.g. Adobe Reader 9 and older). For international passwords with guaranteed interop, AES-256 (R=6) is the only complete solution — not yet supported by this library.
Example:
doc.SetPassword("secret", "")
doc.Save("encrypted.pdf")
func (*Document) SetPermissions ¶
func (d *Document) SetPermissions(p Permissions)
SetPermissions configures what operations a viewer allows on the encrypted document (printing, copying, modifying, etc.). Permissions only take effect if the document is also encrypted — call SetPassword to set the user and owner passwords. If SetPermissions is never called, all operations are allowed by default, matching the historical behavior.
Example:
doc.SetPassword("secret", "owner-secret")
doc.SetPermissions(asposepdf.Permissions{AllowPrint: true, AllowCopy: true})
doc.Save("restricted.pdf")
func (*Document) SetRotation ¶
func (d *Document) SetRotation(angle RotationAngle, pageNums ...int) error
SetRotation sets selected pages to exactly angle (Rotate0, Rotate90, Rotate180, or Rotate270), replacing any existing rotation. If no page numbers are given, all pages are affected. Page numbers are 1-based.
Example:
err = doc.SetRotation(asposepdf.Rotate90) // set all pages to 90° err = doc.SetRotation(asposepdf.Rotate0, 1, 3) // reset pages 1 and 3 to 0°
func (*Document) SetSVGFontResolver ¶ added in v0.2.0
func (d *Document) SetSVGFontResolver(fn SVGFontResolver)
SetSVGFontResolver installs a custom resolver. The renderer queries it first for each SVG font-family encountered; on nil return, falls back to the heuristic. Use this to plug in embedded TTF fonts (Cyrillic, etc.) loaded via Document.LoadFont.
Pass nil to clear a previously-set resolver (revert to heuristic-only).
func (*Document) SetXMP ¶ added in v0.3.0
func (d *Document) SetXMP(meta XMPMetadata) error
SetXMP serialises meta into a standard XMP packet and stores it as the /Catalog/Metadata stream (uncompressed, /Type /Metadata /Subtype /XML per ISO 32000-1 §14.3.2). Replaces any existing packet. Passing an empty XMPMetadata writes an empty (but valid) packet; use ClearXMP to remove metadata entirely.
func (*Document) SetXMPRaw ¶ added in v0.3.0
SetXMPRaw stores data verbatim as the /Catalog/Metadata stream — an escape hatch for callers that produce their own XMP packet. The bytes are written uncompressed so external tools can locate the xpacket markers. Reuses the existing Metadata object if present.
func (*Document) Split ¶
Split returns each page of the document as a separate *Document.
Example:
parts, err := doc.Split()
for i, p := range parts {
p.Save(fmt.Sprintf("page%03d.pdf", i+1))
}
Example ¶
Split a multi-page document into single-page documents.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc, err := pdf.Open("testdata/4pages.pdf")
if err != nil {
log.Fatal(err)
}
parts, err := doc.Split()
if err != nil {
log.Fatal(err)
}
fmt.Println("parts:", len(parts))
}
Output: parts: 4
func (*Document) SubsetFonts ¶ added in v0.3.0
SubsetFonts shrinks every embedded TTF (loaded via LoadFont) to only the glyphs actually drawn, replacing each /FontFile2 with a rebuilt subset program and switching the CIDFont's /CIDToGIDMap from /Identity to a stream that maps the original glyph IDs (still used verbatim as CIDs in content streams) to the compact subset glyph IDs. /W and /ToUnicode are also trimmed to the used glyphs.
Call this once, AFTER all text has been added and just before Save / WriteTo: adding more text that introduces new glyphs after subsetting would reference glyphs the subset no longer contains. Fonts with no drawn glyphs are skipped. Returns the number of fonts subsetted.
Typical reduction is from ~300-700 KB per embedded font down to a few KB, since only the used outlines survive. Mirrors the post-processing shape of (*Document).OptimizeImages.
func (*Document) SyncInfoToXMP ¶ added in v0.3.0
SyncInfoToXMP builds an XMP packet from the document's current /Info dictionary and installs it, so the two metadata stores agree (ISO 32000-1 §14.3.2 recommends consistency when both are present). Info Title/Author/Subject/Keywords/Creator/Producer/dates map to the corresponding XMP properties. No-op-safe when /Info is absent.
func (*Document) ValidateRedactions ¶
ValidateRedactions performs a pre-flight dry-run parseability check on every page that has at least one RedactAnnotation. Returns the first content-stream parse error encountered, or nil if every redact-bearing page's content stream parses cleanly. Pages without redact annotations are not inspected.
Callers should invoke this before ApplyRedactions to surface malformed content streams up-front; ApplyRedactions has best-effort semantics and may leave partial state on failure.
func (*Document) XMP ¶ added in v0.3.0
func (d *Document) XMP() (XMPMetadata, error)
XMP returns the document's XMP metadata parsed from the /Catalog/Metadata stream. Returns a zero XMPMetadata (IsEmpty) when the document has no XMP packet. Parse errors in a malformed packet are returned; recognised properties parsed before the error are discarded.
type DocumentInfo ¶ added in v0.3.0
type DocumentInfo struct {
Title string
Author string
Subject string
Keywords string
Creator string
Producer string
CreationDate string
ModDate string
Custom map[string]string // arbitrary Info dict entries
}
DocumentInfo contains document information from the PDF Info dictionary. Fields not present in the source PDF are empty strings.
Mirrors Aspose.PDF for .NET's DocumentInfo (Document.Info). Note the cross-API naming: in Aspose.PDF for .NET, Document.Info is this Info dictionary while Document.Metadata is the XMP store — which here is (*Document).XMP, not this type.
type EncryptionAlgorithm ¶
type EncryptionAlgorithm int
EncryptionAlgorithm selects the cipher and security-handler revision used by (*Document).SetEncryption. The zero value is AES-128.
const ( // EncryptionAlgAES128 — AES-128, Standard Security Handler V=4 R=4, // /CFM /AESV2. ISO 32000-1 §7.6.3.2. The default (zero value). EncryptionAlgAES128 EncryptionAlgorithm = iota // EncryptionAlgRC4_128 — RC4-128, Standard Security Handler V=2 R=3. // Legacy compatibility only — AES-128 is preferred for new documents. EncryptionAlgRC4_128 // EncryptionAlgAES256 — AES-256, Standard Security Handler V=5 R=6, // /CFM /AESV3. ISO 32000-2 §7.6.4. Output PDF header is bumped to // %PDF-2.0; viewers older than Adobe Acrobat DC (~2015) may not // support PDF 2.0 documents. EncryptionAlgAES256 )
type EncryptionOptions ¶
type EncryptionOptions struct {
UserPassword string
OwnerPassword string
Permissions *Permissions
Algorithm EncryptionAlgorithm
}
EncryptionOptions bundles every knob that controls how a document is encrypted when saved. It is the unified structured input for (*Document).SetEncryption; the shorter SetPassword / SetPermissions methods remain available for the common case of one-line updates.
Zero values:
UserPassword — no password (empty string is a valid "open without
password" user-password under R<=4; the PDF still
carries permissions).
OwnerPassword — defaults to UserPassword, matching Adobe behavior.
Permissions — nil means "grant all" (the historical default);
pass a non-nil pointer to restrict. Permissions{}
(value, not pointer) deliberately denies everything,
so the pointer distinguishes "omitted" from "deny".
Algorithm — EncryptionAlgAES128 (zero value).
Example:
doc.SetEncryption(asposepdf.EncryptionOptions{
UserPassword: "user",
OwnerPassword: "owner",
Permissions: &asposepdf.Permissions{AllowPrint: true, AllowCopy: true},
})
doc.Save("restricted.pdf")
type Field ¶
type Field interface {
PartialName() string
FullName() string
Value() string
SetValue(s string) error
IsReadOnly() bool
IsRequired() bool
PageIndex() int
Rect() Rectangle
// SetStyle applies visual styling (colours, border, font, alignment)
// and regenerates the widget appearance. Style reads it back.
SetStyle(s FieldStyle) error
Style() FieldStyle
// Flatten bakes this single field's appearance into its page content
// and removes the field, leaving other fields and the /AcroForm intact.
// See (*fieldBase).Flatten in flatten.go.
Flatten() error
}
Field is the common interface implemented by every concrete form field type (TextBoxField, CheckboxField, RadioButtonField, etc.).
type FieldStyle ¶ added in v0.3.0
type FieldStyle struct {
BorderColor *Color // /MK /BC — nil = no border colour set
BackgroundColor *Color // /MK /BG — nil = transparent/white default
TextColor *Color // /DA fill colour — nil = black
BorderWidth float64 // /BS /W in points — 0 = hairline default
BorderStyle BorderStyle // /BS /S — BorderSolid (default), Dashed, Beveled, Inset, Underline
DashPattern []float64 // /BS /D — used only when BorderStyle == BorderDashed
TextFont Font // /DA font — nil = Helvetica
TextSize float64 // /DA size in points — 0 = 12pt
TextAlign HAlign // /Q — HAlignLeft (default), HAlignCenter, HAlignRight
}
FieldStyle is the visual styling applied to a form field's widget(s). A zero value means "leave at the library default" for every property: nil colour pointers, zero BorderWidth, BorderSolid, nil DashPattern, nil TextFont (→ Helvetica), zero TextSize (→ 12pt), HAlignLeft.
Styling is persisted into the PDF the way ISO 32000-1 specifies, so it round-trips and is also honoured by viewers that regenerate appearances:
- BorderColor / BackgroundColor → /MK /BC, /MK /BG (§12.5.6.19)
- BorderWidth / BorderStyle / DashPattern → /BS /W, /S, /D (§12.5.4)
- TextFont / TextSize / TextColor → /DA default-appearance string (§12.7.3.3)
- TextAlign → /Q quadding (0 left, 1 centre, 2 right)
Because the library also pre-generates the widget /AP appearance stream from these same values, a styled field renders identically across Acrobat, Foxit, browser PDF viewers, MuPDF, and Poppler.
type FileAttachmentAnnotation ¶
type FileAttachmentAnnotation struct {
// contains filtered or unexported fields
}
FileAttachmentAnnotation embeds a file in the document and shows an icon at the annotation's /Rect. Per ISO 32000-1 §12.5.6.15. No /AP is generated — viewers render the icon themselves based on /Name.
func NewFileAttachmentAnnotation ¶
func NewFileAttachmentAnnotation(page *Page, position Point) *FileAttachmentAnnotation
NewFileAttachmentAnnotation builds an unbound file-attachment annotation. Page must be non-nil. The /Rect is auto-computed as a 24×24 pt square anchored at position (Acrobat icon convention).
Call SetFile or SetFileFromStream to embed file data; without that, the annotation has no /FS entry and viewers render an empty icon.
func (*FileAttachmentAnnotation) AnnotationType ¶
func (a *FileAttachmentAnnotation) AnnotationType() AnnotationType
func (*FileAttachmentAnnotation) Color ¶
func (b *FileAttachmentAnnotation) Color() *Color
Color returns the /C array as an RGB Color. Returns nil if /C is absent.
func (*FileAttachmentAnnotation) Contents ¶
func (b *FileAttachmentAnnotation) Contents() string
Contents returns /Contents (the annotation body text).
func (*FileAttachmentAnnotation) FileBytes ¶
func (a *FileAttachmentAnnotation) FileBytes() []byte
FileBytes returns a defensive copy of the embedded file's raw bytes. Nil if no file.
func (*FileAttachmentAnnotation) FileDescription ¶
func (a *FileAttachmentAnnotation) FileDescription() string
FileDescription returns /Filespec/Desc. Empty if no description set.
func (*FileAttachmentAnnotation) FileMIMEType ¶
func (a *FileAttachmentAnnotation) FileMIMEType() string
FileMIMEType returns the /Subtype on /EmbeddedFile (e.g. "application/pdf"). Empty if no file or /Subtype missing.
func (*FileAttachmentAnnotation) FileName ¶
func (a *FileAttachmentAnnotation) FileName() string
FileName returns the displayed filename from /Filespec/F. Empty if no file.
func (*FileAttachmentAnnotation) FileSize ¶
func (a *FileAttachmentAnnotation) FileSize() int
FileSize returns the size of the embedded file in bytes. Zero if no file.
func (*FileAttachmentAnnotation) Flatten ¶ added in v0.3.0
func (b *FileAttachmentAnnotation) Flatten() error
Flatten bakes this annotation's normal appearance (/AP/N, honoring the /AS state) into its page's content stream at the annotation's /Rect, then removes the annotation. The annotation handle is dangling afterwards.
An annotation with no normal appearance (e.g. a sticky-note Text annotation, which viewers render as an icon) is simply removed — nothing is drawn.
Mirrors Aspose.PDF for .NET's Annotation.Flatten. For form-field widgets prefer (*Form).Flatten, which also clears the /AcroForm entry.
func (*FileAttachmentAnnotation) HasFile ¶
func (a *FileAttachmentAnnotation) HasFile() bool
HasFile returns true if SetFile or SetFileFromStream has been called successfully and not subsequently cleared. Stub for now — full implementation in Task 3.
func (*FileAttachmentAnnotation) Icon ¶
func (a *FileAttachmentAnnotation) Icon() FileAttachmentIcon
Icon returns the /Name entry mapped to a FileAttachmentIcon. Returns FileAttachmentIconPaperclip (the spec default) if absent.
func (*FileAttachmentAnnotation) PageIndex ¶
func (b *FileAttachmentAnnotation) PageIndex() int
PageIndex returns the 1-based index of the page this annotation lives on. 0 if the annotation is not yet attached or its /P doesn't resolve.
func (*FileAttachmentAnnotation) Rect ¶
func (b *FileAttachmentAnnotation) Rect() Rectangle
Rect returns the annotation rectangle. Empty Rectangle if /Rect is missing or malformed.
func (*FileAttachmentAnnotation) RegenerateAppearance ¶
func (a *FileAttachmentAnnotation) RegenerateAppearance()
RegenerateAppearance is a no-op for FileAttachmentAnnotation (no /AP — viewers render the icon themselves).
func (*FileAttachmentAnnotation) SetColor ¶
func (b *FileAttachmentAnnotation) SetColor(c *Color)
SetColor writes /C as an RGB array; nil removes the entry.
func (*FileAttachmentAnnotation) SetContents ¶
func (b *FileAttachmentAnnotation) SetContents(s string)
SetContents writes /Contents (the annotation body text); empty string removes the entry.
func (*FileAttachmentAnnotation) SetFile ¶
func (a *FileAttachmentAnnotation) SetFile(path string) error
SetFile embeds the file at path as the annotation's attachment. The file's MIME type is auto-detected from the extension via mime.TypeByExtension; falls back to "application/octet-stream" for unknown extensions. Returns error on file-open or read failures.
func (*FileAttachmentAnnotation) SetFileDescription ¶
func (a *FileAttachmentAnnotation) SetFileDescription(s string)
SetFileDescription writes /Filespec/Desc.
func (*FileAttachmentAnnotation) SetFileFromStream ¶
func (a *FileAttachmentAnnotation) SetFileFromStream(r io.Reader, name string) error
SetFileFromStream is the io.Reader variant of SetFile. The caller supplies the displayed filename (used for /F entry and for MIME detection from extension).
func (*FileAttachmentAnnotation) SetIcon ¶
func (a *FileAttachmentAnnotation) SetIcon(i FileAttachmentIcon)
SetIcon writes the /Name entry. Unknown is encoded as /Paperclip.
func (*FileAttachmentAnnotation) SetRect ¶
func (b *FileAttachmentAnnotation) SetRect(r Rectangle)
SetRect writes the annotation rectangle.
type FileAttachmentIcon ¶
type FileAttachmentIcon int
FileAttachmentIcon names per ISO 32000-1 §12.5.6.15 Table 178.
const ( FileAttachmentIconUnknown FileAttachmentIcon = iota FileAttachmentIconGraph FileAttachmentIconPaperclip // PDF default FileAttachmentIconPushPin FileAttachmentIconTag )
type Font ¶
type Font interface {
// BaseFont returns the PostScript name, e.g. "Helvetica" or "ArialMT".
BaseFont() string
// IsEmbedded reports whether font data is embedded in the PDF (true for TTF, false for standard 14).
IsEmbedded() bool
}
Font is implemented by standard 14 fonts and embedded TTF fonts. Use the package-level vars (FontHelvetica, ...) or LoadFont to obtain a Font.
var ( FontHelvetica Font = standardFont{/* contains filtered or unexported fields */} FontHelveticaBold Font = standardFont{/* contains filtered or unexported fields */} FontHelveticaOblique Font = standardFont{/* contains filtered or unexported fields */} FontHelveticaBoldOblique Font = standardFont{/* contains filtered or unexported fields */} FontTimesRoman Font = standardFont{/* contains filtered or unexported fields */} FontTimesBold Font = standardFont{/* contains filtered or unexported fields */} FontTimesItalic Font = standardFont{/* contains filtered or unexported fields */} FontTimesBoldItalic Font = standardFont{/* contains filtered or unexported fields */} FontCourier Font = standardFont{/* contains filtered or unexported fields */} FontCourierBold Font = standardFont{/* contains filtered or unexported fields */} FontCourierOblique Font = standardFont{/* contains filtered or unexported fields */} FontCourierBoldOblique Font = standardFont{/* contains filtered or unexported fields */} FontSymbol Font = standardFont{/* contains filtered or unexported fields */} FontZapfDingbats Font = standardFont{/* contains filtered or unexported fields */} )
Standard 14 PDF fonts. These Fonts need not be embedded — every PDF viewer is required to render them.
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
Form is the document's AcroForm view. Always non-nil — for documents without an /AcroForm dict, Form is empty (no fields, no flags). Field instances returned from Form are live handles over the underlying pdfDict; SetValue mutates in place and the next Save writes the new state.
func (*Form) AddCheckbox ¶
AddCheckbox creates a checkbox widget on pageNum with the given rectangle and field name. Default state is unchecked (/V = /Off). The widget's /AP/N has two appearance states: "/Yes" (export name for checked) and "/Off". Callers can call SetChecked(true) on the returned handle to flip state and ensure /V and /AS are in sync.
Errors on duplicate name, invalid pageNum, or empty name.
func (*Form) AddComboBox ¶
func (f *Form) AddComboBox(pageNum int, rect Rectangle, name string, options []ChoiceOption) (*ComboBoxField, error)
AddComboBox creates a single-select dropdown choice field. The caller can pre-populate options or pass an empty slice and call AddOption later. Field is non-editable by default; SetEditable(true) flips bit 19.
func (*Form) AddListBox ¶
func (f *Form) AddListBox(pageNum int, rect Rectangle, name string, options []ChoiceOption) (*ListBoxField, error)
AddListBox creates a single-select list field. SetMultiSelect(true) on the returned handle enables multi-selection (bit 22).
func (*Form) AddPushButton ¶
func (f *Form) AddPushButton(pageNum int, rect Rectangle, name string, caption string) (*ButtonField, error)
AddPushButton creates a non-toggling button. The caption is stored in /MK/CA and rendered by viewers as the button label. Push buttons have no value semantics — Value() returns "", SetValue returns an error.
func (*Form) AddRadioGroup ¶
func (f *Form) AddRadioGroup(name string, items []RadioItem) (*RadioButtonField, error)
AddRadioGroup creates a radio-button parent field plus one widget per item. Items may live on different pages. Export values must be unique within the group.
func (*Form) AddTextField ¶
AddTextField creates a single-line text input on pageNum with the given rectangle and field name, auto-creating /AcroForm and the default Helvetica font resource if needed. Returns the live *TextBoxField handle. Errors on duplicate name, invalid pageNum, or empty name.
func (*Form) Field ¶
Field returns the leaf field by FullName, or nil if no such field exists. Mirrors the C# `doc.Form["name"]` indexer pattern.
func (*Form) Fields ¶
Fields returns all leaf form fields as a flat slice. Field tree hierarchy is resolved internally; callers see only the leaves whose FullName carries the dotted path.
func (*Form) Flatten ¶ added in v0.3.0
Flatten bakes every form field's current appearance into its page's content stream and then removes all fields, their widgets, and the /AcroForm dict, producing a non-interactive document that renders the same. A field whose widget has no normal appearance is removed without drawing.
Mirrors Aspose.PDF for .NET's Form.Flatten. After Flatten the Form is empty; previously returned Field handles are dangling and must not be used.
func (*Form) NeedAppearances ¶
NeedAppearances reports whether /AcroForm/NeedAppearances is true, which tells viewers to regenerate cached /AP appearance streams when displaying form fields.
func (*Form) RemoveField ¶
RemoveField removes the named field (and all its widget annotations) from /AcroForm/Fields and from each affected page's /Annots. The underlying pdfObjects are deleted from the document's object map. Returns true if the field was found and removed; false otherwise.
For combined-pattern fields (TextField, Checkbox, ComboBox, ListBox, PushButton), the single dict is both the field and its widget: it is removed from /Fields and from the owning page's /Annots.
For radio groups, the parent dict is removed from /Fields, and each widget kid is removed from its respective page's /Annots.
After removal, any *Field handles previously returned for this field are dangling and must not be used.
func (*Form) SetNeedAppearances ¶
SetNeedAppearances toggles /AcroForm/NeedAppearances. When set, viewers regenerate the /AP appearance stream on display instead of trusting the pre-generated one (which Acrobat treats as a document modification). The library auto-builds /AP for every field on creation and on every value mutation, so the default (false) is correct for nearly all cases; callers only need this for niche workflows where viewer-side regeneration is required.
On a Document with no /AcroForm dict, calling this with true creates a new /AcroForm dict in the catalog so the flag is preserved on Save.
type FormFieldType ¶
type FormFieldType int
FormFieldType identifies the kind of form field. Returned by FieldType().
const ( FormFieldTypeUnknown FormFieldType = iota FormFieldTypeText FormFieldTypeCheckbox FormFieldTypeRadioButton FormFieldTypePushButton FormFieldTypeComboBox FormFieldTypeListBox )
func FieldType ¶
func FieldType(f Field) FormFieldType
FieldType returns the concrete kind of f. Convenience helper for callers who want a switch on type without the type-assertion form.
type FreeTextAnnotation ¶
type FreeTextAnnotation struct {
// contains filtered or unexported fields
}
FreeTextAnnotation displays text directly on the page, rendered into /AP/N using an embedded font. Per ISO 32000-1 §12.5.6.6.
Supports /BS border, /BG background, /Q alignment via TextStyle, plus /IT intent (FreeText / FreeTextCallout / FreeTextTypewriter), /CL callout points, /BE border effect (cloudy), and /RD inner rect for callouts. Full feature set added incrementally across Tasks 9-17.
func NewFreeTextAnnotation ¶
func NewFreeTextAnnotation(page *Page, rect Rectangle, contents string, style TextStyle) *FreeTextAnnotation
NewFreeTextAnnotation builds an unbound FreeText annotation. Page must be non-nil. Contents is the text body. style configures font, size, color, alignment, and background — serialized to /DA, /Q, /BG.
func (*FreeTextAnnotation) AnnotationType ¶
func (a *FreeTextAnnotation) AnnotationType() AnnotationType
func (*FreeTextAnnotation) BorderEffect ¶
func (a *FreeTextAnnotation) BorderEffect() BorderEffect
BorderEffect returns the /BE/S entry as a BorderEffect. Returns BorderEffectNone if /BE is absent or unrecognized.
func (*FreeTextAnnotation) BorderEffectIntensity ¶
func (a *FreeTextAnnotation) BorderEffectIntensity() float64
BorderEffectIntensity returns the /BE/I entry. Returns 0 if absent. Default visual intensity for cloudy border is 1.0 — caller of SetBorderEffect typically also sets intensity via SetBorderEffectIntensity.
func (*FreeTextAnnotation) BorderStyle ¶
func (d *FreeTextAnnotation) BorderStyle() BorderStyle
BorderStyle returns the /BS/S style. Defaults to BorderSolid if absent.
func (*FreeTextAnnotation) BorderWidth ¶
func (d *FreeTextAnnotation) BorderWidth() float64
BorderWidth returns the stroke line width. Reads /BS/W (preferred) or /Border[2] (legacy fallback). Defaults to 1 if neither is present.
func (*FreeTextAnnotation) CalloutPoints ¶
func (a *FreeTextAnnotation) CalloutPoints() []Point
CalloutPoints returns the /CL knee + endpoint points (page space). Returns nil if /CL is absent or malformed. Format: 2-element slice (knee, endpoint) for /CL = [x1 y1 x2 y2]; 3-element slice (knee1, knee2, endpoint) for /CL = [x1 y1 x2 y2 x3 y3].
func (*FreeTextAnnotation) Contents ¶
func (a *FreeTextAnnotation) Contents() string
Contents returns the /Contents text body. Overrides annotationBase to ensure the value is always read from the dict.
func (*FreeTextAnnotation) DashPattern ¶
func (d *FreeTextAnnotation) DashPattern() []float64
DashPattern returns a defensive copy of the dash array. Reads /BS/D (preferred) or falls back to the legacy /Border[3] entry per ISO 32000-1 §12.5.4. Returns nil if neither is present.
func (*FreeTextAnnotation) EndLineEnding ¶
func (a *FreeTextAnnotation) EndLineEnding() LineEndingStyle
EndLineEnding returns the /LE entry as a LineEndingStyle. Returns LineEndingNone if absent or unrecognized.
func (*FreeTextAnnotation) InnerRect ¶
func (a *FreeTextAnnotation) InnerRect() Rectangle
InnerRect returns the inner text rectangle derived from /RD entry. If /RD is absent, returns the full annotation /Rect.
func (*FreeTextAnnotation) Intent ¶
func (a *FreeTextAnnotation) Intent() FreeTextIntent
Intent returns the /IT entry mapped to a FreeTextIntent. Returns FreeTextIntentFreeText (the spec default) if /IT is absent.
func (*FreeTextAnnotation) RegenerateAppearance ¶
func (a *FreeTextAnnotation) RegenerateAppearance()
RegenerateAppearance forces /AP/N to be rebuilt from current state.
func (*FreeTextAnnotation) SetBorderEffect ¶
func (a *FreeTextAnnotation) SetBorderEffect(e BorderEffect)
SetBorderEffect writes /BE/S. The default (BorderEffectNone) removes the /BE entry to keep the dict minimal.
func (*FreeTextAnnotation) SetBorderEffectIntensity ¶
func (a *FreeTextAnnotation) SetBorderEffectIntensity(i float64)
SetBorderEffectIntensity writes /BE/I (cloud intensity, typically 0-2). Setting to 0 removes the /I entry; if /BE becomes empty, removes /BE entirely.
func (*FreeTextAnnotation) SetBorderStyle ¶
func (d *FreeTextAnnotation) SetBorderStyle(s BorderStyle)
SetBorderStyle writes /BS/S using the PDF spec name codes.
func (*FreeTextAnnotation) SetBorderWidth ¶
func (d *FreeTextAnnotation) SetBorderWidth(w float64)
SetBorderWidth writes /BS/W and clears any legacy /Border array.
func (*FreeTextAnnotation) SetCalloutPoints ¶
func (a *FreeTextAnnotation) SetCalloutPoints(pts []Point)
SetCalloutPoints writes /CL (must be 2 or 3 points; otherwise the call is a no-op). Auto-sets Intent to FreeTextIntentCallout. The caller passes points in page-space coordinates; round-trip preserves them as written.
func (*FreeTextAnnotation) SetColor ¶
func (d *FreeTextAnnotation) SetColor(c *Color)
SetColor overrides annotationBase.SetColor to regenerate /AP/N after the stroke color changes.
func (*FreeTextAnnotation) SetContents ¶
func (a *FreeTextAnnotation) SetContents(s string)
SetContents writes /Contents and regenerates /AP/N (the rendered text content depends on Contents).
func (*FreeTextAnnotation) SetDashPattern ¶
func (d *FreeTextAnnotation) SetDashPattern(p []float64)
SetDashPattern writes /BS/D. The slice is copied; the caller may safely mutate p after this returns.
func (*FreeTextAnnotation) SetEndLineEnding ¶
func (a *FreeTextAnnotation) SetEndLineEnding(s LineEndingStyle)
SetEndLineEnding writes /LE for the callout endpoint shape.
func (*FreeTextAnnotation) SetInnerRect ¶
func (a *FreeTextAnnotation) SetInnerRect(inner Rectangle)
SetInnerRect writes /RD computed from the difference between the outer /Rect and the supplied inner rect (page-space). Negative distances are clamped to 0 to keep /RD spec-valid.
func (*FreeTextAnnotation) SetIntent ¶
func (a *FreeTextAnnotation) SetIntent(i FreeTextIntent)
SetIntent writes the /IT entry. The default (FreeTextIntentFreeText) removes the entry to keep the dict minimal.
func (*FreeTextAnnotation) SetRect ¶
func (d *FreeTextAnnotation) SetRect(r Rectangle)
SetRect overrides annotationBase.SetRect to regenerate /AP/N after the rectangle changes (the appearance stream's BBox is derived from /Rect).
func (*FreeTextAnnotation) SetTextStyle ¶
func (a *FreeTextAnnotation) SetTextStyle(s TextStyle)
SetTextStyle writes the style as /DA + /Q + /BG and regenerates /AP/N. VAlign is preserved in-memory (not stored in the PDF dict) and honored by the /AP/N renderer.
func (*FreeTextAnnotation) TextStyle ¶
func (a *FreeTextAnnotation) TextStyle() TextStyle
TextStyle returns the text style reconstructed from /DA + /Q + /BG. Only fields that round-trip through PDF dict entries are populated: Font, Size, Color, Background, HAlign. Other fields (LineSpacing, Underline, Strikethrough, Rotation, VAlign) are rendering hints honored when /AP/N is generated; they don't survive a round-trip through the dict.
type FreeTextIntent ¶
type FreeTextIntent int
FreeTextIntent per ISO 32000-1 §12.5.6.6 /IT entry. Defaults to FreeTextIntentFreeText (plain text in a rectangle).
const ( FreeTextIntentFreeText FreeTextIntent = iota // /FreeText FreeTextIntentCallout // /FreeTextCallout FreeTextIntentTypewriter // /FreeTextTypeWriter )
type GenericAnnotation ¶
type GenericAnnotation struct {
// contains filtered or unexported fields
}
GenericAnnotation is the catch-all surface for /Subtype values this release does not yet model (Stamp, FreeText, Ink, etc.). It exposes only the base Annotation accessors — callers can detect it via AnnotationType() == AnnotationTypeUnknown.
func (*GenericAnnotation) AnnotationType ¶
func (a *GenericAnnotation) AnnotationType() AnnotationType
func (*GenericAnnotation) Color ¶
func (b *GenericAnnotation) Color() *Color
Color returns the /C array as an RGB Color. Returns nil if /C is absent.
func (*GenericAnnotation) Contents ¶
func (b *GenericAnnotation) Contents() string
Contents returns /Contents (the annotation body text).
func (*GenericAnnotation) Flatten ¶ added in v0.3.0
func (b *GenericAnnotation) Flatten() error
Flatten bakes this annotation's normal appearance (/AP/N, honoring the /AS state) into its page's content stream at the annotation's /Rect, then removes the annotation. The annotation handle is dangling afterwards.
An annotation with no normal appearance (e.g. a sticky-note Text annotation, which viewers render as an icon) is simply removed — nothing is drawn.
Mirrors Aspose.PDF for .NET's Annotation.Flatten. For form-field widgets prefer (*Form).Flatten, which also clears the /AcroForm entry.
func (*GenericAnnotation) PageIndex ¶
func (b *GenericAnnotation) PageIndex() int
PageIndex returns the 1-based index of the page this annotation lives on. 0 if the annotation is not yet attached or its /P doesn't resolve.
func (*GenericAnnotation) Rect ¶
func (b *GenericAnnotation) Rect() Rectangle
Rect returns the annotation rectangle. Empty Rectangle if /Rect is missing or malformed.
func (*GenericAnnotation) SetColor ¶
func (b *GenericAnnotation) SetColor(c *Color)
SetColor writes /C as an RGB array; nil removes the entry.
func (*GenericAnnotation) SetContents ¶
func (b *GenericAnnotation) SetContents(s string)
SetContents writes /Contents (the annotation body text); empty string removes the entry.
func (*GenericAnnotation) SetRect ¶
func (b *GenericAnnotation) SetRect(r Rectangle)
SetRect writes the annotation rectangle.
type GifDevice ¶ added in v0.3.0
type GifDevice struct {
// contains filtered or unexported fields
}
GifDevice renders a page to GIF. Mirrors Aspose.PDF for .NET's GifDevice.
func NewGifDevice ¶ added in v0.3.0
func NewGifDevice(res Resolution) *GifDevice
NewGifDevice returns a GifDevice for the given resolution.
type GoToAction ¶
type GoToAction struct {
// contains filtered or unexported fields
}
GoToAction navigates to a page within the same document. PageNum is 1-based; Top is the y-coordinate of the destination view in default user space.
func NewGoToAction ¶
func NewGoToAction(pageNum int, top float64) *GoToAction
NewGoToAction builds a /GoTo action targeting the given 1-based page and a y-coordinate (top of view).
func (*GoToAction) ActionType ¶
func (a *GoToAction) ActionType() ActionType
func (*GoToAction) PageNum ¶
func (a *GoToAction) PageNum() int
PageNum returns the 1-based destination page number.
func (*GoToAction) SetPageNum ¶
func (a *GoToAction) SetPageNum(n int)
SetPageNum updates the destination page number (1-based).
func (*GoToAction) SetTop ¶
func (a *GoToAction) SetTop(t float64)
SetTop updates the y-coordinate of the destination view.
func (*GoToAction) Top ¶
func (a *GoToAction) Top() float64
Top returns the y-coordinate of the destination view.
type GoToURIAction ¶
type GoToURIAction struct {
// contains filtered or unexported fields
}
GoToURIAction opens a URI in the user's default handler (typically a web browser).
func NewGoToURIAction ¶
func NewGoToURIAction(uri string) *GoToURIAction
NewGoToURIAction builds a /URI action. Empty URI is permitted but usually not what callers want.
func (*GoToURIAction) ActionType ¶
func (a *GoToURIAction) ActionType() ActionType
func (*GoToURIAction) SetURI ¶
func (a *GoToURIAction) SetURI(uri string)
SetURI updates the destination URI.
type Gradient ¶ added in v0.3.0
type Gradient interface {
// contains filtered or unexported methods
}
Gradient is a fill that varies colour across a shape: either a LinearGradient or a RadialGradient. Assign one to ShapeStyle.FillGradient to fill a DrawRectangle / DrawRoundedRectangle / DrawCircle / DrawEllipse / DrawPolygon / DrawPath shape with it.
Coordinates are PDF user space (points; origin at the page bottom-left, Y up) — the same space as the shape being filled. Implemented as PDF axial (Type 2) and radial (Type 3) shading patterns. Limitations mirror the SVG renderer: the spread method is pad (the end colours extend past the gradient vector) and per-stop alpha is not rendered (shadings are opaque DeviceRGB).
type GradientStop ¶ added in v0.3.0
GradientStop is one colour stop in a gradient, positioned at Offset (0 at the gradient's start, 1 at its end). Stops should be supplied in ascending Offset order.
type HighlightAnnotation ¶
type HighlightAnnotation struct {
// contains filtered or unexported fields
}
HighlightAnnotation marks a region with semi-transparent highlight color. Renders natively in spec-conforming viewers from /Subtype + /QuadPoints + /C — no /AP needed.
func NewHighlightAnnotation ¶
func NewHighlightAnnotation(page *Page, rect Rectangle) *HighlightAnnotation
NewHighlightAnnotation builds an unbound highlight annotation. Page must be non-nil.
func (*HighlightAnnotation) AnnotationType ¶
func (a *HighlightAnnotation) AnnotationType() AnnotationType
func (*HighlightAnnotation) Color ¶
func (b *HighlightAnnotation) Color() *Color
Color returns the /C array as an RGB Color. Returns nil if /C is absent.
func (*HighlightAnnotation) Contents ¶
func (b *HighlightAnnotation) Contents() string
Contents returns /Contents (the annotation body text).
func (*HighlightAnnotation) Flatten ¶ added in v0.3.0
func (b *HighlightAnnotation) Flatten() error
Flatten bakes this annotation's normal appearance (/AP/N, honoring the /AS state) into its page's content stream at the annotation's /Rect, then removes the annotation. The annotation handle is dangling afterwards.
An annotation with no normal appearance (e.g. a sticky-note Text annotation, which viewers render as an icon) is simply removed — nothing is drawn.
Mirrors Aspose.PDF for .NET's Annotation.Flatten. For form-field widgets prefer (*Form).Flatten, which also clears the /AcroForm entry.
func (*HighlightAnnotation) PageIndex ¶
func (b *HighlightAnnotation) PageIndex() int
PageIndex returns the 1-based index of the page this annotation lives on. 0 if the annotation is not yet attached or its /P doesn't resolve.
func (*HighlightAnnotation) QuadPoints ¶
func (a *HighlightAnnotation) QuadPoints() []QuadPoint
QuadPoints returns the array of quads describing the selection. Returns nil if /QuadPoints is absent or its array length is not a multiple of 8 (malformed).
func (*HighlightAnnotation) Rect ¶
func (b *HighlightAnnotation) Rect() Rectangle
Rect returns the annotation rectangle. Empty Rectangle if /Rect is missing or malformed.
func (*HighlightAnnotation) SetColor ¶
func (b *HighlightAnnotation) SetColor(c *Color)
SetColor writes /C as an RGB array; nil removes the entry.
func (*HighlightAnnotation) SetContents ¶
func (b *HighlightAnnotation) SetContents(s string)
SetContents writes /Contents (the annotation body text); empty string removes the entry.
func (*HighlightAnnotation) SetQuadPoints ¶
func (a *HighlightAnnotation) SetQuadPoints(qp []QuadPoint)
SetQuadPoints writes /QuadPoints. nil or empty slice removes the entry.
func (*HighlightAnnotation) SetRect ¶
func (b *HighlightAnnotation) SetRect(r Rectangle)
SetRect writes the annotation rectangle.
type Image ¶
type Image struct {
Data []byte // encoded image bytes (PNG or JPEG)
Format ImageFormat // output format
Width int // pixel width
Height int // pixel height
BPC int // bits per component (original)
ColorSpace ImageColorSpace // original PDF color space
X, Y float64 // position on page (lower-left, in points)
PageWidth float64 // display width on page (in points)
PageHeight float64 // display height on page (in points)
Inline bool // true if from inline image (BI/ID/EI)
}
Image holds an extracted image with its encoded data and metadata.
type ImageColorSpace ¶
type ImageColorSpace int
ImageColorSpace describes the original color space of the image in the PDF.
const ( ColorSpaceDeviceRGB ImageColorSpace = iota ColorSpaceDeviceGray ColorSpaceDeviceCMYK ColorSpaceIndexed ColorSpaceICCBased )
type ImageFormat ¶
type ImageFormat int
ImageFormat describes the output format of an extracted image.
const ( ImageFormatPNG ImageFormat = iota ImageFormatJPEG )
type ImageInfo ¶
type ImageInfo struct {
Width int // pixel width
Height int // pixel height
BPC int // bits per component (original)
ColorSpace ImageColorSpace // original PDF color space
Format ImageFormat // output format (PNG or JPEG)
X, Y float64 // position on page (lower-left, in points)
PageWidth float64 // display width on page (in points)
PageHeight float64 // display height on page (in points)
Inline bool // true if from inline image (BI/ID/EI)
Name string // XObject name (e.g. "/Im0"); empty for inline
// contains filtered or unexported fields
}
ImageInfo holds metadata about an image found on a page without decoding pixel data. Call Extract() to perform the actual decoding and get the full Image.
func (*ImageInfo) Remove ¶
Remove removes the image from the page. Deletes the XObject reference from page resources and the drawing operators from the content stream. The underlying XObject remains in the document's object store (safe for shared references). Images inside Form XObjects are not supported; only page-level images can be removed.
type ImageToDocumentOptions ¶
type ImageToDocumentOptions struct {
PageWidth float64 // explicit page size in points; 0 = auto from image
PageHeight float64
MarginLeft float64
MarginRight float64
MarginTop float64
MarginBottom float64
}
ImageToDocumentOptions controls page sizing for ImageToDocument.
type InkAnnotation ¶
type InkAnnotation struct {
// contains filtered or unexported fields
}
InkAnnotation draws a series of free-form strokes — typically used to represent handwritten ink. Each stroke is a sequence of points rendered as a polyline; in Task 16 strokes with 3+ points get Catmull-Rom smoothing for visual quality.
func NewInkAnnotation ¶
func NewInkAnnotation(page *Page, strokes [][]Point) *InkAnnotation
NewInkAnnotation builds an unbound ink annotation. Page must be non-nil. Each inner slice is one continuous stroke. The /Rect entry is auto-computed as the bounding box of all stroke points plus padding equal to BorderWidth.
func (*InkAnnotation) AddStroke ¶
func (a *InkAnnotation) AddStroke(stroke []Point)
AddStroke appends a single stroke to the annotation. Convenience for incremental construction.
func (*InkAnnotation) AnnotationType ¶
func (a *InkAnnotation) AnnotationType() AnnotationType
func (*InkAnnotation) BorderStyle ¶
func (d *InkAnnotation) BorderStyle() BorderStyle
BorderStyle returns the /BS/S style. Defaults to BorderSolid if absent.
func (*InkAnnotation) BorderWidth ¶
func (d *InkAnnotation) BorderWidth() float64
BorderWidth returns the stroke line width. Reads /BS/W (preferred) or /Border[2] (legacy fallback). Defaults to 1 if neither is present.
func (*InkAnnotation) DashPattern ¶
func (d *InkAnnotation) DashPattern() []float64
DashPattern returns a defensive copy of the dash array. Reads /BS/D (preferred) or falls back to the legacy /Border[3] entry per ISO 32000-1 §12.5.4. Returns nil if neither is present.
func (*InkAnnotation) RegenerateAppearance ¶
func (a *InkAnnotation) RegenerateAppearance()
RegenerateAppearance forces /AP/N to be rebuilt from current properties.
func (*InkAnnotation) SetBorderStyle ¶
func (d *InkAnnotation) SetBorderStyle(s BorderStyle)
SetBorderStyle writes /BS/S using the PDF spec name codes.
func (*InkAnnotation) SetBorderWidth ¶
func (a *InkAnnotation) SetBorderWidth(w float64)
SetBorderWidth overrides drawingAnnotationBase.SetBorderWidth so /Rect (whose padding scales with BorderWidth) is recomputed before /AP/N regenerates — single-pass /BBox sync.
func (*InkAnnotation) SetColor ¶
func (d *InkAnnotation) SetColor(c *Color)
SetColor overrides annotationBase.SetColor to regenerate /AP/N after the stroke color changes.
func (*InkAnnotation) SetDashPattern ¶
func (d *InkAnnotation) SetDashPattern(p []float64)
SetDashPattern writes /BS/D. The slice is copied; the caller may safely mutate p after this returns.
func (*InkAnnotation) SetRect ¶
func (d *InkAnnotation) SetRect(r Rectangle)
SetRect overrides annotationBase.SetRect to regenerate /AP/N after the rectangle changes (the appearance stream's BBox is derived from /Rect).
func (*InkAnnotation) SetStrokes ¶
func (a *InkAnnotation) SetStrokes(strokes [][]Point)
SetStrokes writes /InkList. The slices are deep-copied; the caller may safely mutate after this returns.
func (*InkAnnotation) Strokes ¶
func (a *InkAnnotation) Strokes() [][]Point
Strokes returns a deep copy of /InkList. Mutating the result does not affect the annotation.
type JavaScriptAction ¶
type JavaScriptAction struct {
// contains filtered or unexported fields
}
JavaScriptAction holds a JavaScript snippet attached to an annotation. JS actions are both parsed from existing PDFs and constructable via NewJavaScriptAction; a constructed action is encoded back on Save.
func NewJavaScriptAction ¶
func NewJavaScriptAction(script string) *JavaScriptAction
NewJavaScriptAction builds a /JavaScript action carrying the given script. The action runs when its parent annotation is activated (clicked) by a viewer that supports JavaScript.
SECURITY WARNING: Embedding JavaScript in a PDF can introduce security risks for recipients. Scripts execute in the viewer's JavaScript engine context with access to form fields, navigation, and viewer-specific APIs (varies by viewer). Use only with scripts you authored or audited; never embed user-supplied JS without careful review.
JavaScript actions are commonly disabled by default in viewers (Acrobat: Preferences > Security > "Enable JavaScript") so behavior is not guaranteed across all rendering environments.
func (*JavaScriptAction) ActionType ¶
func (a *JavaScriptAction) ActionType() ActionType
func (*JavaScriptAction) Script ¶
func (a *JavaScriptAction) Script() string
type JpegDevice ¶ added in v0.3.0
type JpegDevice struct {
// contains filtered or unexported fields
}
JpegDevice renders a page to JPEG. Mirrors Aspose.PDF for .NET's JpegDevice.
func NewJpegDevice ¶ added in v0.3.0
func NewJpegDevice(res Resolution, quality int) *JpegDevice
NewJpegDevice returns a JpegDevice; quality outside 1..100 defaults to 90.
type LineAnnotation ¶
type LineAnnotation struct {
// contains filtered or unexported fields
}
LineAnnotation draws a straight line between two points, with optional line endings on each end (arrows, circles, etc. — added in Task 14). The /Rect entry is auto-computed from the endpoints + padding for line endings.
func NewLineAnnotation ¶
func NewLineAnnotation(page *Page, start, end Point) *LineAnnotation
NewLineAnnotation builds an unbound line annotation. Page must be non-nil. The /Rect is auto-computed as the bounding box of the line plus padding equal to 9 × BorderWidth (Acrobat convention) on each side.
func (*LineAnnotation) AnnotationType ¶
func (a *LineAnnotation) AnnotationType() AnnotationType
func (*LineAnnotation) BorderStyle ¶
func (d *LineAnnotation) BorderStyle() BorderStyle
BorderStyle returns the /BS/S style. Defaults to BorderSolid if absent.
func (*LineAnnotation) BorderWidth ¶
func (d *LineAnnotation) BorderWidth() float64
BorderWidth returns the stroke line width. Reads /BS/W (preferred) or /Border[2] (legacy fallback). Defaults to 1 if neither is present.
func (*LineAnnotation) DashPattern ¶
func (d *LineAnnotation) DashPattern() []float64
DashPattern returns a defensive copy of the dash array. Reads /BS/D (preferred) or falls back to the legacy /Border[3] entry per ISO 32000-1 §12.5.4. Returns nil if neither is present.
func (*LineAnnotation) EndLineEnding ¶
func (a *LineAnnotation) EndLineEnding() LineEndingStyle
EndLineEnding returns the style applied to the end of the line.
func (*LineAnnotation) InteriorColor ¶
func (a *LineAnnotation) InteriorColor() *Color
InteriorColor returns the /IC fill color (used for filled line endings: ClosedArrow, RClosedArrow, Square, Circle, Diamond). Returns nil if absent.
func (*LineAnnotation) LeaderLineLength ¶
func (a *LineAnnotation) LeaderLineLength() float64
LeaderLineLength returns the /LL value (0 if absent). Used for dimension-line annotations where the line is offset from the measured points by this much.
func (*LineAnnotation) RegenerateAppearance ¶
func (a *LineAnnotation) RegenerateAppearance()
RegenerateAppearance forces /AP/N to be rebuilt from current properties.
func (*LineAnnotation) SetBorderStyle ¶
func (d *LineAnnotation) SetBorderStyle(s BorderStyle)
SetBorderStyle writes /BS/S using the PDF spec name codes.
func (*LineAnnotation) SetBorderWidth ¶
func (a *LineAnnotation) SetBorderWidth(w float64)
SetBorderWidth overrides drawingAnnotationBase.SetBorderWidth so /Rect (which depends on BorderWidth via line-ending padding) is recomputed before /AP/N regenerates — ensuring the appearance stream's /BBox matches the new bounds in a single pass.
func (*LineAnnotation) SetColor ¶
func (d *LineAnnotation) SetColor(c *Color)
SetColor overrides annotationBase.SetColor to regenerate /AP/N after the stroke color changes.
func (*LineAnnotation) SetDashPattern ¶
func (d *LineAnnotation) SetDashPattern(p []float64)
SetDashPattern writes /BS/D. The slice is copied; the caller may safely mutate p after this returns.
func (*LineAnnotation) SetEnd ¶
func (a *LineAnnotation) SetEnd(p Point)
SetEnd updates the line's end point and recomputes /Rect.
func (*LineAnnotation) SetEndLineEnding ¶
func (a *LineAnnotation) SetEndLineEnding(s LineEndingStyle)
SetEndLineEnding sets the end-side line-ending style.
func (*LineAnnotation) SetInteriorColor ¶
func (a *LineAnnotation) SetInteriorColor(c *Color)
SetInteriorColor writes /IC as an RGB array; nil removes the entry.
func (*LineAnnotation) SetLeaderLineLength ¶
func (a *LineAnnotation) SetLeaderLineLength(l float64)
SetLeaderLineLength writes /LL. Zero removes the entry.
func (*LineAnnotation) SetRect ¶
func (d *LineAnnotation) SetRect(r Rectangle)
SetRect overrides annotationBase.SetRect to regenerate /AP/N after the rectangle changes (the appearance stream's BBox is derived from /Rect).
func (*LineAnnotation) SetStart ¶
func (a *LineAnnotation) SetStart(p Point)
SetStart updates the line's start point and recomputes /Rect.
func (*LineAnnotation) SetStartLineEnding ¶
func (a *LineAnnotation) SetStartLineEnding(s LineEndingStyle)
SetStartLineEnding sets the start-side line-ending style.
func (*LineAnnotation) Start ¶
func (a *LineAnnotation) Start() Point
Start returns the line's start point.
func (*LineAnnotation) StartLineEnding ¶
func (a *LineAnnotation) StartLineEnding() LineEndingStyle
StartLineEnding returns the style applied to the start of the line. Defaults to LineEndingNone if /LE is absent or malformed.
type LineEndingStyle ¶
type LineEndingStyle int
LineEndingStyle is one of the 10 line-ending shapes per ISO 32000-1 §12.5.6.7 Table 176, used in /Line annotations' /LE entry.
const ( LineEndingNone LineEndingStyle = iota LineEndingSquare LineEndingCircle LineEndingDiamond LineEndingOpenArrow LineEndingClosedArrow LineEndingButt LineEndingROpenArrow // OpenArrow rotated 180° (away from line) LineEndingRClosedArrow // ClosedArrow rotated 180° LineEndingSlash )
type LineJoin ¶
type LineJoin int
LineJoin is the /j line join style per ISO 32000-1 §8.4.3.4 Table 55.
type LineStyle ¶
type LineStyle struct {
Color *Color // nil → black {0,0,0,1}
Width float64 // ≤ 0 → no stroke (the draw call becomes a no-op for stroke)
DashPattern []float64 // [on, off, on, off, ...]; nil or empty → solid
DashPhase float64 // offset into the dash pattern, default 0
Cap LineCap // default LineCapButt (see appearance_builder.go); per ISO 32000-1 §8.4.3.3
Join LineJoin // default LineJoinMiter (see appearance_builder.go); per ISO 32000-1 §8.4.3.4
MiterLimit float64 // ≤ 0 → PDF default (10)
}
LineStyle describes how a stroked path is drawn.
Zero value: black, 0pt wide (no stroke), solid, butt cap, miter join. Mirrors Aspose.PDF for .NET's GraphInfo stroke fields.
type LinearGradient ¶ added in v0.3.0
type LinearGradient struct {
X1, Y1, X2, Y2 float64
Stops []GradientStop
}
LinearGradient interpolates colour along the line from (X1, Y1) to (X2, Y2). Use NewLinearGradient for the common case.
func NewLinearGradient ¶ added in v0.3.0
func NewLinearGradient(x1, y1, x2, y2 float64, stops ...GradientStop) LinearGradient
NewLinearGradient builds a linear gradient from (x1, y1) to (x2, y2) with the given stops.
type LinkAnnotation ¶
type LinkAnnotation struct {
// contains filtered or unexported fields
}
LinkAnnotation is a clickable region. Its visual is rendered by the viewer (no /AP needed). The associated /A action determines what happens on click — see Action and the various NewXxxAction factories.
func NewLinkAnnotation ¶
func NewLinkAnnotation(page *Page, rect Rectangle) *LinkAnnotation
NewLinkAnnotation builds an unbound link annotation. Page must be non-nil. The annotation is not added to the document until page.Annotations().Add(link) succeeds.
Example ¶
Add a clickable link annotation that opens an external URL.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc := pdf.NewDocumentFromFormat(pdf.PageFormatA4)
page, _ := doc.Page(1)
link := pdf.NewLinkAnnotation(page, pdf.Rectangle{LLX: 50, LLY: 700, URX: 300, URY: 720})
link.SetAction(pdf.NewGoToURIAction("https://pkg.go.dev/github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"))
if err := page.Annotations().Add(link); err != nil {
log.Fatal(err)
}
fmt.Println("annotations:", page.Annotations().Count())
}
Output: annotations: 1
func (*LinkAnnotation) Action ¶
func (a *LinkAnnotation) Action() Action
Action returns the action attached to this link, or nil if no /A is present or the action type is unsupported.
func (*LinkAnnotation) AnnotationType ¶
func (a *LinkAnnotation) AnnotationType() AnnotationType
func (*LinkAnnotation) BorderWidth ¶ added in v0.3.0
func (a *LinkAnnotation) BorderWidth() float64
BorderWidth returns the width (in points) of the rectangular border drawn around the link annotation. Returns the PDF default of 1pt when /Border is absent, matching the behaviour of viewers like Acrobat.
func (*LinkAnnotation) Color ¶
func (b *LinkAnnotation) Color() *Color
Color returns the /C array as an RGB Color. Returns nil if /C is absent.
func (*LinkAnnotation) Contents ¶
func (b *LinkAnnotation) Contents() string
Contents returns /Contents (the annotation body text).
func (*LinkAnnotation) Flatten ¶ added in v0.3.0
func (b *LinkAnnotation) Flatten() error
Flatten bakes this annotation's normal appearance (/AP/N, honoring the /AS state) into its page's content stream at the annotation's /Rect, then removes the annotation. The annotation handle is dangling afterwards.
An annotation with no normal appearance (e.g. a sticky-note Text annotation, which viewers render as an icon) is simply removed — nothing is drawn.
Mirrors Aspose.PDF for .NET's Annotation.Flatten. For form-field widgets prefer (*Form).Flatten, which also clears the /AcroForm entry.
func (*LinkAnnotation) Highlight ¶
func (a *LinkAnnotation) Highlight() LinkHighlightMode
Highlight returns the click-feedback mode (/H entry). Returns LinkHighlightInvert if /H is absent (the PDF default).
func (*LinkAnnotation) PageIndex ¶
func (b *LinkAnnotation) PageIndex() int
PageIndex returns the 1-based index of the page this annotation lives on. 0 if the annotation is not yet attached or its /P doesn't resolve.
func (*LinkAnnotation) Rect ¶
func (b *LinkAnnotation) Rect() Rectangle
Rect returns the annotation rectangle. Empty Rectangle if /Rect is missing or malformed.
func (*LinkAnnotation) SetAction ¶
func (a *LinkAnnotation) SetAction(act Action)
SetAction writes the /A entry. nil clears /A.
func (*LinkAnnotation) SetBorderWidth ¶ added in v0.3.0
func (a *LinkAnnotation) SetBorderWidth(width float64)
SetBorderWidth writes the /Border entry — [horiz-corner-radius vert-corner-radius border-width]. Pass 0 to suppress the rectangle PDF viewers otherwise draw around the link by default.
func (*LinkAnnotation) SetColor ¶
func (b *LinkAnnotation) SetColor(c *Color)
SetColor writes /C as an RGB array; nil removes the entry.
func (*LinkAnnotation) SetContents ¶
func (b *LinkAnnotation) SetContents(s string)
SetContents writes /Contents (the annotation body text); empty string removes the entry.
func (*LinkAnnotation) SetHighlight ¶
func (a *LinkAnnotation) SetHighlight(h LinkHighlightMode)
SetHighlight writes the /H entry. LinkHighlightInvert (the default) removes /H entirely so that the dict matches a freshly-created link.
func (*LinkAnnotation) SetRect ¶
func (b *LinkAnnotation) SetRect(r Rectangle)
SetRect writes the annotation rectangle.
type LinkHighlightMode ¶
type LinkHighlightMode int
LinkHighlightMode controls the visual feedback when the link is activated by the user (the /H entry per ISO 32000-1 §12.5.6.5).
const ( // LinkHighlightInvert (default) inverts the contents of the link // rectangle when activated. LinkHighlightInvert LinkHighlightMode = iota // LinkHighlightNone means no visible feedback on activation. LinkHighlightNone // LinkHighlightOutline inverts the annotation's border. LinkHighlightOutline // LinkHighlightPush visually depresses the rectangle on activation. LinkHighlightPush )
type ListBoxField ¶
type ListBoxField struct {
// contains filtered or unexported fields
}
ListBoxField is a single- or multi-select list choice field.
func (*ListBoxField) AddOption ¶
func (f *ListBoxField) AddOption(o ChoiceOption)
AddOption appends a ChoiceOption to /Opt.
func (*ListBoxField) Flatten ¶ added in v0.3.0
func (b *ListBoxField) Flatten() error
Flatten bakes this single field's appearance (each of its widgets) into the owning page content and removes the field, leaving every other field and the /AcroForm dict intact. Mirrors Aspose.PDF for .NET's Field.Flatten.
After Flatten the field handle is dangling and must not be used.
func (*ListBoxField) IsReadOnly ¶
func (b *ListBoxField) IsReadOnly() bool
func (*ListBoxField) IsRequired ¶
func (b *ListBoxField) IsRequired() bool
func (*ListBoxField) MultiSelect ¶
func (f *ListBoxField) MultiSelect() bool
func (*ListBoxField) Options ¶
func (f *ListBoxField) Options() []ChoiceOption
func (*ListBoxField) PartialName ¶
func (b *ListBoxField) PartialName() string
func (*ListBoxField) RemoveOption ¶
func (f *ListBoxField) RemoveOption(index int) error
RemoveOption removes the option at index. Errors on out-of-range.
func (*ListBoxField) Selected ¶
func (f *ListBoxField) Selected() []int
Selected returns the indices of currently selected options. Single- select listboxes return at most one element.
func (*ListBoxField) SetMultiSelect ¶
func (f *ListBoxField) SetMultiSelect(v bool)
SetMultiSelect toggles bit 22 (/Ff MultiSelect) on a ListBoxField.
func (*ListBoxField) SetReadOnly ¶
func (f *ListBoxField) SetReadOnly(v bool)
func (*ListBoxField) SetRequired ¶
func (f *ListBoxField) SetRequired(v bool)
func (*ListBoxField) SetSelected ¶
func (f *ListBoxField) SetSelected(indices ...int) error
SetSelected replaces the selected indices. Variadic arguments allow SetSelected() (clear), SetSelected(0) (single), SetSelected(0, 1) (multi). Multi-selection on a single-select listbox returns an error.
func (*ListBoxField) SetStyle ¶ added in v0.3.0
func (b *ListBoxField) SetStyle(s FieldStyle) error
SetStyle applies s to the field, writing /MK, /BS, /DA, and /Q on the field and its widgets and regenerating each widget's /AP appearance so the new look is visible immediately in every viewer. Returns an error only if the field is detached or a styled font cannot be registered.
func (*ListBoxField) SetValue ¶
func (f *ListBoxField) SetValue(s string) error
func (*ListBoxField) Style ¶ added in v0.3.0
func (b *ListBoxField) Style() FieldStyle
Style reads back the field's current styling from /DA, /Q, /MK, and /BS. Properties never set return their zero/default value. The first widget is used for /MK and /BS.
func (*ListBoxField) Value ¶
func (f *ListBoxField) Value() string
type MarginInfo ¶
MarginInfo describes margins or padding in points: Top / Right / Bottom / Left. Inside a Cell, MarginInfo represents the padding between the cell's border and its text content. Mirrors Aspose.PDF for .NET's MarginInfo.
type NamedAction ¶
type NamedAction struct {
// contains filtered or unexported fields
}
NamedAction triggers a built-in viewer command (FirstPage, Print, ...).
func NewNamedAction ¶
func NewNamedAction(n NamedActionType) *NamedAction
NewNamedAction builds a /Named action.
func (*NamedAction) ActionType ¶
func (a *NamedAction) ActionType() ActionType
func (*NamedAction) Name ¶
func (a *NamedAction) Name() NamedActionType
func (*NamedAction) SetName ¶
func (a *NamedAction) SetName(n NamedActionType)
type NamedActionType ¶
type NamedActionType int
NamedActionType identifies one of the standard viewer commands supported by /Named actions per ISO 32000-1 §12.6.4.11.
const ( NamedActionUnknown NamedActionType = iota NamedActionFirstPage NamedActionLastPage NamedActionNextPage NamedActionPrevPage NamedActionPrint )
type NamedDestination ¶
type NamedDestination struct {
// contains filtered or unexported fields
}
NamedDestination wraps a name reference into the document's NamedDestinations collection. Implements Destination so it can be used wherever an explicit destination is accepted (outline entries, future link annotation /Dest values, GoToAction).
Resolution is lazy: Page() and Resolve() look up the name in doc.NamedDestinations() at call time. This allows constructing a NamedDestination before adding the entry to the collection (forward reference).
Per ISO 32000-1 §12.3.2.3.
func NewNamedDestination ¶
func NewNamedDestination(doc *Document, name string) *NamedDestination
NewNamedDestination builds a name-reference destination. The name need not be registered yet — resolution is lazy at Page() and write time.
Aspose .NET: new NamedDestination(name) Go: pdf.NewNamedDestination(doc, name)
func (*NamedDestination) DestinationType ¶
func (n *NamedDestination) DestinationType() DestinationType
DestinationType returns DestinationTypeNamed.
func (*NamedDestination) Name ¶
func (n *NamedDestination) Name() string
Name returns the registered name this destination references.
func (*NamedDestination) Page ¶
func (n *NamedDestination) Page() *Page
Page resolves the underlying destination's page via the document's NamedDestinations collection. Returns nil if the name is not registered or the underlying destination has no Page.
func (*NamedDestination) Resolve ¶
func (n *NamedDestination) Resolve() Destination
Resolve returns the underlying explicit destination registered under this name, or nil if absent. Useful when you need the typed concrete (e.g. *DestinationXYZ to read coordinates).
type NamedDestinations ¶
type NamedDestinations struct {
// contains filtered or unexported fields
}
NamedDestinations is a name-to-destination map per ISO 32000-1 §12.3.2.3. Backed at PDF level by the modern /Catalog/Names/Dests name tree (PDF 1.2+); on read it also absorbs legacy /Catalog/Dests for backward compatibility. On write, only /Names/Dests is emitted.
Mirrors Aspose.PDF for .NET's NamedDestinations collection.
func (*NamedDestinations) Add ¶
func (n *NamedDestinations) Add(name string, dest Destination) error
Add registers dest under name. Errors on:
- empty name
- nil dest
- dest is itself a *NamedDestination (would create a name→name loop)
If name was already present, the previous value is replaced silently.
func (*NamedDestinations) All ¶
func (n *NamedDestinations) All() map[string]Destination
All returns a snapshot map of name → destination.
func (*NamedDestinations) Count ¶
func (n *NamedDestinations) Count() int
Count returns the number of registered entries.
func (*NamedDestinations) Document ¶
func (n *NamedDestinations) Document() *Document
Document returns the document this collection is bound to.
func (*NamedDestinations) Get ¶
func (n *NamedDestinations) Get(name string) Destination
Get returns the destination registered under name, or nil if absent. Never returns a *NamedDestination (no recursive lookups).
func (*NamedDestinations) Has ¶
func (n *NamedDestinations) Has(name string) bool
Has reports whether name is registered.
func (*NamedDestinations) Names ¶
func (n *NamedDestinations) Names() []string
Names returns a snapshot slice of all registered names in lex order.
func (*NamedDestinations) Remove ¶
func (n *NamedDestinations) Remove(name string) bool
Remove deletes the entry; returns true if it existed.
type OptimizeImageOptions ¶
type OptimizeImageOptions struct {
MaxDPI float64 // images above this DPI are downscaled; 0 = no downscaling
JPEGQuality int // JPEG quality 1-100; 0 = default (75)
ConvertPNGToJPEG bool // convert opaque PNG (no alpha) to JPEG
}
OptimizeImageOptions controls image optimization behavior.
type OutlineItemCollection ¶
type OutlineItemCollection struct {
// contains filtered or unexported fields
}
OutlineItemCollection represents an outline entry and the collection of its children. The recursive structure mirrors Aspose.PDF for .NET: each entry is both a tree node (with Title, Color, Action, Destination, etc.) and a collection (Add/At/Remove/Count for children). The root collection — returned by Document.Outlines() — has no parent and an empty Title; only its children are visible as top-level bookmarks.
Per ISO 32000-1 §12.3.3.
func NewOutlineItemCollection ¶
func NewOutlineItemCollection(doc *Document) *OutlineItemCollection
NewOutlineItemCollection builds an unattached outline entry bound to the given document. Add it to a parent via Document.Outlines().Add(...) or via another entry's Add(...) — until added it has no effect on the saved PDF.
Aspose .NET: new OutlineItemCollection(doc.Outlines) Go: pdf.NewOutlineItemCollection(doc)
func (*OutlineItemCollection) Action ¶
func (o *OutlineItemCollection) Action() Action
Action returns the action attached via /A. Reuses the Action interface defined for annotations.
func (*OutlineItemCollection) Add ¶
func (o *OutlineItemCollection) Add(child *OutlineItemCollection) error
Add appends child as the last child of this entry. Errors on nil, cross-document, cycle, or already-attached child.
func (*OutlineItemCollection) All ¶
func (o *OutlineItemCollection) All() []*OutlineItemCollection
All returns a snapshot slice of direct children.
func (*OutlineItemCollection) At ¶
func (o *OutlineItemCollection) At(index int) *OutlineItemCollection
At returns the child at the given 0-based index, or nil if out-of-range.
func (*OutlineItemCollection) Bold ¶
func (o *OutlineItemCollection) Bold() bool
Bold corresponds to /F bit 2 in the outline item dict. Default false.
func (*OutlineItemCollection) Color ¶
func (o *OutlineItemCollection) Color() *Color
Color returns the RGB label color, or nil if /C is absent (default black). SetColor(nil) clears /C.
func (*OutlineItemCollection) Count ¶
func (o *OutlineItemCollection) Count() int
Count returns the number of direct children (placeholder until Task 5 adds the rest of the collection API).
func (*OutlineItemCollection) Destination ¶
func (o *OutlineItemCollection) Destination() Destination
Destination returns the explicit view destination via /Dest, or nil if absent. If both Destination and Action are set, /Dest takes priority per ISO 32000-1 §12.3.3.
func (*OutlineItemCollection) Document ¶
func (o *OutlineItemCollection) Document() *Document
Document returns the document this collection is bound to.
func (*OutlineItemCollection) Insert ¶
func (o *OutlineItemCollection) Insert(index int, child *OutlineItemCollection) error
Insert inserts child at the given 0-based index among this entry's children.
func (*OutlineItemCollection) IsExpanded ¶
func (o *OutlineItemCollection) IsExpanded() bool
IsExpanded controls the viewer's initial expand/collapse state. Encoded via the sign of /Count. Default true.
func (*OutlineItemCollection) Italic ¶
func (o *OutlineItemCollection) Italic() bool
Italic corresponds to /F bit 1. Default false.
func (*OutlineItemCollection) Parent ¶
func (o *OutlineItemCollection) Parent() *OutlineItemCollection
Parent returns the parent entry, or nil for the root collection.
func (*OutlineItemCollection) Remove ¶
func (o *OutlineItemCollection) Remove(child *OutlineItemCollection) bool
Remove detaches child if it's a direct child. Returns true on hit.
func (*OutlineItemCollection) RemoveAt ¶
func (o *OutlineItemCollection) RemoveAt(index int) error
RemoveAt detaches the child at the given index.
func (*OutlineItemCollection) SetAction ¶
func (o *OutlineItemCollection) SetAction(a Action)
SetAction sets the /A action. Pass nil to clear.
func (*OutlineItemCollection) SetBold ¶
func (o *OutlineItemCollection) SetBold(b bool)
func (*OutlineItemCollection) SetColor ¶
func (o *OutlineItemCollection) SetColor(c *Color)
func (*OutlineItemCollection) SetDestination ¶
func (o *OutlineItemCollection) SetDestination(d Destination)
SetDestination sets the /Dest entry. Pass nil to clear.
func (*OutlineItemCollection) SetIsExpanded ¶
func (o *OutlineItemCollection) SetIsExpanded(b bool)
func (*OutlineItemCollection) SetItalic ¶
func (o *OutlineItemCollection) SetItalic(b bool)
func (*OutlineItemCollection) SetTitle ¶
func (o *OutlineItemCollection) SetTitle(s string)
SetTitle replaces the bookmark text.
func (*OutlineItemCollection) Title ¶
func (o *OutlineItemCollection) Title() string
Title returns the bookmark text.
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page is a live view of a single page within a Document. It reflects the current state of the document, including any mutations.
func (*Page) AddImage ¶
AddImage adds an image from a file to the page within the given rectangle.
Example ¶
Place a JPEG image on a blank page.
package main
import (
"bytes"
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc := pdf.NewDocumentFromFormat(pdf.PageFormatA4)
page, _ := doc.Page(1)
rect := pdf.Rectangle{LLX: 50, LLY: 50, URX: 300, URY: 300}
if err := page.AddImage("testdata/Koala.jpg", rect); err != nil {
log.Fatal(err)
}
var buf bytes.Buffer
if _, err := doc.WriteTo(&buf); err != nil {
log.Fatal(err)
}
fmt.Println("ok")
}
Output: ok
func (*Page) AddImageFromStream ¶
AddImageFromStream adds an image from a reader to the page within the given rectangle.
func (*Page) AddSVG ¶ added in v0.2.0
AddSVG reads an SVG file and renders it into the given rectangle on the page. Unsupported elements (text, image, gradients, masks) are skipped silently per Phase 2 scope.
Returns error only on XML parse failure, invalid numeric attributes, or I/O errors.
func (*Page) AddSVGFromStream ¶ added in v0.2.0
AddSVGFromStream renders an SVG from any io.Reader into the given rectangle on the page. Best-effort: unsupported elements are silently skipped.
func (*Page) AddSVGObject ¶ added in v0.2.0
AddSVGObject renders a pre-parsed SVG into the given rectangle on the page. Useful when the same SVG is rendered on multiple pages without re-parsing.
func (*Page) AddTable ¶
AddTable renders the table inside the given rectangle.
Returns the number of pages automatically appended to the document (0 when the table fits in rect). When the table doesn't fit and overflow is needed, new pages are appended with dimensions matching the receiver page; the continuation rectangle is computed from t.OverflowMargins(). Repeating header rows (see Table.SetRepeatingRowsCount) draw at the top of each page, including the original.
Errors before any drawing on validation failures: nil table, bad rect, non-positive column widths, mismatched cell counts (span-aware), merge overlaps, rowspan crossing the header/body boundary, or a spanning group too tall to fit any page.
func (*Page) AddText ¶
AddText draws text inside the rectangle using the given style. Text is wrapped at word boundaries to fit the rectangle width. Content exceeding the rectangle height is clipped.
Example ¶
Draw "Hello, world!" centered on a blank A4 page and write the resulting PDF to an in-memory buffer.
package main
import (
"bytes"
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc := pdf.NewDocumentFromFormat(pdf.PageFormatA4)
page, _ := doc.Page(1)
size, _ := page.Size()
style := pdf.TextStyle{
Font: pdf.FontHelveticaBold,
Size: 24,
HAlign: pdf.HAlignCenter,
VAlign: pdf.VAlignMiddle,
}
rect := pdf.Rectangle{LLX: 0, LLY: 0, URX: size.Width, URY: size.Height}
if err := page.AddText("Hello, world!", style, rect); err != nil {
log.Fatal(err)
}
var buf bytes.Buffer
if _, err := doc.WriteTo(&buf); err != nil {
log.Fatal(err)
}
fmt.Println("wrote:", buf.Len() > 0)
}
Output: wrote: true
func (*Page) Annotations ¶
func (p *Page) Annotations() *AnnotationCollection
Annotations returns the page's annotation collection. Always non-nil; for a page with no /Annots array, the collection is empty.
func (*Page) ArtBox ¶
ArtBox returns the art box of the page as a Rectangle. Falls back to CropBox, then MediaBox if not set.
func (*Page) BleedBox ¶
BleedBox returns the bleed box of the page as a Rectangle. Falls back to CropBox, then MediaBox if not set.
func (*Page) CropBox ¶
CropBox returns the crop box of the page as a Rectangle. Falls back to MediaBox if not set. Mirrors Aspose.PDF for .NET's Page.CropBox.
func (*Page) DrawCircle ¶
func (p *Page) DrawCircle(center Point, radius float64, style ShapeStyle) error
DrawCircle strokes and/or fills a circle. Returns error for negative radius. No-op if radius is zero or neither stroke nor fill is configured.
Mirrors Aspose.PDF for .NET's Drawing.Circle.
func (*Page) DrawEllipse ¶
func (p *Page) DrawEllipse(center Point, rx, ry float64, style ShapeStyle) error
DrawEllipse strokes and/or fills an axis-aligned ellipse. Returns error for negative semi-axis. No-op if either semi-axis is zero or neither stroke nor fill is configured.
Mirrors Aspose.PDF for .NET's Drawing.Ellipse.
func (*Page) DrawLine ¶
DrawLine strokes a single line segment from→to with the given style. No-op if style.Width <= 0.
Mirrors Aspose.PDF for .NET's Drawing.Line shape.
func (*Page) DrawPath ¶
func (p *Page) DrawPath(path *Path, style ShapeStyle) error
DrawPath strokes and/or fills the previously-built path. Errors if path is nil. No-op if path has no operations or style is empty.
Mirrors Aspose.PDF for .NET's Drawing.GraphicsPath / Drawing.Curve.
func (*Page) DrawPolygon ¶
func (p *Page) DrawPolygon(points []Point, style ShapeStyle) error
DrawPolygon strokes and/or fills a closed polygon (last point connects back to the first via `h`). Errors if len(points) < 3. No-op if neither stroke nor fill is configured.
Mirrors Aspose.PDF for .NET's Drawing.Polygon.
func (*Page) DrawPolyline ¶
DrawPolyline strokes an open polyline (first and last points are NOT connected). No fill — even if one were specified, an open path has ambiguous fill semantics. Errors if len(points) < 2. No-op if style.Width <= 0.
Mirrors Aspose.PDF for .NET's Drawing.Polyline.
func (*Page) DrawRectangle ¶
func (p *Page) DrawRectangle(rect Rectangle, style ShapeStyle) error
DrawRectangle strokes and/or fills an axis-aligned rectangle. No-op if neither stroke (Width > 0) nor fill (FillColor != nil) is set.
Mirrors Aspose.PDF for .NET's Drawing.Rectangle shape.
Example ¶
Draw a filled rectangle with a stroked border on a blank page.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc := pdf.NewDocumentFromFormat(pdf.PageFormatA4)
page, _ := doc.Page(1)
style := pdf.ShapeStyle{
LineStyle: pdf.LineStyle{
Color: &pdf.Color{R: 0.1, G: 0.3, B: 0.6, A: 1},
Width: 2,
},
FillColor: &pdf.Color{R: 0.85, G: 0.92, B: 1, A: 1},
}
rect := pdf.Rectangle{LLX: 100, LLY: 600, URX: 400, URY: 750}
if err := page.DrawRectangle(rect, style); err != nil {
log.Fatal(err)
}
fmt.Println("ok")
}
Output: ok
func (*Page) DrawRoundedRectangle ¶
func (p *Page) DrawRoundedRectangle(rect Rectangle, radius float64, style ShapeStyle) error
DrawRoundedRectangle strokes and/or fills an axis-aligned rectangle with rounded corners of the given radius. The radius is clamped to half the shorter side. Returns error for negative radius.
Implemented as a Path: 4 straight edges + 4 quarter-arc corners.
Mirrors Aspose.PDF for .NET's Drawing.RoundedRectangle.
func (*Page) ExtractImages ¶
ExtractImages returns all images found on the page.
func (*Page) ExtractText ¶
ExtractText returns the text content of the page. Characters from fonts with unrecognized encodings are replaced with U+FFFD.
func (*Page) ExtractTextWithLayout ¶
ExtractTextWithLayout returns structured text lines sorted in visual (top-to-bottom, left-to-right) reading order. Each line contains its concatenated text and individual fragments with positions.
func (*Page) ImageInfos ¶
ImageInfos returns metadata for all images found on the page without decoding pixel data.
func (*Page) Label ¶
Label returns the formatted page label for this page as defined by the document's /PageLabels number tree (PDF spec §12.4.2).
Common label styles:
- /D — decimal integers: 1, 2, 3, …
- /r — lowercase roman: i, ii, iii, …
- /R — uppercase roman: I, II, III, …
- /a — lowercase alphabetic: a, b, …, z, aa, ab, …
- /A — uppercase alphabetic: A, B, …, Z, AA, AB, …
A /P prefix string is prepended when present (e.g. "A-1", "A-2").
If the document has no /PageLabels entry, the decimal page number is returned.
func (*Page) MediaBox ¶ added in v0.3.0
MediaBox returns the page's MediaBox as a Rectangle in PDF user space. If not set on the page itself, it is inherited from the page tree. Mirrors Aspose.PDF for .NET's Page.MediaBox.
func (*Page) RenderBMP ¶ added in v0.3.0
func (p *Page) RenderBMP(w io.Writer, opts RenderOptions) error
RenderBMP renders the page and writes it as an uncompressed BMP.
func (*Page) RenderGIF ¶ added in v0.3.0
func (p *Page) RenderGIF(w io.Writer, opts RenderOptions) error
RenderGIF renders the page and writes it as GIF (256 colours, quantized).
func (*Page) RenderImage ¶ added in v0.3.0
func (p *Page) RenderImage(opts RenderOptions) (image.Image, error)
RenderImage rasterizes the page to an *image.RGBA at the requested DPI. The rendered region is the CropBox intersected with the MediaBox per ISO 32000-1 §7.7.3.3 (a stray CropBox larger than the page would otherwise shrink the content into a corner of an oversized canvas). Content the renderer does not yet support is skipped rather than erroring, so a page always produces an image.
func (*Page) RenderJPEG ¶ added in v0.3.0
RenderJPEG renders the page and writes it as JPEG. quality is 1..100; values outside that range use 90.
func (*Page) RenderPNG ¶ added in v0.3.0
func (p *Page) RenderPNG(w io.Writer, opts RenderOptions) error
RenderPNG renders the page and writes it as PNG.
func (*Page) RenderTIFF ¶ added in v0.3.0
func (p *Page) RenderTIFF(w io.Writer, opts RenderOptions) error
RenderTIFF renders the page and writes it as a single-page Deflate TIFF.
func (*Page) Rotation ¶
func (p *Page) Rotation() RotationAngle
Rotation returns the effective rotation of the page in degrees (0, 90, 180, 270).
func (*Page) SearchText ¶ added in v0.3.0
func (p *Page) SearchText(query string, opts ...SearchOptions) ([]TextMatch, error)
SearchText finds every occurrence of query on the page and returns the matches in visual reading order (top-to-bottom, left-to-right). Each match carries the matched text and a bounding rectangle in PDF user space.
By default the query is a case-sensitive literal string; pass a SearchOptions to enable case-insensitive and/or regular-expression matching. At most one SearchOptions is honored (the last, if several are passed).
This mirrors Aspose.PDF for .NET's TextFragmentAbsorber + page.Accept flow. Matches are located within a single text line: a query that would straddle a line break is not found. An empty query, or an invalid regular expression, returns an error.
func (*Page) SetArtBox ¶ added in v0.3.0
SetArtBox sets the page's ArtBox (meaningful content extent).
func (*Page) SetBleedBox ¶ added in v0.3.0
SetBleedBox sets the page's BleedBox (production bleed region).
func (*Page) SetCropBox ¶ added in v0.3.0
SetCropBox sets the page's CropBox (the visible region). Mirrors Page.CropBox.
func (*Page) SetMediaBox ¶ added in v0.3.0
SetMediaBox sets the page's MediaBox (the full page rectangle) in PDF user space. The box is written directly on the page, overriding any inherited or referenced value. Mirrors Aspose.PDF for .NET's Page.MediaBox setter.
func (*Page) SetPageSize ¶ added in v0.3.0
SetPageSize resizes the page by setting its MediaBox to [0 0 width height] (points). Existing content is not scaled or moved — only the page rectangle changes. Mirrors Aspose.PDF for .NET's Page.SetPageSize.
func (*Page) SetTrimBox ¶ added in v0.3.0
SetTrimBox sets the page's TrimBox (intended finished dimensions).
type PageFormat ¶
PageFormat describes a page size in points (1/72 inch).
func (PageFormat) Landscape ¶
func (f PageFormat) Landscape() PageFormat
Landscape returns the format with width and height swapped.
type PageLabelRange ¶ added in v0.3.0
type PageLabelRange struct {
StartPage int // 1-based page where this range begins
Style PageLabelStyle // numbering style
Prefix string // optional label prefix (e.g. "A-")
StartNum int // first number for this range; treated as 1 if ≤ 0
}
PageLabelRange describes a contiguous run of pages that share a numbering style. The first range must start at page 1; subsequent ranges inherit every preceding range's style/prefix until overridden. Mirrors the entries of a /PageLabels /Nums leaf per PDF spec §12.4.2.
type PageLabelStyle ¶ added in v0.3.0
type PageLabelStyle int
PageLabelStyle is the numbering style applied within a PageLabelRange. Mirrors the /S values from PDF spec §12.4.2 Table 159.
const ( PageLabelStyleNone PageLabelStyle = iota // no /S — only the prefix is rendered PageLabelDecimal // /D — 1, 2, 3, … PageLabelRomanLower // /r — i, ii, iii, … PageLabelRomanUpper // /R — I, II, III, … PageLabelAlphabeticLower // /a — a, b, …, z, aa, ab, … PageLabelAlphabeticUpper // /A — A, B, …, Z, AA, AB, … )
type PageRange ¶
type PageRange struct {
From, To int
}
PageRange specifies an inclusive range of pages (1-based).
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path is a sequence of MoveTo/LineTo/CurveTo/Close operations defining an arbitrary 2D path in PDF user space (origin at page bottom-left, Y up).
Construct via NewPath() and chain mutator methods, then pass to (*Page).DrawPath. Path is a builder type — it accumulates operations and holds no rendering state.
func (*Path) Arc ¶
Arc adds an arc to the path, approximated by cubic Bezier curves.
(cx, cy) is the center; r is the radius. startAngle and sweepAngle are in radians; sweepAngle may be negative (clockwise). The arc is subdivided into segments of ≤90°, each approximated by one cubic Bezier using k = (4/3) * tan(segmentAngle / 4) for the control-point magnitude.
If the path has no current point, MoveTo to the arc's start is implicit. After the call, the path's current point is the arc's endpoint.
No-op if r <= 0 or sweepAngle == 0.
func (*Path) Close ¶
Close closes the current subpath with a line back to the most recent MoveTo. PDF operator h.
func (*Path) CurveTo ¶
CurveTo adds a cubic Bezier curve from the current point to (x, y) with control points (c1x, c1y) and (c2x, c2y). PDF operator c.
func (*Path) LineTo ¶
LineTo adds a straight line segment from the current point to (x, y). If there is no current point, equivalent to MoveTo per PDF spec semantics.
func (*Path) QuadTo ¶
QuadTo adds a quadratic Bezier curve (one control point) from the current point to (x, y), automatically converted to the equivalent cubic per the standard quadratic-to-cubic formula:
C1 = P0 + (2/3) * (Q - P0) C2 = P3 + (2/3) * (Q - P3)
If there is no current point, treats (0, 0) as the start (matching PDF path semantics).
type Permissions ¶
type Permissions struct {
AllowPrint bool
AllowModify bool
AllowCopy bool
AllowAnnotations bool
AllowFormFill bool
AllowAccessibility bool
AllowAssembly bool
AllowPrintHighRes bool
}
Permissions controls what a viewer allows on an encrypted PDF. The zero value denies every operation. Permissions only take effect when the document is also encrypted (SetPassword); viewers enforce the bits — the library itself is not a DRM enforcer.
Per ISO 32000-1 §7.6.3.2 Table 22, bit meanings for R=3/R=4:
AllowPrint — bit 3 (low-resolution print) AllowModify — bit 4 (modify page contents) AllowCopy — bit 5 (copy text / extract graphics) AllowAnnotations — bit 6 (add/modify text annotations) AllowFormFill — bit 9 (fill in existing form fields) AllowAccessibility — bit 10 (extract text/graphics for accessibility) AllowAssembly — bit 11 (insert/rotate/delete pages) AllowPrintHighRes — bit 12 (print in high resolution)
type PngDevice ¶ added in v0.3.0
type PngDevice struct {
// contains filtered or unexported fields
}
PngDevice renders a page to PNG at a fixed resolution. Mirrors Aspose.PDF for .NET's PngDevice.
func NewPngDevice ¶ added in v0.3.0
func NewPngDevice(res Resolution) *PngDevice
NewPngDevice returns a PngDevice for the given resolution.
type Point ¶
type Point struct {
X, Y float64
}
Point is a single point in PDF user-space coordinates.
type QuadPoint ¶
type QuadPoint struct {
X1, Y1, X2, Y2, X3, Y3, X4, Y4 float64
}
QuadPoint is one quadrilateral within a markup annotation's /QuadPoints array. Per ISO 32000-1 §12.5.6.10 the eight floats name the corners in this order: (X1,Y1)=upper-left, (X2,Y2)=upper-right, (X3,Y3)=lower-left, (X4,Y4)=lower-right (in default user space, so "upper" means higher Y).
type RadialGradient ¶ added in v0.3.0
type RadialGradient struct {
CX, CY, R, FX, FY float64
Stops []GradientStop
}
RadialGradient interpolates colour from the focal point (FX, FY) out to the circle centred at (CX, CY) with radius R. NewRadialGradient sets the focal point to the centre (the common case); set FX/FY explicitly for an off-centre highlight.
func NewRadialGradient ¶ added in v0.3.0
func NewRadialGradient(cx, cy, r float64, stops ...GradientStop) RadialGradient
NewRadialGradient builds a radial gradient on the circle centred at (cx, cy) with radius r, focal point at the centre.
type RadioButtonField ¶
type RadioButtonField struct {
// contains filtered or unexported fields
}
RadioButtonField is a group of mutually exclusive options.
func (*RadioButtonField) Flatten ¶ added in v0.3.0
func (b *RadioButtonField) Flatten() error
Flatten bakes this single field's appearance (each of its widgets) into the owning page content and removes the field, leaving every other field and the /AcroForm dict intact. Mirrors Aspose.PDF for .NET's Field.Flatten.
After Flatten the field handle is dangling and must not be used.
func (*RadioButtonField) IsReadOnly ¶
func (b *RadioButtonField) IsReadOnly() bool
func (*RadioButtonField) IsRequired ¶
func (b *RadioButtonField) IsRequired() bool
func (*RadioButtonField) Options ¶
func (f *RadioButtonField) Options() []*RadioButtonOptionField
Options returns one RadioButtonOptionField per widget in the group.
func (*RadioButtonField) PartialName ¶
func (b *RadioButtonField) PartialName() string
func (*RadioButtonField) SetReadOnly ¶
func (f *RadioButtonField) SetReadOnly(v bool)
func (*RadioButtonField) SetRequired ¶
func (f *RadioButtonField) SetRequired(v bool)
func (*RadioButtonField) SetStyle ¶ added in v0.3.0
func (b *RadioButtonField) SetStyle(s FieldStyle) error
SetStyle applies s to the field, writing /MK, /BS, /DA, and /Q on the field and its widgets and regenerating each widget's /AP appearance so the new look is visible immediately in every viewer. Returns an error only if the field is detached or a styled font cannot be registered.
func (*RadioButtonField) SetValue ¶
func (f *RadioButtonField) SetValue(s string) error
SetValue takes the export name of the option to select. Empty string clears the selection (writes /Off). Any other unknown value returns an error.
func (*RadioButtonField) Style ¶ added in v0.3.0
func (b *RadioButtonField) Style() FieldStyle
Style reads back the field's current styling from /DA, /Q, /MK, and /BS. Properties never set return their zero/default value. The first widget is used for /MK and /BS.
func (*RadioButtonField) Value ¶
func (f *RadioButtonField) Value() string
type RadioButtonOptionField ¶
type RadioButtonOptionField struct {
// contains filtered or unexported fields
}
RadioButtonOptionField is one of the option widgets inside a RadioButtonField. Mirrors the C# nested type pattern.
func (*RadioButtonOptionField) Name ¶
func (o *RadioButtonOptionField) Name() string
Name returns the option's export value (its /AS state when selected, equivalently its non-/Off key in the widget's /AP/N dict).
func (*RadioButtonOptionField) Selected ¶
func (o *RadioButtonOptionField) Selected() bool
Selected reports whether this option is the currently selected one.
func (*RadioButtonOptionField) SetSelected ¶
func (o *RadioButtonOptionField) SetSelected(v bool)
SetSelected(true) selects this option and clears all siblings. SetSelected(false) clears the selection if this option is currently selected; siblings are unaffected.
type RadioItem ¶
RadioItem describes one widget inside a radio group. PageNum is 1-based; Export is the unique export value for this option (becomes the /AS state name when selected).
type Rectangle ¶
type Rectangle struct {
LLX, LLY float64 // lower-left corner
URX, URY float64 // upper-right corner
}
Rectangle represents a PDF rectangle [llx, lly, urx, ury] in points (1/72 inch).
type RedactAnnotation ¶
type RedactAnnotation struct {
// contains filtered or unexported fields
}
RedactAnnotation marks regions for redaction. Mark mode (this type) renders a semi-transparent fill of /QuadPoints regions. The destructive content removal happens when (*Document).ApplyRedactions is called — this annotation is then removed and the underlying page content is irreversibly rewritten. Per ISO 32000-1 §12.5.6.20.
func NewRedactAnnotation ¶
func NewRedactAnnotation(page *Page, rect Rectangle) *RedactAnnotation
NewRedactAnnotation builds an unbound redact annotation. Page must be non-nil. By default, /QuadPoints is empty (rendering uses /Rect as a single quad). Callers typically call SetQuadPoints to specify multiple disjoint regions.
func (*RedactAnnotation) AnnotationType ¶
func (a *RedactAnnotation) AnnotationType() AnnotationType
func (*RedactAnnotation) BorderStyle ¶
func (d *RedactAnnotation) BorderStyle() BorderStyle
BorderStyle returns the /BS/S style. Defaults to BorderSolid if absent.
func (*RedactAnnotation) BorderWidth ¶
func (d *RedactAnnotation) BorderWidth() float64
BorderWidth returns the stroke line width. Reads /BS/W (preferred) or /Border[2] (legacy fallback). Defaults to 1 if neither is present.
func (*RedactAnnotation) DashPattern ¶
func (d *RedactAnnotation) DashPattern() []float64
DashPattern returns a defensive copy of the dash array. Reads /BS/D (preferred) or falls back to the legacy /Border[3] entry per ISO 32000-1 §12.5.4. Returns nil if neither is present.
func (*RedactAnnotation) InteriorColor ¶
func (a *RedactAnnotation) InteriorColor() *Color
InteriorColor returns the /IC fill color (used for both mark visual and post-apply overlay). Returns nil if absent.
func (*RedactAnnotation) OverlayText ¶
func (a *RedactAnnotation) OverlayText() string
OverlayText returns /OverlayText. Empty string if absent.
func (*RedactAnnotation) OverlayTextStyle ¶
func (a *RedactAnnotation) OverlayTextStyle() TextStyle
OverlayTextStyle returns the style reconstructed from /DA + /Q. Background is not relevant for redact overlay.
func (*RedactAnnotation) QuadPoints ¶
func (a *RedactAnnotation) QuadPoints() []QuadPoint
QuadPoints returns the regions to redact in page space. Returns nil if /QuadPoints is absent (Apply uses /Rect as the single region).
func (*RedactAnnotation) RegenerateAppearance ¶
func (a *RedactAnnotation) RegenerateAppearance()
RegenerateAppearance forces /AP/N to be rebuilt.
func (*RedactAnnotation) RepeatOverlayText ¶
func (a *RedactAnnotation) RepeatOverlayText() bool
RepeatOverlayText returns /Repeat. False if absent.
func (*RedactAnnotation) SetBorderStyle ¶
func (d *RedactAnnotation) SetBorderStyle(s BorderStyle)
SetBorderStyle writes /BS/S using the PDF spec name codes.
func (*RedactAnnotation) SetBorderWidth ¶
func (d *RedactAnnotation) SetBorderWidth(w float64)
SetBorderWidth writes /BS/W and clears any legacy /Border array.
func (*RedactAnnotation) SetColor ¶
func (d *RedactAnnotation) SetColor(c *Color)
SetColor overrides annotationBase.SetColor to regenerate /AP/N after the stroke color changes.
func (*RedactAnnotation) SetDashPattern ¶
func (d *RedactAnnotation) SetDashPattern(p []float64)
SetDashPattern writes /BS/D. The slice is copied; the caller may safely mutate p after this returns.
func (*RedactAnnotation) SetInteriorColor ¶
func (a *RedactAnnotation) SetInteriorColor(c *Color)
SetInteriorColor writes /IC. nil deletes the entry.
func (*RedactAnnotation) SetOverlayText ¶
func (a *RedactAnnotation) SetOverlayText(s string)
SetOverlayText writes /OverlayText. Empty string deletes the entry.
func (*RedactAnnotation) SetOverlayTextStyle ¶
func (a *RedactAnnotation) SetOverlayTextStyle(s TextStyle)
SetOverlayTextStyle writes /DA + /Q.
func (*RedactAnnotation) SetQuadPoints ¶
func (a *RedactAnnotation) SetQuadPoints(qp []QuadPoint)
SetQuadPoints writes /QuadPoints. nil/empty slice removes the entry (Apply will then use /Rect as single region).
func (*RedactAnnotation) SetRect ¶
func (d *RedactAnnotation) SetRect(r Rectangle)
SetRect overrides annotationBase.SetRect to regenerate /AP/N after the rectangle changes (the appearance stream's BBox is derived from /Rect).
func (*RedactAnnotation) SetRepeatOverlayText ¶
func (a *RedactAnnotation) SetRepeatOverlayText(repeat bool)
SetRepeatOverlayText writes /Repeat. False removes the entry.
type RenderOptions ¶ added in v0.3.0
type RenderOptions struct {
DPI float64 // dots per inch; 0 → DefaultDPI
Background *Color // page backdrop; nil → opaque white
}
RenderOptions controls page rasterization.
type ResetFormAction ¶
type ResetFormAction struct {
// contains filtered or unexported fields
}
ResetFormAction resets named form fields to their /DV defaults.
func NewResetFormAction ¶
func NewResetFormAction(fields []string) *ResetFormAction
NewResetFormAction builds a /ResetForm action targeting the given field names. Empty fields means "reset all fields" per spec. The fields slice is copied; the caller may safely mutate it after this returns.
func (*ResetFormAction) ActionType ¶
func (a *ResetFormAction) ActionType() ActionType
func (*ResetFormAction) FieldNames ¶
func (a *ResetFormAction) FieldNames() []string
FieldNames returns a copy of the field-name list. The returned slice is owned by the caller; mutating it does not affect the action.
func (*ResetFormAction) SetFieldNames ¶
func (a *ResetFormAction) SetFieldNames(f []string)
SetFieldNames replaces the field-name list. The slice is copied; the caller may safely mutate f after this returns.
type Resolution ¶ added in v0.3.0
type Resolution struct{ DPI float64 }
Resolution is a rendering resolution in DPI. Mirrors Aspose.PDF for .NET's Aspose.Pdf.Devices.Resolution.
func NewResolution ¶ added in v0.3.0
func NewResolution(dpi float64) Resolution
NewResolution returns a Resolution of the given DPI.
type RotationAngle ¶
type RotationAngle int
RotationAngle represents a valid PDF page rotation in clockwise degrees.
const ( Rotate0 RotationAngle = 0 Rotate90 RotationAngle = 90 Rotate180 RotationAngle = 180 Rotate270 RotationAngle = 270 )
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row is a single row within a Table.
func (*Row) Background ¶
Background returns the row-level background color, or nil if unset.
func (*Row) Border ¶
func (r *Row) Border() *BorderInfo
Border returns the row-level border override, or nil if unset.
func (*Row) Margin ¶
func (r *Row) Margin() *MarginInfo
Margin returns the row-level margin override, or nil if unset.
func (*Row) SetBackground ¶
SetBackground sets a row-level background color. Cells in the row inherit this background unless the cell itself calls SetBackground.
func (*Row) SetBorder ¶
func (r *Row) SetBorder(b BorderInfo) *Row
SetBorder sets a row-level default border. Cells inherit unless overridden.
func (*Row) SetHeight ¶
SetHeight sets the row's drawn height in points. Pass 0 to use auto-fit (the renderer measures cell contents to compute a row height that fits).
func (*Row) SetMargin ¶
func (r *Row) SetMargin(m MarginInfo) *Row
SetMargin sets a row-level default cell padding. Cells inherit unless overridden.
func (*Row) SetTextStyle ¶
SetTextStyle sets a row-level default text style. Cells in the row inherit this style (overlaid on table.DefaultCellStyle) unless overridden per-cell.
type SVG ¶ added in v0.2.0
type SVG struct {
// contains filtered or unexported fields
}
SVG is the pre-parsed SVG document.
type SVGFontResolver ¶ added in v0.2.0
SVGFontResolver maps an SVG font-family + style to a pdf.Font. Return nil to fall back to the library's built-in heuristic (Standard 14 mapping based on family keyword).
type SearchOptions ¶ added in v0.3.0
type SearchOptions struct {
// CaseInsensitive folds case when matching (literal and regex alike).
CaseInsensitive bool
// Regex treats the query as an RE2 regular expression instead of a literal
// string. Invalid patterns are reported as an error by SearchText.
Regex bool
}
SearchOptions tunes how SearchText interprets the query. The zero value is a case-sensitive literal search, matching the default of Aspose.PDF for .NET's TextFragmentAbsorber.
type ShapeStyle ¶
type ShapeStyle struct {
LineStyle
FillColor *Color // nil = no fill
FillPattern string // optional PDF pattern resource name (e.g. "/P0"); overrides FillColor when set
FillGradient Gradient // optional linear/radial gradient fill; overrides FillColor
}
ShapeStyle combines a stroke (LineStyle) with an optional fill color.
FillColor nil → no fill (stroke-only). Width ≤ 0 in the embedded LineStyle → no stroke (fill-only). If both are unset, the draw call is a no-op.
FillPattern, when non-empty, overrides FillColor: the fill uses a PDF /Pattern colorspace with the named pattern resource (e.g. "/P0"). Used internally by the SVG renderer to wire gradient fills.
FillGradient, when non-nil, fills the shape with a LinearGradient or RadialGradient. It takes precedence over FillColor; the draw call registers the necessary PDF shading pattern on the page automatically.
Mirrors Aspose.PDF for .NET's GraphInfo (stroke + fill).
type SquareAnnotation ¶
type SquareAnnotation struct {
// contains filtered or unexported fields
}
SquareAnnotation draws a rectangular annotation with stroked border and optional interior fill. Renders natively from /AP/N — Solid, Dashed, Beveled, Inset, and Underline border styles supported.
func NewSquareAnnotation ¶
func NewSquareAnnotation(page *Page, rect Rectangle) *SquareAnnotation
NewSquareAnnotation builds an unbound square annotation. Page must be non-nil. The annotation is not added to the document until page.Annotations().Add(square) succeeds.
func (*SquareAnnotation) AnnotationType ¶
func (a *SquareAnnotation) AnnotationType() AnnotationType
func (*SquareAnnotation) BorderStyle ¶
func (d *SquareAnnotation) BorderStyle() BorderStyle
BorderStyle returns the /BS/S style. Defaults to BorderSolid if absent.
func (*SquareAnnotation) BorderWidth ¶
func (d *SquareAnnotation) BorderWidth() float64
BorderWidth returns the stroke line width. Reads /BS/W (preferred) or /Border[2] (legacy fallback). Defaults to 1 if neither is present.
func (*SquareAnnotation) DashPattern ¶
func (d *SquareAnnotation) DashPattern() []float64
DashPattern returns a defensive copy of the dash array. Reads /BS/D (preferred) or falls back to the legacy /Border[3] entry per ISO 32000-1 §12.5.4. Returns nil if neither is present.
func (*SquareAnnotation) InteriorColor ¶
func (a *SquareAnnotation) InteriorColor() *Color
InteriorColor returns the /IC fill color, or nil if absent.
func (*SquareAnnotation) RegenerateAppearance ¶
func (a *SquareAnnotation) RegenerateAppearance()
RegenerateAppearance forces /AP/N to be rebuilt from current properties. Useful when the underlying dict was mutated directly (bypassing setters).
func (*SquareAnnotation) SetBorderStyle ¶
func (d *SquareAnnotation) SetBorderStyle(s BorderStyle)
SetBorderStyle writes /BS/S using the PDF spec name codes.
func (*SquareAnnotation) SetBorderWidth ¶
func (d *SquareAnnotation) SetBorderWidth(w float64)
SetBorderWidth writes /BS/W and clears any legacy /Border array.
func (*SquareAnnotation) SetColor ¶
func (d *SquareAnnotation) SetColor(c *Color)
SetColor overrides annotationBase.SetColor to regenerate /AP/N after the stroke color changes.
func (*SquareAnnotation) SetDashPattern ¶
func (d *SquareAnnotation) SetDashPattern(p []float64)
SetDashPattern writes /BS/D. The slice is copied; the caller may safely mutate p after this returns.
func (*SquareAnnotation) SetInteriorColor ¶
func (a *SquareAnnotation) SetInteriorColor(c *Color)
SetInteriorColor writes /IC as an RGB array; nil removes the entry.
type SquigglyAnnotation ¶
type SquigglyAnnotation struct {
// contains filtered or unexported fields
}
SquigglyAnnotation draws a wavy underline under text (typically used for spell-check style hints).
func NewSquigglyAnnotation ¶
func NewSquigglyAnnotation(page *Page, rect Rectangle) *SquigglyAnnotation
NewSquigglyAnnotation builds an unbound squiggly-underline annotation.
func (*SquigglyAnnotation) AnnotationType ¶
func (a *SquigglyAnnotation) AnnotationType() AnnotationType
func (*SquigglyAnnotation) Color ¶
func (b *SquigglyAnnotation) Color() *Color
Color returns the /C array as an RGB Color. Returns nil if /C is absent.
func (*SquigglyAnnotation) Contents ¶
func (b *SquigglyAnnotation) Contents() string
Contents returns /Contents (the annotation body text).
func (*SquigglyAnnotation) Flatten ¶ added in v0.3.0
func (b *SquigglyAnnotation) Flatten() error
Flatten bakes this annotation's normal appearance (/AP/N, honoring the /AS state) into its page's content stream at the annotation's /Rect, then removes the annotation. The annotation handle is dangling afterwards.
An annotation with no normal appearance (e.g. a sticky-note Text annotation, which viewers render as an icon) is simply removed — nothing is drawn.
Mirrors Aspose.PDF for .NET's Annotation.Flatten. For form-field widgets prefer (*Form).Flatten, which also clears the /AcroForm entry.
func (*SquigglyAnnotation) PageIndex ¶
func (b *SquigglyAnnotation) PageIndex() int
PageIndex returns the 1-based index of the page this annotation lives on. 0 if the annotation is not yet attached or its /P doesn't resolve.
func (*SquigglyAnnotation) QuadPoints ¶
func (a *SquigglyAnnotation) QuadPoints() []QuadPoint
QuadPoints returns the array of quads describing the squiggly region. Returns nil if /QuadPoints is absent or its array length is not a multiple of 8 (malformed).
func (*SquigglyAnnotation) Rect ¶
func (b *SquigglyAnnotation) Rect() Rectangle
Rect returns the annotation rectangle. Empty Rectangle if /Rect is missing or malformed.
func (*SquigglyAnnotation) SetColor ¶
func (b *SquigglyAnnotation) SetColor(c *Color)
SetColor writes /C as an RGB array; nil removes the entry.
func (*SquigglyAnnotation) SetContents ¶
func (b *SquigglyAnnotation) SetContents(s string)
SetContents writes /Contents (the annotation body text); empty string removes the entry.
func (*SquigglyAnnotation) SetQuadPoints ¶
func (a *SquigglyAnnotation) SetQuadPoints(qp []QuadPoint)
SetQuadPoints writes /QuadPoints. nil or empty slice removes the entry.
func (*SquigglyAnnotation) SetRect ¶
func (b *SquigglyAnnotation) SetRect(r Rectangle)
SetRect writes the annotation rectangle.
type StampAnnotation ¶
type StampAnnotation struct {
// contains filtered or unexported fields
}
StampAnnotation is a rubber-stamp annotation. Renders one of 14 predefined visuals (Approved, Confidential, Draft, etc.) or a custom image. Per ISO 32000-1 §12.5.6.13.
func NewStampAnnotation ¶
func NewStampAnnotation(page *Page, rect Rectangle, name StampName) *StampAnnotation
NewStampAnnotation builds an unbound stamp annotation. Page must be non-nil. /Name defaults to the supplied name (use StampNameDraft if uncertain).
func (*StampAnnotation) AnnotationType ¶
func (a *StampAnnotation) AnnotationType() AnnotationType
func (*StampAnnotation) BorderStyle ¶
func (d *StampAnnotation) BorderStyle() BorderStyle
BorderStyle returns the /BS/S style. Defaults to BorderSolid if absent.
func (*StampAnnotation) BorderWidth ¶
func (d *StampAnnotation) BorderWidth() float64
BorderWidth returns the stroke line width. Reads /BS/W (preferred) or /Border[2] (legacy fallback). Defaults to 1 if neither is present.
func (*StampAnnotation) ClearCustomImage ¶
func (a *StampAnnotation) ClearCustomImage()
ClearCustomImage reverts /AP/N to the predefined-name template visual. The previously-attached image XObject becomes orphan and can be reclaimed via doc.RemoveUnusedObjects().
func (*StampAnnotation) DashPattern ¶
func (d *StampAnnotation) DashPattern() []float64
DashPattern returns a defensive copy of the dash array. Reads /BS/D (preferred) or falls back to the legacy /Border[3] entry per ISO 32000-1 §12.5.4. Returns nil if neither is present.
func (*StampAnnotation) HasCustomImage ¶
func (a *StampAnnotation) HasCustomImage() bool
HasCustomImage returns true if SetCustomImage / SetCustomImageFromStream has been called and not subsequently cleared. Stub for now — full custom-image support in Task 8.
func (*StampAnnotation) Name ¶
func (a *StampAnnotation) Name() StampName
Name returns the StampName decoded from /Name. Returns StampNameUnknown for non-spec custom names.
func (*StampAnnotation) RawName ¶
func (a *StampAnnotation) RawName() string
RawName returns the /Name entry as a raw string ("/Approved", custom).
func (*StampAnnotation) RegenerateAppearance ¶
func (a *StampAnnotation) RegenerateAppearance()
RegenerateAppearance forces /AP/N to be rebuilt from current state.
func (*StampAnnotation) SetBorderStyle ¶
func (d *StampAnnotation) SetBorderStyle(s BorderStyle)
SetBorderStyle writes /BS/S using the PDF spec name codes.
func (*StampAnnotation) SetBorderWidth ¶
func (d *StampAnnotation) SetBorderWidth(w float64)
SetBorderWidth writes /BS/W and clears any legacy /Border array.
func (*StampAnnotation) SetColor ¶
func (d *StampAnnotation) SetColor(c *Color)
SetColor overrides annotationBase.SetColor to regenerate /AP/N after the stroke color changes.
func (*StampAnnotation) SetCustomImage ¶
func (a *StampAnnotation) SetCustomImage(path string) error
SetCustomImage embeds the image at path as the stamp's /AP/N visual, overriding the predefined-name template. Format auto-detected from magic bytes (JPEG, PNG).
func (*StampAnnotation) SetCustomImageFromStream ¶
func (a *StampAnnotation) SetCustomImageFromStream(r io.Reader) error
SetCustomImageFromStream is the io.Reader variant of SetCustomImage.
func (*StampAnnotation) SetDashPattern ¶
func (d *StampAnnotation) SetDashPattern(p []float64)
SetDashPattern writes /BS/D. The slice is copied; the caller may safely mutate p after this returns.
func (*StampAnnotation) SetName ¶
func (a *StampAnnotation) SetName(n StampName)
SetName writes the /Name entry from a typed StampName.
func (*StampAnnotation) SetRawName ¶
func (a *StampAnnotation) SetRawName(s string)
SetRawName writes the /Name entry from a raw string. Used for non-spec custom names. Calling SetRawName with a value not matching any spec name will cause Name() to return StampNameUnknown.
type StampName ¶
type StampName int
StampName names per ISO 32000-1 §12.5.6.13 Table 184. Used in /Subtype /Stamp annotations' /Name entry. Unknown handles non-spec custom names (round-tripped via RawName).
const ( StampNameUnknown StampName = iota StampNameApproved StampNameAsIs StampNameConfidential StampNameDepartmental StampNameDraft // PDF default StampNameExperimental StampNameExpired StampNameFinal StampNameForComment StampNameForPublicRelease StampNameNotApproved StampNameNotForPublicRelease StampNameSold StampNameTopSecret )
type StrikeOutAnnotation ¶
type StrikeOutAnnotation struct {
// contains filtered or unexported fields
}
StrikeOutAnnotation draws a horizontal line through text.
func NewStrikeOutAnnotation ¶
func NewStrikeOutAnnotation(page *Page, rect Rectangle) *StrikeOutAnnotation
NewStrikeOutAnnotation builds an unbound strike-out annotation.
func (*StrikeOutAnnotation) AnnotationType ¶
func (a *StrikeOutAnnotation) AnnotationType() AnnotationType
func (*StrikeOutAnnotation) Color ¶
func (b *StrikeOutAnnotation) Color() *Color
Color returns the /C array as an RGB Color. Returns nil if /C is absent.
func (*StrikeOutAnnotation) Contents ¶
func (b *StrikeOutAnnotation) Contents() string
Contents returns /Contents (the annotation body text).
func (*StrikeOutAnnotation) Flatten ¶ added in v0.3.0
func (b *StrikeOutAnnotation) Flatten() error
Flatten bakes this annotation's normal appearance (/AP/N, honoring the /AS state) into its page's content stream at the annotation's /Rect, then removes the annotation. The annotation handle is dangling afterwards.
An annotation with no normal appearance (e.g. a sticky-note Text annotation, which viewers render as an icon) is simply removed — nothing is drawn.
Mirrors Aspose.PDF for .NET's Annotation.Flatten. For form-field widgets prefer (*Form).Flatten, which also clears the /AcroForm entry.
func (*StrikeOutAnnotation) PageIndex ¶
func (b *StrikeOutAnnotation) PageIndex() int
PageIndex returns the 1-based index of the page this annotation lives on. 0 if the annotation is not yet attached or its /P doesn't resolve.
func (*StrikeOutAnnotation) QuadPoints ¶
func (a *StrikeOutAnnotation) QuadPoints() []QuadPoint
QuadPoints returns the array of quads describing the strike-out region. Returns nil if /QuadPoints is absent or its array length is not a multiple of 8 (malformed).
func (*StrikeOutAnnotation) Rect ¶
func (b *StrikeOutAnnotation) Rect() Rectangle
Rect returns the annotation rectangle. Empty Rectangle if /Rect is missing or malformed.
func (*StrikeOutAnnotation) SetColor ¶
func (b *StrikeOutAnnotation) SetColor(c *Color)
SetColor writes /C as an RGB array; nil removes the entry.
func (*StrikeOutAnnotation) SetContents ¶
func (b *StrikeOutAnnotation) SetContents(s string)
SetContents writes /Contents (the annotation body text); empty string removes the entry.
func (*StrikeOutAnnotation) SetQuadPoints ¶
func (a *StrikeOutAnnotation) SetQuadPoints(qp []QuadPoint)
SetQuadPoints writes /QuadPoints. nil or empty slice removes the entry.
func (*StrikeOutAnnotation) SetRect ¶
func (b *StrikeOutAnnotation) SetRect(r Rectangle)
SetRect writes the annotation rectangle.
type SubmitFormAction ¶
type SubmitFormAction struct {
// contains filtered or unexported fields
}
SubmitFormAction submits form field values to a URL.
func NewSubmitFormAction ¶
func NewSubmitFormAction(url string, fields []string, flags SubmitFormFlags) *SubmitFormAction
NewSubmitFormAction builds a /SubmitForm action. The fields slice is copied; the caller may safely mutate it after this returns.
func (*SubmitFormAction) ActionType ¶
func (a *SubmitFormAction) ActionType() ActionType
func (*SubmitFormAction) FieldNames ¶
func (a *SubmitFormAction) FieldNames() []string
FieldNames returns a copy of the field-name list. The returned slice is owned by the caller; mutating it does not affect the action.
func (*SubmitFormAction) Flags ¶
func (a *SubmitFormAction) Flags() SubmitFormFlags
func (*SubmitFormAction) SetFieldNames ¶
func (a *SubmitFormAction) SetFieldNames(f []string)
SetFieldNames replaces the field-name list. The slice is copied; the caller may safely mutate f after this returns.
func (*SubmitFormAction) SetFlags ¶
func (a *SubmitFormAction) SetFlags(f SubmitFormFlags)
func (*SubmitFormAction) SetURL ¶
func (a *SubmitFormAction) SetURL(u string)
func (*SubmitFormAction) URL ¶
func (a *SubmitFormAction) URL() string
type SubmitFormFlags ¶
type SubmitFormFlags int
SubmitFormFlags is the /Flags bitfield for a /SubmitForm action per ISO 32000-1 Table 237. Bit 1 is least significant.
const ( SubmitIncludeNoValueFields SubmitFormFlags = 1 << 1 SubmitExportFormat SubmitFormFlags = 1 << 2 SubmitGetMethod SubmitFormFlags = 1 << 3 SubmitSubmitCoordinates SubmitFormFlags = 1 << 4 SubmitXFDF SubmitFormFlags = 1 << 5 SubmitIncludeAppendSaves SubmitFormFlags = 1 << 6 SubmitIncludeAnnotations SubmitFormFlags = 1 << 7 SubmitSubmitPDF SubmitFormFlags = 1 << 8 SubmitCanonicalFormat SubmitFormFlags = 1 << 9 SubmitExclNonUserAnnots SubmitFormFlags = 1 << 10 SubmitExclFKey SubmitFormFlags = 1 << 11 SubmitEmbedForm SubmitFormFlags = 1 << 13 )
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a transient builder for a tabular layout drawn onto a Page. Mirrors Aspose.PDF for .NET's Table class. After (*Page).AddTable renders the table, the *Table is not held by the document.
func NewTable ¶
func NewTable() *Table
NewTable returns an empty table. Configure via Set* methods + AddRow. Mirrors Aspose.PDF for .NET's `new Table()` constructor.
Example ¶
Build a tiny invoice-style table and render it onto a blank page.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
doc := pdf.NewDocumentFromFormat(pdf.PageFormatA4)
page, _ := doc.Page(1)
table := pdf.NewTable().
SetColumnWidths([]float64{300, 100}).
SetDefaultCellBorder(pdf.BorderInfo{Sides: pdf.BorderSideAll, Width: 0.5}).
SetDefaultCellMargin(pdf.MarginInfo{Top: 4, Right: 6, Bottom: 4, Left: 6})
header := table.AddRow()
header.AddCell("Item").SetTextStyle(pdf.TextStyle{Font: pdf.FontHelveticaBold, Size: 11})
header.AddCell("Price").SetTextStyle(pdf.TextStyle{Font: pdf.FontHelveticaBold, Size: 11}).
SetHAlign(pdf.HAlignRight)
table.AddRows([][]string{
{"Espresso", "€3.50"},
{"Cappuccino", "€4.50"},
{"Tiramisu", "€7.50"},
})
rect := pdf.Rectangle{LLX: 50, LLY: 500, URX: 450, URY: 750}
if _, err := page.AddTable(table, rect); err != nil {
log.Fatal(err)
}
fmt.Println("rows:", table.RowCount())
}
Output: rows: 4
func (*Table) AddRows ¶
AddRows is a convenience that creates one Row per inner slice and one Cell per string in that slice. Returns the rows in insertion order so callers can apply further per-row customization (SetBackground, SetHeight, etc.).
Rows added through AddRows have plain cells — no ColSpan/RowSpan. For spanning, use the explicit AddRow + Cell.SetColSpan flow.
func (*Table) Border ¶
func (t *Table) Border() BorderInfo
func (*Table) ColumnWidths ¶
ColumnWidths returns a copy of the column widths.
func (*Table) DefaultCellBorder ¶
func (t *Table) DefaultCellBorder() BorderInfo
func (*Table) DefaultCellMargin ¶
func (t *Table) DefaultCellMargin() MarginInfo
func (*Table) DefaultCellStyle ¶
func (*Table) OverflowMargins ¶
OverflowMargins returns the configured overflow margins (defaults 50/50 if SetOverflowMargins has not been called).
func (*Table) RepeatingRowsCount ¶
RepeatingRowsCount returns the number of header rows that repeat on each continuation page (default 0).
func (*Table) SetBorder ¶
func (t *Table) SetBorder(b BorderInfo) *Table
func (*Table) SetColumnWidths ¶
SetColumnWidths sets the column widths in points. Defensive-copies the slice.
func (*Table) SetDefaultCellBorder ¶
func (t *Table) SetDefaultCellBorder(b BorderInfo) *Table
func (*Table) SetDefaultCellMargin ¶
func (t *Table) SetDefaultCellMargin(m MarginInfo) *Table
func (*Table) SetDefaultCellStyle ¶
func (*Table) SetOverflowMargins ¶
SetOverflowMargins sets the top/bottom margins (in points) used to compute the continuation-page bounding rectangle when the table overflows the original rect. Defaults: 50pt on each side.
The continuation rect uses the same LLX/URX as the original rect; the Y range becomes [bottom, pageHeight - top].
func (*Table) SetRepeatingRowsCount ¶
SetRepeatingRowsCount marks the first n rows as headers that repeat at the top of every continuation page. Default 0 (no repeat).
Mirrors Aspose.PDF for .NET's Table.RepeatingRowsCount property.
type TextAnnotation ¶
type TextAnnotation struct {
// contains filtered or unexported fields
}
TextAnnotation is a sticky-note annotation. Renders as an icon (no /AP/N — viewers draw their own icon for the /Name value). The associated /Contents is the note's body text shown in a popup when the icon is clicked.
func NewTextAnnotation ¶
func NewTextAnnotation(page *Page, position Point) *TextAnnotation
NewTextAnnotation builds an unbound text-note annotation. Page must be non-nil. The /Rect is auto-computed as a 24×24 pt square anchored at position (Acrobat sticky-note convention).
func (*TextAnnotation) AnnotationType ¶
func (a *TextAnnotation) AnnotationType() AnnotationType
func (*TextAnnotation) Color ¶
func (b *TextAnnotation) Color() *Color
Color returns the /C array as an RGB Color. Returns nil if /C is absent.
func (*TextAnnotation) Contents ¶
func (b *TextAnnotation) Contents() string
Contents returns /Contents (the annotation body text).
func (*TextAnnotation) Flatten ¶ added in v0.3.0
func (b *TextAnnotation) Flatten() error
Flatten bakes this annotation's normal appearance (/AP/N, honoring the /AS state) into its page's content stream at the annotation's /Rect, then removes the annotation. The annotation handle is dangling afterwards.
An annotation with no normal appearance (e.g. a sticky-note Text annotation, which viewers render as an icon) is simply removed — nothing is drawn.
Mirrors Aspose.PDF for .NET's Annotation.Flatten. For form-field widgets prefer (*Form).Flatten, which also clears the /AcroForm entry.
func (*TextAnnotation) Icon ¶
func (a *TextAnnotation) Icon() TextIcon
Icon returns the /Name value mapped to a TextIcon. Returns TextIconNote (the spec default) if /Name is absent.
func (*TextAnnotation) Open ¶
func (a *TextAnnotation) Open() bool
Open returns the /Open flag (whether the popup is initially shown).
func (*TextAnnotation) PageIndex ¶
func (b *TextAnnotation) PageIndex() int
PageIndex returns the 1-based index of the page this annotation lives on. 0 if the annotation is not yet attached or its /P doesn't resolve.
func (*TextAnnotation) Rect ¶
func (b *TextAnnotation) Rect() Rectangle
Rect returns the annotation rectangle. Empty Rectangle if /Rect is missing or malformed.
func (*TextAnnotation) RegenerateAppearance ¶
func (a *TextAnnotation) RegenerateAppearance()
RegenerateAppearance is a no-op for TextAnnotation (no /AP — viewers render the icon themselves). Present for API symmetry across all annotation types.
func (*TextAnnotation) SetColor ¶
func (b *TextAnnotation) SetColor(c *Color)
SetColor writes /C as an RGB array; nil removes the entry.
func (*TextAnnotation) SetContents ¶
func (b *TextAnnotation) SetContents(s string)
SetContents writes /Contents (the annotation body text); empty string removes the entry.
func (*TextAnnotation) SetIcon ¶
func (a *TextAnnotation) SetIcon(t TextIcon)
SetIcon writes the /Name entry. Unknown is encoded as /Note (default) to avoid producing an empty name.
func (*TextAnnotation) SetOpen ¶
func (a *TextAnnotation) SetOpen(open bool)
SetOpen writes the /Open flag.
func (*TextAnnotation) SetRect ¶
func (b *TextAnnotation) SetRect(r Rectangle)
SetRect writes the annotation rectangle.
type TextBoxField ¶
type TextBoxField struct {
// contains filtered or unexported fields
}
TextBoxField is a single- or multi-line text input.
func (*TextBoxField) Flatten ¶ added in v0.3.0
func (b *TextBoxField) Flatten() error
Flatten bakes this single field's appearance (each of its widgets) into the owning page content and removes the field, leaving every other field and the /AcroForm dict intact. Mirrors Aspose.PDF for .NET's Field.Flatten.
After Flatten the field handle is dangling and must not be used.
func (*TextBoxField) IsMultiline ¶
func (f *TextBoxField) IsMultiline() bool
func (*TextBoxField) IsPassword ¶
func (f *TextBoxField) IsPassword() bool
func (*TextBoxField) IsReadOnly ¶
func (b *TextBoxField) IsReadOnly() bool
func (*TextBoxField) IsRequired ¶
func (b *TextBoxField) IsRequired() bool
func (*TextBoxField) MaxLen ¶
func (f *TextBoxField) MaxLen() int
func (*TextBoxField) PartialName ¶
func (b *TextBoxField) PartialName() string
func (*TextBoxField) SetMaxLen ¶
func (f *TextBoxField) SetMaxLen(n int)
SetMaxLen sets the maximum number of characters. 0 removes the limit.
func (*TextBoxField) SetMultiline ¶
func (f *TextBoxField) SetMultiline(v bool)
func (*TextBoxField) SetPassword ¶
func (f *TextBoxField) SetPassword(v bool)
func (*TextBoxField) SetReadOnly ¶
func (f *TextBoxField) SetReadOnly(v bool)
func (*TextBoxField) SetRequired ¶
func (f *TextBoxField) SetRequired(v bool)
func (*TextBoxField) SetStyle ¶ added in v0.3.0
func (b *TextBoxField) SetStyle(s FieldStyle) error
SetStyle applies s to the field, writing /MK, /BS, /DA, and /Q on the field and its widgets and regenerating each widget's /AP appearance so the new look is visible immediately in every viewer. Returns an error only if the field is detached or a styled font cannot be registered.
func (*TextBoxField) SetValue ¶
func (f *TextBoxField) SetValue(s string) error
func (*TextBoxField) Style ¶ added in v0.3.0
func (b *TextBoxField) Style() FieldStyle
Style reads back the field's current styling from /DA, /Q, /MK, and /BS. Properties never set return their zero/default value. The first widget is used for /MK and /BS.
func (*TextBoxField) Value ¶
func (f *TextBoxField) Value() string
type TextFragment ¶
type TextFragment struct {
Text string
X float64 // horizontal position in points (from left edge)
Y float64 // vertical position in points (from bottom edge)
Width float64 // width in points
FontName string // e.g. "Helvetica", "Arial-BoldMT"
FontSize float64 // effective size in points
Height float64 // text height in points (from ascent/descent metrics)
Bold bool
Italic bool
CharSpacing float64 // character spacing (Tc operator) in text space units
Color Color // fill color
IsSubscript bool // Y is below the line baseline
IsSuperscript bool // Y is above the line baseline
// contains filtered or unexported fields
}
TextFragment represents a contiguous run of text with uniform font.
type TextIcon ¶
type TextIcon int
TextIcon names per ISO 32000-1 §12.5.6.4 Table 172, used in /Subtype /Text annotations' /Name entry.
type TextLine ¶
type TextLine struct {
Text string // concatenated text of all fragments (with spaces)
Y float64 // vertical position in points (from bottom edge)
Fragments []TextFragment
}
TextLine represents a horizontal line of text fragments at a common Y position.
type TextMatch ¶ added in v0.3.0
type TextMatch struct {
Text string // the matched text as it appears on the page
PageNumber int // 1-based page number the match was found on
Rect Rectangle // bounding box of the match in PDF user space (points)
}
TextMatch is a single occurrence located by SearchText.
type TextStyle ¶
type TextStyle struct {
Font Font // nil defaults to FontHelvetica in AddText
Size float64 // in points; 0 treated as 12
Color *Color // nil → black opaque {0,0,0,1}
Background *Color // nil → no background
HAlign HAlign // default: HAlignLeft
VAlign VAlign // default: VAlignTop
LineSpacing float64 // multiplier of font size; 0 treated as 1.2
Underline bool
Strikethrough bool
Rotation float64 // degrees counter-clockwise; pivot = lower-left corner of rect; default 0
Behind bool // if true, text is drawn under existing page content; default false
}
TextStyle defines reusable text formatting properties.
type TiffDevice ¶ added in v0.3.0
type TiffDevice struct {
// contains filtered or unexported fields
}
TiffDevice renders pages to TIFF. Mirrors Aspose.PDF for .NET's TiffDevice: Process writes one page, ProcessDocument writes a whole document as a single multi-page TIFF.
func NewTiffDevice ¶ added in v0.3.0
func NewTiffDevice(res Resolution) *TiffDevice
NewTiffDevice returns a TiffDevice for the given resolution.
func (*TiffDevice) Process ¶ added in v0.3.0
func (d *TiffDevice) Process(page *Page, w io.Writer) error
Process renders page and writes it to w as a single-page TIFF.
func (*TiffDevice) ProcessDocument ¶ added in v0.3.0
func (d *TiffDevice) ProcessDocument(doc *Document, w io.Writer) error
ProcessDocument renders every page of doc into one multi-page TIFF.
type UnderlineAnnotation ¶
type UnderlineAnnotation struct {
// contains filtered or unexported fields
}
UnderlineAnnotation draws a horizontal line under text.
func NewUnderlineAnnotation ¶
func NewUnderlineAnnotation(page *Page, rect Rectangle) *UnderlineAnnotation
NewUnderlineAnnotation builds an unbound underline annotation.
func (*UnderlineAnnotation) AnnotationType ¶
func (a *UnderlineAnnotation) AnnotationType() AnnotationType
func (*UnderlineAnnotation) Color ¶
func (b *UnderlineAnnotation) Color() *Color
Color returns the /C array as an RGB Color. Returns nil if /C is absent.
func (*UnderlineAnnotation) Contents ¶
func (b *UnderlineAnnotation) Contents() string
Contents returns /Contents (the annotation body text).
func (*UnderlineAnnotation) Flatten ¶ added in v0.3.0
func (b *UnderlineAnnotation) Flatten() error
Flatten bakes this annotation's normal appearance (/AP/N, honoring the /AS state) into its page's content stream at the annotation's /Rect, then removes the annotation. The annotation handle is dangling afterwards.
An annotation with no normal appearance (e.g. a sticky-note Text annotation, which viewers render as an icon) is simply removed — nothing is drawn.
Mirrors Aspose.PDF for .NET's Annotation.Flatten. For form-field widgets prefer (*Form).Flatten, which also clears the /AcroForm entry.
func (*UnderlineAnnotation) PageIndex ¶
func (b *UnderlineAnnotation) PageIndex() int
PageIndex returns the 1-based index of the page this annotation lives on. 0 if the annotation is not yet attached or its /P doesn't resolve.
func (*UnderlineAnnotation) QuadPoints ¶
func (a *UnderlineAnnotation) QuadPoints() []QuadPoint
QuadPoints returns the array of quads describing the underlined region. Returns nil if /QuadPoints is absent or its array length is not a multiple of 8 (malformed).
func (*UnderlineAnnotation) Rect ¶
func (b *UnderlineAnnotation) Rect() Rectangle
Rect returns the annotation rectangle. Empty Rectangle if /Rect is missing or malformed.
func (*UnderlineAnnotation) SetColor ¶
func (b *UnderlineAnnotation) SetColor(c *Color)
SetColor writes /C as an RGB array; nil removes the entry.
func (*UnderlineAnnotation) SetContents ¶
func (b *UnderlineAnnotation) SetContents(s string)
SetContents writes /Contents (the annotation body text); empty string removes the entry.
func (*UnderlineAnnotation) SetQuadPoints ¶
func (a *UnderlineAnnotation) SetQuadPoints(qp []QuadPoint)
SetQuadPoints writes /QuadPoints. nil or empty slice removes the entry.
func (*UnderlineAnnotation) SetRect ¶
func (b *UnderlineAnnotation) SetRect(r Rectangle)
SetRect writes the annotation rectangle.
type ValidationIssue ¶
type ValidationIssue struct {
Code string // e.g. "INVALID_HEADER", "XREF_ERROR", "OBJECT_ERROR", "PAGE_TREE_ERROR", "ENCRYPTED"
Message string
}
ValidationIssue describes a single problem found in a PDF file.
type ValidationReport ¶
type ValidationReport struct {
// Valid is true when no issues were found.
Valid bool
Issues []ValidationIssue
}
ValidationReport is returned by Validate and summarises the structural integrity of a PDF.
func Validate ¶
func Validate(inputPath string) (*ValidationReport, error)
Validate checks a PDF file for structural integrity. It verifies the file header, cross-reference table, all indirect objects, and the page tree. Encrypted documents are flagged with an ENCRYPTED issue but are not treated as invalid.
Scope: this is a structural-integrity check (is the file parseable and internally consistent), NOT a standards-conformance check. It does not validate PDF/A or PDF/UA. This differs from Aspose.PDF for .NET's Document.Validate, which checks PDF/A and PDF/UA compliance and writes an XML report; the corresponding capability here is intentionally narrower.
A non-nil error is returned only for I/O failures (file not found, etc.). PDF-level problems are reported inside ValidationReport.Issues.
Example:
report, err := asposepdf.Validate("document.pdf")
if err != nil {
log.Fatal(err)
}
if !report.Valid {
for _, issue := range report.Issues {
fmt.Println(issue.Code, issue.Message)
}
}
Example ¶
Validate the structural integrity of a PDF file.
package main
import (
"fmt"
"log"
pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"
)
func main() {
report, err := pdf.Validate("testdata/4pages.pdf")
if err != nil {
log.Fatal(err)
}
fmt.Println("valid:", report.Valid, "issues:", len(report.Issues))
}
Output: valid: true issues: 0
type WidgetAnnotation ¶
type WidgetAnnotation struct {
// contains filtered or unexported fields
}
WidgetAnnotation is the read-only view of a form widget annotation surfaced through AnnotationCollection. Form fields continue to be mutated via the Form API — a WidgetAnnotation only exposes the base Annotation surface (Rect, Color, Title, Contents, PageIndex).
func (*WidgetAnnotation) AnnotationType ¶
func (a *WidgetAnnotation) AnnotationType() AnnotationType
func (*WidgetAnnotation) Color ¶
func (b *WidgetAnnotation) Color() *Color
Color returns the /C array as an RGB Color. Returns nil if /C is absent.
func (*WidgetAnnotation) Contents ¶
func (b *WidgetAnnotation) Contents() string
Contents returns /Contents (the annotation body text).
func (*WidgetAnnotation) Flatten ¶ added in v0.3.0
func (b *WidgetAnnotation) Flatten() error
Flatten bakes this annotation's normal appearance (/AP/N, honoring the /AS state) into its page's content stream at the annotation's /Rect, then removes the annotation. The annotation handle is dangling afterwards.
An annotation with no normal appearance (e.g. a sticky-note Text annotation, which viewers render as an icon) is simply removed — nothing is drawn.
Mirrors Aspose.PDF for .NET's Annotation.Flatten. For form-field widgets prefer (*Form).Flatten, which also clears the /AcroForm entry.
func (*WidgetAnnotation) PageIndex ¶
func (b *WidgetAnnotation) PageIndex() int
PageIndex returns the 1-based index of the page this annotation lives on. 0 if the annotation is not yet attached or its /P doesn't resolve.
func (*WidgetAnnotation) Rect ¶
func (b *WidgetAnnotation) Rect() Rectangle
Rect returns the annotation rectangle. Empty Rectangle if /Rect is missing or malformed.
func (*WidgetAnnotation) SetColor ¶
func (b *WidgetAnnotation) SetColor(c *Color)
SetColor writes /C as an RGB array; nil removes the entry.
func (*WidgetAnnotation) SetContents ¶
func (b *WidgetAnnotation) SetContents(s string)
SetContents writes /Contents (the annotation body text); empty string removes the entry.
func (*WidgetAnnotation) SetRect ¶
func (b *WidgetAnnotation) SetRect(r Rectangle)
SetRect writes the annotation rectangle.
type XMPMetadata ¶ added in v0.3.0
type XMPMetadata struct {
Title string
Authors []string
Description string
Keywords []string
CreatorTool string
Producer string
CreateDate string
ModifyDate string
MetadataDate string
Custom []XMPProperty
}
XMPMetadata is the document's XMP packet modelled as common schema fields plus a list of arbitrary Custom properties. Empty fields are omitted when written. Dates are ISO 8601 strings (e.g. "2026-05-29T12:00:00Z") to round-trip losslessly.
Field → XMP property mapping:
- Title → dc:title (language alternative, x-default)
- Authors → dc:creator (ordered rdf:Seq)
- Description → dc:description (language alternative, x-default)
- Keywords → dc:subject (unordered rdf:Bag)
- CreatorTool → xmp:CreatorTool
- CreateDate → xmp:CreateDate
- ModifyDate → xmp:ModifyDate
- MetadataDate → xmp:MetadataDate
- Producer → pdf:Producer
func (XMPMetadata) IsEmpty ¶ added in v0.3.0
func (m XMPMetadata) IsEmpty() bool
IsEmpty reports whether the XMP metadata carries no information.
type XMPProperty ¶ added in v0.3.0
type XMPProperty struct {
Namespace string // namespace URI, e.g. "http://ns.adobe.com/xap/1.0/mm/"
Prefix string // namespace prefix used in the serialised packet, e.g. "xmpMM"
Name string // local property name, e.g. "DocumentID"
Value string // property value
}
XMPProperty is a single simple (string-valued) XMP property in an arbitrary namespace. Used for properties outside the common Dublin Core / XMP Basic / PDF schemas modelled directly on XMPMetadata.
Source Files
¶
- annotation.go
- annotation_action.go
- annotation_drawing.go
- annotation_fileattachment.go
- annotation_freetext.go
- annotation_link.go
- annotation_markup.go
- annotation_redact.go
- annotation_stamp.go
- annotation_text.go
- appearance.go
- appearance_builder.go
- appearance_freetext.go
- appearance_redact.go
- appearance_stamp.go
- appearance_widget.go
- bmp.go
- ccitt.go
- ccitt_tables.go
- cff.go
- cmap.go
- cmap_cid.go
- cmap_cid_data.go
- cmyk_lut.go
- color.go
- content_parser.go
- decrypt.go
- decrypt_aes.go
- decrypt_aes256.go
- doc.go
- document.go
- document_new.go
- document_pages.go
- encoding.go
- encrypt.go
- encrypt_aes.go
- encrypt_aes256.go
- flatten.go
- font.go
- font_api.go
- font_embed.go
- font_metrics.go
- font_subset.go
- form.go
- form_button.go
- form_fields.go
- form_style.go
- image.go
- image_add.go
- image_convert.go
- image_decode.go
- image_inline.go
- image_optimize.go
- image_remove.go
- image_replace.go
- io.go
- jbig2.go
- jbig2_generic.go
- jbig2_halftone.go
- jbig2_huffman.go
- jbig2_huffsym.go
- jbig2_hufftext.go
- jbig2_mmr.go
- jbig2_mq.go
- jbig2_refine.go
- jbig2_symbol.go
- jbig2_tables.go
- jbig2_text.go
- jpx.go
- jpx_dwt.go
- jpx_tagtree.go
- jpx_tier1.go
- jpx_tier2.go
- lexer.go
- lzw.go
- metadata.go
- named_destinations.go
- named_destinations_parse.go
- named_destinations_write.go
- outline.go
- outline_destination.go
- outline_parse.go
- outline_write.go
- page.go
- page_labels.go
- page_range.go
- parser.go
- raster.go
- raster_path.go
- raster_stroke.go
- rectangle.go
- redact_apply.go
- redact_apply_image.go
- redact_apply_path.go
- redact_apply_text.go
- render.go
- render_annotations.go
- render_blend.go
- render_clip.go
- render_colorspace.go
- render_device.go
- render_dingbats.go
- render_document.go
- render_fontrepo.go
- render_fontsubset.go
- render_function_ps.go
- render_glyph.go
- render_gstate.go
- render_image.go
- render_imagemask.go
- render_oc.go
- render_shading.go
- render_softmask.go
- render_std14.go
- render_text.go
- render_tiling.go
- render_type3.go
- svg.go
- svg_attrs.go
- svg_clip.go
- svg_css.go
- svg_filter.go
- svg_gradient.go
- svg_image.go
- svg_marker.go
- svg_mask.go
- svg_named_colors.go
- svg_parse.go
- svg_parse_clip.go
- svg_parse_filter.go
- svg_parse_gradient.go
- svg_parse_image.go
- svg_parse_marker.go
- svg_parse_mask.go
- svg_parse_text.go
- svg_parse_use.go
- svg_path.go
- svg_render.go
- svg_render_filter.go
- svg_render_gradient.go
- svg_render_image.go
- svg_render_marker.go
- svg_render_mask.go
- svg_render_text.go
- svg_text.go
- svg_transform.go
- svg_types.go
- svg_use.go
- svg_viewbox.go
- table.go
- table_image.go
- table_render.go
- text.go
- text_add.go
- text_layout.go
- text_search.go
- tiff.go
- ttf.go
- type1.go
- type1_charstring.go
- types.go
- validate.go
- vector.go
- vector_draw.go
- vector_emit.go
- vector_gradient.go
- writer.go
- xmp.go
- xref.go
- xref_reconstruct.go
Directories
¶
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
acroform_build
command
Builds a single-page A4 PDF with a title, a paragraph of body text, and an AcroForm containing one field of each supported type.
|
Builds a single-page A4 PDF with a title, a paragraph of body text, and an AcroForm containing one field of each supported type. |
|
acroform_read
command
Reads every form field from a PDF and emits a JSON dump to stdout.
|
Reads every form field from a PDF and emits a JSON dump to stdout. |
|
blank_with_images
command
|
|
|
embed_font
command
|
|
|
feature_showcase
command
Feature Showcase — a small "annual report"-style document that exercises every major Aspose.PDF for Go feature inside a single narrative.
|
Feature Showcase — a small "annual report"-style document that exercises every major Aspose.PDF for Go feature inside a single narrative. |
|
metadata
command
|
|
|
openall
command
Diagnostic: open every PDF in a folder with the library and report any failures.
|
Diagnostic: open every PDF in a folder with the library and report any failures. |
|
render
command
render rasterizes every page of a PDF to a PNG under result_files/render/, and writes the whole document as one multi-page TIFF (document.tiff).
|
render rasterizes every page of a PDF to a PNG under result_files/render/, and writes the whole document as one multi-page TIFF (document.tiff). |
|
set_password
command
|
|
|
text_extraction
command
|
|
|
textsearch
command
textsearch opens a real PDF, searches it for a query string, and prints the matches (text + page + bounding rectangle) as JSON.
|
textsearch opens a real PDF, searches it for a query string, and prints the matches (text + page + bounding rectangle) as JSON. |
|
visualtest
command
visualtest renders a slice of PDFs from a corpus folder to multi-page TIFFs for eyeballing the renderer's output against a reference viewer (Acrobat).
|
visualtest renders a slice of PDFs from a corpus folder to multi-page TIFFs for eyeballing the renderer's output against a reference viewer (Acrobat). |
