HomeUniDoc
...

Package pdfutil

Overview ▾

func ConvertPageToGrayscale

func ConvertPageToGrayscale(page *model.PdfPage) error

ConvertPageToGrayscale() replaces color objects on the page with grayscale ones. Also references XObject Images and Forms to convert those to grayscale.

func ExtractPageRange

func ExtractPageRange(inputPath string, outputPath string, pageFrom int, pageTo int, keepOptionalContent bool) error

ExtractPageRange extracts a range of pages from inputPath PDF file and saves it as outputPath PDF file. keepOptionalContent controls if we need to process OC properties (rarely needed).

func MergePdf

func MergePdf(inputPaths []string, outputPath string, isMergingForms bool) error

MergePdf merges several PDF files passed as inputPaths to one PDF file, outputPath. isMergingForms controls if it is necessary to merge AcroForms from input files. If you are not sure, you can always set isMergingForms to true.

func NormalizePage

func NormalizePage(page *model.PdfPage) error

NormalizePage performs the following operations on the passed in page:

- Normalize the page rotation.
  Rotates the contents of the page according to the Rotate entry, thus
  flattening the rotation. The Rotate entry of the page is set to nil.
- Normalize the media box.
  If the media box of the page is offsetted (Llx != 0 or Lly != 0),
  the contents of the page are translated to (-Llx, -Lly). After
  normalization, the media box is updated (Llx and Lly are set to 0 and
  Urx and Ury are updated accordingly).
- Normalize the crop box.
  The crop box of the page is updated based on the previous operations.

After normalization, the page should look the same if openend using a PDF viewer. NOTE: This function does not normalize annotations, outlines other parts that are not part of the basic geometry and page content streams.