HomeUniDoc
...

Package convert

Overview ▾

Constants

EnumeratedValues for the DefaultPageSize.

const (
    A4 int = iota
    Letter
)

func ConvertToPdf

func ConvertToPdf(d *document.Document) *creator.Creator

ConvertToPdf converts document to PDF file. This package is beta, breaking changes can take place.

func ConvertToPdfWithOptions

func ConvertToPdfWithOptions(d *document.Document, opts *Options) *creator.Creator

ConvertToPdfWithOptions convert the document to PDF with file given options.

func RegisterFont

func RegisterFont(name string, style FontStyle, font *model.PdfFont)

RegisterFont makes a PdfFont accessible for using in converting to PDF.

func RegisterFontsFromDirectory

func RegisterFontsFromDirectory(dirName string) error

RegisterFontsFromDirectory registers all fonts from the given directory automatically detecting font families and styles. For composite fonts use RegisterCompositeFontsFromDirectory.

type FontStyle

FontStyle represents a kind of font styling. It can be FontStyle_Regular, FontStyle_Bold, FontStyle_Italic and FontStyle_BoldItalic.

type FontStyle = convertutils.FontStyle
const (
    FontStyle_Regular    FontStyle = 0
    FontStyle_Bold       FontStyle = 1
    FontStyle_Italic     FontStyle = 2
    FontStyle_BoldItalic FontStyle = 3
)

type Options

Options contains the options for convert process - e.g ProcessFields is when document contains fields and the value need to be processed also.

type Options struct {
    // ProcessFields process the document fields if set to true, default is `false`.
    ProcessFields bool

    // EnableFontSubsetting process document with subsetting font to reduce size result.
    // Default value is `true`.
    EnableFontSubsetting bool

    // FontFiles location of fonts for convert process.
    FontFiles []string

    // FontDirectory location of font directory for convert process.
    // This will load all font files inside directory if set
    // we recommend to use FontFiles for better performance.
    FontDirectory string

    // DefaultPageSize is applied when there is no page size explicitly set in the document.
    // It can be A4 or Letter, A4 is the default option.
    DefaultPageSize int

    // DefaultFontSize is applied when there is no font size explicitly set in the document
    // Possible values compatible with MS Word are 11 or 12, by default it is 12.
    DefaultFontSize int
}