pdfmm 0.9.20
Public Member Functions | Static Public Member Functions | List of all members
mm::PdfPage Class Referencefinal

#include <PdfPage.h>

Inheritance diagram for mm::PdfPage:
mm::PdfCanvas

Public Member Functions

 PdfPage (PdfDocument &parent, const PdfRect &size)
 
 PdfPage (PdfObject &obj, const std::deque< PdfObject * > &listOfParents)
 
PdfRect GetRect () const override
 
bool HasRotation (double &teta) const override
 
bool SetPageWidth (int newWidth)
 
bool SetPageHeight (int newHeight)
 
void SetMediaBox (const PdfRect &size)
 
void SetTrimBox (const PdfRect &size)
 
unsigned GetPageNumber () const
 
PdfRect GetMediaBox () const
 
PdfRect GetCropBox () const
 
PdfRect GetTrimBox () const
 
PdfRect GetBleedBox () const
 
PdfRect GetArtBox () const
 
int GetRotationRaw () const
 
void SetRotationRaw (int rotation)
 
unsigned GetAnnotationCount () const
 
PdfAnnotationCreateAnnotation (PdfAnnotationType annotType, const PdfRect &rect)
 
PdfAnnotationGetAnnotation (unsigned index)
 
void DeleteAnnotation (unsigned index)
 
PdfObjectGetFromResources (const PdfName &type, const PdfName &key)
 
void DeleteAnnotation (PdfObject &annotObj)
 
const PdfObjectGetInheritedKey (const PdfName &name) const
 
void SetICCProfile (const std::string_view &csTag, PdfInputStream &stream, int64_t colorComponents, PdfColorSpace alternateColorSpace=PdfColorSpace::DeviceRGB)
 
- Public Member Functions inherited from mm::PdfCanvas
virtual ~PdfCanvas ()
 
virtual PdfObjectGetOrCreateContentsObject ()=0
 
virtual PdfStreamGetStreamForAppending (PdfStreamAppendFlags flags)=0
 
virtual PdfResourcesGetOrCreateResources ()=0
 
virtual PdfRect GetRect () const =0
 
virtual bool HasRotation (double &teta) const =0
 
void AddColorResource (const PdfColor &color)
 
void AddResource (const PdfName &identifier, const PdfReference &ref, const PdfName &name)
 

Static Public Member Functions

static PdfRect CreateStandardPageSize (const PdfPageSize pageSize, bool landscape=false)
 
- Static Public Member Functions inherited from mm::PdfCanvas
static PdfArray GetProcSet ()
 

Detailed Description

PdfPage is one page in the pdf document. It is possible to draw on a page using a PdfPainter object. Every document needs at least one page.

Constructor & Destructor Documentation

◆ PdfPage() [1/2]

PdfPage::PdfPage ( PdfDocument parent,
const PdfRect size 
)

Create a new PdfPage object.

Parameters
sizea PdfRect specifying the size of the page (i.e the /MediaBox key) in PDF units
parentadd the page to this parent

◆ PdfPage() [2/2]

mm::PdfPage::PdfPage ( PdfObject obj,
const std::deque< PdfObject * > &  listOfParents 
)

Create a PdfPage based on an existing PdfObject

Parameters
objan existing PdfObject
listOfParentsa list of PdfObjects that are parents of this page and can be queried for inherited attributes. The last object in the list is the most direct parent of this page.

Member Function Documentation

◆ CreateAnnotation()

PdfAnnotation * PdfPage::CreateAnnotation ( PdfAnnotationType  annotType,
const PdfRect rect 
)

Create a new annotation to this page.

Parameters
annotTypethe type of the annotation
rectrectangle of the annotation on the page
Returns
the annotation object which is owned by the PdfPage

◆ CreateStandardPageSize()

PdfRect PdfPage::CreateStandardPageSize ( const PdfPageSize  pageSize,
bool  landscape = false 
)
static

Creates a PdfRect with the page size as values which is needed to create a PdfPage object from an enum which are defined for a few standard page sizes.

Parameters
pageSizethe page size you want
landscapecreate a landscape pagesize instead of portrait (by exchanging width and height)
Returns
a PdfRect object which can be passed to the PdfPage constructor

◆ DeleteAnnotation() [1/2]

void PdfPage::DeleteAnnotation ( PdfObject annotObj)

Delete the annotation with the given object

Parameters
annotObjthe object of an annotation
See also
GetAnnotationCount

◆ DeleteAnnotation() [2/2]

void PdfPage::DeleteAnnotation ( unsigned  index)

Delete the annotation with index index from this page.

Parameters
indexthe index of the annotation to delete
See also
GetAnnotationCount

◆ GetAnnotation()

PdfAnnotation * PdfPage::GetAnnotation ( unsigned  index)

Get the annotation with index index of the current page.

Parameters
indexthe index of the annotation to retrieve
Returns
a annotation object. The annotation object is owned by the PdfPage.
See also
GetAnnotationCount

◆ GetAnnotationCount()

unsigned PdfPage::GetAnnotationCount ( ) const

Get the number of annotations associated with this page \ returns int number of annotations

◆ GetArtBox()

PdfRect PdfPage::GetArtBox ( ) const

Get the current ArtBox in PDF units.

Returns
PdfRect the page box

◆ GetBleedBox()

PdfRect PdfPage::GetBleedBox ( ) const

Get the current BleedBox (extra area for printing purposes) in PDF units.

Returns
PdfRect the page box

◆ GetCropBox()

PdfRect PdfPage::GetCropBox ( ) const

Get the current CropBox (visible page size) in PDF units.

Returns
PdfRect the page box

◆ GetFromResources()

PdfObject * PdfPage::GetFromResources ( const PdfName type,
const PdfName key 
)

Get an element from the pages resources dictionary, using a type (category) and a key.

Parameters
typethe type of resource to fetch (e.g. /Font, or /XObject)
keythe key of the resource
Returns
the object of the resource or nullptr if it was not found

◆ GetInheritedKey()

const PdfObject * PdfPage::GetInheritedKey ( const PdfName name) const

Method for getting a value that can be inherited Possible names that can be inherited according to the PDF specification are: Resources, MediaBox, CropBox and Rotate

Returns
PdfObject - the result of the key fetching or nullptr

◆ GetMediaBox()

PdfRect PdfPage::GetMediaBox ( ) const

Get the current MediaBox (physical page size) in PDF units.

Returns
PdfRect the page box

◆ GetPageNumber()

unsigned PdfPage::GetPageNumber ( ) const

Page number inside of the document. The first page has the number 1, the last page has the number PdfPageTree:GetTotalNumberOfPages()

Returns
the number of the page inside of the document
See also
PdfPageTree:GetTotalNumberOfPages()

◆ GetRect()

PdfRect PdfPage::GetRect ( ) const
overridevirtual

Get the current canvas size in PDF Units

Returns
a PdfRect containing the page size available for drawing

Implements mm::PdfCanvas.

◆ GetRotationRaw()

int PdfPage::GetRotationRaw ( ) const

Get the current page rotation (if any), it's a clockwise rotation

Returns
int 0, 90, 180 or 270

◆ GetTrimBox()

PdfRect PdfPage::GetTrimBox ( ) const

Get the current TrimBox (cut area) in PDF units.

Returns
PdfRect the page box

◆ HasRotation()

bool PdfPage::HasRotation ( double &  teta) const
overridevirtual

Get the current canvas rotation

Parameters
tetacounterclockwise rotation in radians
Returns
true if the canvas has a rotation

Implements mm::PdfCanvas.

◆ SetICCProfile()

void PdfPage::SetICCProfile ( const std::string_view &  csTag,
PdfInputStream stream,
int64_t  colorComponents,
PdfColorSpace  alternateColorSpace = PdfColorSpace::DeviceRGB 
)

Set an ICC profile for this page

Parameters
csTaga ColorSpace tag
streaman input stream from which the ICC profiles data can be read
colorComponentsthe number of colorcomponents of the ICC profile (expected is 1, 3 or 4 components)
alternateColorSpacean alternate colorspace to use if the ICC profile cannot be used
See also
PdfPainter::SetDependICCProfileColor()

◆ SetMediaBox()

void PdfPage::SetMediaBox ( const PdfRect size)

Set the mediabox in PDF Units

Parameters
sizea PdfRect specifying the mediabox of the page (i.e the /TrimBox key) in PDF units

◆ SetPageHeight()

bool PdfPage::SetPageHeight ( int  newHeight)

Set the current page height in PDF Units

Returns
true if successful, false otherwise

◆ SetPageWidth()

bool PdfPage::SetPageWidth ( int  newWidth)

Set the current page width in PDF Units

Returns
true if successful, false otherwise

◆ SetRotationRaw()

void PdfPage::SetRotationRaw ( int  rotation)

Set the current page rotation.

Parameters
iRotationRotation to set to the page. Valid value are 0, 90, 180, 270.

◆ SetTrimBox()

void PdfPage::SetTrimBox ( const PdfRect size)

Set the trimbox in PDF Units

Parameters
sizea PdfRect specifying the trimbox of the page (i.e the /TrimBox key) in PDF units