qpdf

package
v0.0.0-...-828eff7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package qpdf provides simple Go bindings for qpdf C / C++ API. Due to the limitations of the C API, it is only capable of doing basic transformations on PDF files; mostly linearization. Refer to examples/ for usage information. For more information: https://github.com/qpdf/qpdf/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version is an implementation of qpdf_get_qpdf_version. It returns the current version of the qpdf software / library as a string.

Types

type QPDF

type QPDF struct {
	// contains filtered or unexported fields
}

QPDF contains the qpdf_data object. It should never initialised manually (i.e. new(QPDF) or QPDF{}). It should be initialised using the Init method.

func Init

func Init() *QPDF

Init is an implementation of qpdf_init. It returns a QPDF object containing an initialised qpdf_data pointer. This method must be called before any other QPDF operations.

func (*QPDF) GC

func (q *QPDF) GC()

GC is an implementation of qpdf_cleanup. All dynamic memory - except the qpdf_data object - is managed by the qpdf library. This method may be used to free up the dynamically allocated qpdf_data pointer. After calling this method, any pointers to the qpdf_data object will no longer be valid.

func (*QPDF) HasError

func (q *QPDF) HasError() bool

HasError is an implementation of qpdf_has_error. It checks if there are any outstanding / unhandled errors in qpdf_data, and if so, it will return true.

func (*QPDF) LastError

func (q *QPDF) LastError() error

LastError is an implementation of qpdf_get_error, and qpdf_get_error_full_text. It attempts to get the last error condition, and if there is an error, it will pass the condition to qpdf_get_error_full_text to retrieve the full / user-friendly error message from the qpdf library. Upon calling this method, HasError will return false until the next error condition occurs (i.e. it drains the errors).

func (*QPDF) Linearize

func (q *QPDF) Linearize()

Linearize is an implementation of qpdf_set_linearization. It does not actually linearize the qpdf_data object immediately. Instead, enables linearization mode. The actual transformation occurs during qpdf_write.

func (*QPDF) Open

func (q *QPDF) Open(fn string) error

Open is an implementation of qpdf_read. It reads, and parses the source PDF file into qpdf_data. Methods to manipulate the data can be called after the file is opened with this method.

func (*QPDF) SetOutput

func (q *QPDF) SetOutput(fn string) error

SetOutput is an implementation of qpdf_init_write. It initialises qpdf_data for write operations, and it prepares the target file for PDF data to be written.

func (*QPDF) Write

func (q *QPDF) Write() error

Write is an implementation of qpdf_write. It carries out the actual write operation using data from the qpdf_data object. The output is written to the target file defined in SetOutput, assuming no errors occured.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL