HomeUniDoc
HomeUniDoc
...

Package pdfutil

Overview ▾

Index ▾

Package files

page.go

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.