Documentation
¶
Overview ¶
nolint
Index ¶
- func GetDescenderToBaselineFromTTF(ctx context.Context, ttfPath string, fontSize float64) (float64, error)
- func PageCount(ctx context.Context, rawPayload io.Reader) (_ int, err error)
- func SaveToHTML(ctx context.Context, page, width uint16, scale float32, dpi int, ...) (err error)
- func SaveToPNG(ctx context.Context, page, width uint16, scale float32, dpi int, ...) (err error)
- type CheckboxParams
- type ImageParams
- type Location
- type PageSize
- type PdfDocument
- type PdfHandler
- func (p *PdfHandler) AddCheckboxToPage(document *PdfDocument, params CheckboxParams) (err error)
- func (p *PdfHandler) AddImageToPage(document *PdfDocument, params ImageParams) (err error)
- func (p *PdfHandler) AddTextBoxToPage(document *PdfDocument, params TextParams) (err error)
- func (p *PdfHandler) CheckPDFDocMdpP1(document *PdfDocument) (hasDocMdpP1 bool, err error)
- func (p *PdfHandler) CheckPDFPassword(document *PdfDocument) (needsPassword bool, err error)
- func (p *PdfHandler) CheckPDFRestrictions(document *PdfDocument) (isRestricted bool, err error)
- func (p *PdfHandler) ClosePDF(document *PdfDocument) (err error)
- func (p *PdfHandler) ConvertTopLeftToBottomLeft(ctx context.Context, document *PdfDocument, page int, x, y, height float64) (float64, float64, error)
- func (p *PdfHandler) GetPageSize(document *PdfDocument, page int) (pageSize PageSize, err error)
- func (p *PdfHandler) GetPageSizeWithContext(ctx context.Context, document *PdfDocument, page int) (pageSize PageSize, err error)
- func (p *PdfHandler) OpenPDF(rawPayload io.Reader) (document *PdfDocument, err error)
- func (p *PdfHandler) SavePDF(document *PdfDocument, filePath string) (err error)
- func (p *PdfHandler) SaveToPNG(document *PdfDocument, page, width uint16, scale float32, dpi int, ...) (err error)
- type Size
- type TextParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveToHTML ¶
func SaveToPNG ¶
func SaveToPNG( ctx context.Context, page, width uint16, scale float32, dpi int, rawPayload io.Reader, output io.Writer, ) (err error)
SaveToPNG is used to convert a page from a PDF file to PNG. Internally everything is based on the scale factor and this value is used to determine the actual output size based on the original size of the page. If none is set we'll use a default scale factor of 1.5. When using the default value, 1.5, there is a special case when we detect that the page is a landscape and it has a 0 or 180 degree rotation, on those cases we set the scale factor of 1. If width is set then we'll calculate the scale factor by dividing the width by the page horizontal size. If both width and scale are set we'll use only the scale as it takes precedence.
Types ¶
type CheckboxParams ¶
type CheckboxParams struct {
Value bool
Page int
// Specify location in PDF points (1 point = 1/72 inch):
// (0,0) represents the upper-left corner.
// (pageWidth, pageHeight) represents the bottom-right corner.
Location Location
// Specify size in PDF points (1 point = 1/72 inch):
// 0 represents zero size.
// pageWidth/pageHeight represents the full page width or height
Size Size
}
type ImageParams ¶
type ImageParams struct {
Page int
// Specify location in PDF points (1 point = 1/72 inch):
// (0,0) represents the upper-left corner.
// (pageWidth, pageHeight) represents the bottom-right corner.
Location Location
// Specify size in PDF points (1 point = 1/72 inch):
// 0 represents zero size.
// pageWidth/pageHeight represents the full page width or height
Size Size
ImagePath string
}
type PdfDocument ¶
type PdfDocument struct {
// contains filtered or unexported fields
}
type PdfHandler ¶
func NewPdfHandler ¶
func NewPdfHandler(ctx context.Context, logger *slog.Logger) *PdfHandler
NewPdfHandler creates a new PdfHandler with the given context and logger
func NewPdfHandlerWithLogger ¶
func NewPdfHandlerWithLogger(logger *slog.Logger) *PdfHandler
NewPdfHandlerWithLogger creates a new PdfHandler with background context and the given logger Deprecated: Use NewPdfHandler instead
func (*PdfHandler) AddCheckboxToPage ¶
func (p *PdfHandler) AddCheckboxToPage(document *PdfDocument, params CheckboxParams) (err error)
func (*PdfHandler) AddImageToPage ¶
func (p *PdfHandler) AddImageToPage(document *PdfDocument, params ImageParams) (err error)
func (*PdfHandler) AddTextBoxToPage ¶
func (p *PdfHandler) AddTextBoxToPage(document *PdfDocument, params TextParams) (err error)
func (*PdfHandler) CheckPDFDocMdpP1 ¶
func (p *PdfHandler) CheckPDFDocMdpP1(document *PdfDocument) (hasDocMdpP1 bool, err error)
CheckPDFDocMdpP1 checks if a document has a DocMDP signature with P=1 (no changes allowed). DocMDP (Document Modification Detection and Prevention) P1 means the document is certified and no modifications are permitted. Any attempt to modify such a document should be rejected.
func (*PdfHandler) CheckPDFPassword ¶
func (p *PdfHandler) CheckPDFPassword(document *PdfDocument) (needsPassword bool, err error)
func (*PdfHandler) CheckPDFRestrictions ¶
func (p *PdfHandler) CheckPDFRestrictions(document *PdfDocument) (isRestricted bool, err error)
func (*PdfHandler) ClosePDF ¶
func (p *PdfHandler) ClosePDF(document *PdfDocument) (err error)
func (*PdfHandler) ConvertTopLeftToBottomLeft ¶
func (p *PdfHandler) ConvertTopLeftToBottomLeft(ctx context.Context, document *PdfDocument, page int, x, y, height float64) (float64, float64, error)
ConvertTopLeftToBottomLeft converts PDF point coordinates from top-left origin to bottom-left origin PDF coordinate system uses bottom-left as origin, but user input uses top-left as origin
func (*PdfHandler) GetPageSize ¶
func (p *PdfHandler) GetPageSize(document *PdfDocument, page int) (pageSize PageSize, err error)
func (*PdfHandler) GetPageSizeWithContext ¶
func (p *PdfHandler) GetPageSizeWithContext(ctx context.Context, document *PdfDocument, page int) (pageSize PageSize, err error)
func (*PdfHandler) OpenPDF ¶
func (p *PdfHandler) OpenPDF(rawPayload io.Reader) (document *PdfDocument, err error)
func (*PdfHandler) SavePDF ¶
func (p *PdfHandler) SavePDF(document *PdfDocument, filePath string) (err error)
func (*PdfHandler) SaveToPNG ¶
func (p *PdfHandler) SaveToPNG(document *PdfDocument, page, width uint16, scale float32, dpi int, output io.Writer) (err error)
type TextParams ¶
type TextParams struct {
Value string
Page int
// Specify location in PDF points (1 point = 1/72 inch):
// (0,0) represents the upper-left corner.
// (pageWidth, pageHeight) represents the bottom-right corner.
Location Location
// Set the text bounding box size in PDF points (1 point = 1/72 inch):
// 0 represents zero size.
// pageWidth/pageHeight represents the full page width or height
Size Size
Font struct {
Family string
Size float64 // In "Point" where 1 point = 1/72 inch
}
}