wxMaxima
Loading...
Searching...
No Matches
Public Member Functions
wxPdfDC Class Reference

Class representing a PDF drawing context. More...

#include <pdfdc.h>

Inheritance diagram for wxPdfDC:
[legend]
Collaboration diagram for wxPdfDC:
[legend]

Public Member Functions

 wxPdfDC ()
 Default constructor.
 
 wxPdfDC (const wxPrintData &printData)
 Constructor initializing the DC with print data.
 
 wxPdfDC (wxPdfDocument *pdfDocument, double templateWidth, double templateHeight)
 Constructor for creating a template in an existing PDF document.
 
wxPdfDocument * GetPdfDocument ()
 Returns the associated PDF document.
 
void SetResolution (int ppi)
 Sets the resolution for the DC.
 
int GetResolution () const
 Returns the current resolution.
 
void SetFontResolution (int ppi)
 Sets the resolution font sizes are interpreted at.
 
int GetFontResolution () const
 Returns the resolution font sizes are interpreted at.
 
void SetImageType (wxBitmapType bitmapType, int quality=75)
 Sets the image type and quality for bitmap output.
 
void SetMapModeStyle (wxPdfMapModeStyle style)
 Sets the map mode style.
 
wxPdfMapModeStyle GetMapModeStyle () const
 Returns the current map mode style.
 

Detailed Description

Class representing a PDF drawing context.

Constructor & Destructor Documentation

◆ wxPdfDC() [1/2]

wxPdfDC::wxPdfDC ( const wxPrintData &  printData)

Constructor initializing the DC with print data.

Parameters
printDataPrinter configuration data
Example
wxPrintData printData;
printData.SetOrientation(wxPORTRAIT);
printData.SetPaperId(wxPAPER_A4);
printData.SetFilename(wxS("output.pdf"));
wxPdfDC dc(printData);
dc.SetMapModeStyle(wxPDF_MAPMODESTYLE_PDF);
dc.SetMapMode(wxMM_POINTS);
if (dc.StartDoc(_("Printing...")))
{
dc.StartPage();
dc.DrawText(wxS("Hello, PDF!"), 10, 10);
dc.EndPage();
dc.EndDoc();
}
Class representing a PDF drawing context.
Definition: pdfdc.h:47
@ wxPDF_MAPMODESTYLE_PDF
same font sizes and text position as with the wxPdfDocument API
Definition: pdfdc.h:40

◆ wxPdfDC() [2/2]

wxPdfDC::wxPdfDC ( wxPdfDocument *  pdfDocument,
double  templateWidth,
double  templateHeight 
)

Constructor for creating a template in an existing PDF document.

Parameters
pdfDocumentAssociated PDF document
templateWidthWidth of the template in user units
templateHeightHeight of the template in user units
Example
pdf.AddPage();
double w = 125, h = 125;
int tpl = pdf.BeginTemplate(0, 0, w, h);
{
wxPdfDC dc(&pdf, w, h);
if (dc.StartDoc(_("Printing...")))
{
dc.StartPage();
dc.DrawRectangle(10, 10, 100, 50);
dc.EndPage();
dc.EndDoc();
}
}
pdf.UseTemplate(tpl, 40, 30, 75);
pdf.SaveAsFile(wxS("output.pdf"));
Class representing a PDF document.
Definition: pdfdocument.h:176
virtual void UseTemplate(int templateId)
Uses a template in current page or in another template.
Definition: pdftemplate.cpp:146
virtual bool SaveAsFile(const wxString &name=wxEmptyString)
Saves the document to a file on disk.
Definition: pdfdocument.cpp:2233
virtual int EndTemplate()
Terminates a template.
Definition: pdftemplate.cpp:119
virtual int BeginTemplate(double x=0, double y=0, double width=0, double height=0)
Starts a new Template.
Definition: pdftemplate.cpp:63
virtual void AddPage(int orientation=-1, bool useDefaultPageSize=true)
Adds a new page to the document.
Definition: pdfdocument.cpp:686
See also
wxPdfDocument::BeginTemplate(), wxPdfDocument::EndTemplate(), wxPdfDocument::UseTemplate()

Member Function Documentation

◆ GetFontResolution()

int wxPdfDC::GetFontResolution ( ) const

Returns the resolution font sizes are interpreted at.

eturn Resolution in pixels per inch

See also
SetFontResolution()

◆ GetMapModeStyle()

wxPdfMapModeStyle wxPdfDC::GetMapModeStyle ( ) const

Returns the current map mode style.

Returns
The current map mode style
See also
SetMapModeStyle()

◆ GetPdfDocument()

wxPdfDocument * wxPdfDC::GetPdfDocument ( )

Returns the associated PDF document.

Returns
Pointer to the PDF document

◆ GetResolution()

int wxPdfDC::GetResolution ( ) const

Returns the current resolution.

Returns
Resolution in pixels per inch
See also
SetResolution()

◆ SetFontResolution()

void wxPdfDC::SetFontResolution ( int  ppi)

Sets the resolution font sizes are interpreted at.

A wxFont's point size is turned into the size of the PDF font the way a screen DC would draw it: as if the DC had the resolution of the screen (wxDisplay::GetPPI(), 72 on macOS). That makes text drawn with wxPdfDC look as large, relative to the rest of the drawing, as it does in a window – but it also makes the PDF depend on the screen of the computer that created it: the same code writes larger text on a 120 dpi screen than on a 96 dpi one, and smaller text on a Mac.

Applications that lay out their drawing for a fixed resolution can make the output reproducible by setting it here; text measurement (GetTextExtent()) uses the same value, so the layout stays consistent.

Parameters
ppiResolution in pixels per inch that font sizes are meant for, for example 96 (the reference resolution of Windows and GTK) or 72 (so that a font of n points is drawn n points high if the DC's resolution is 72 as well). Values <= 0 restore the screen's.
See also
GetFontResolution(), SetResolution()

◆ SetImageType()

void wxPdfDC::SetImageType ( wxBitmapType  bitmapType,
int  quality = 75 
)

Sets the image type and quality for bitmap output.

Parameters
bitmapTypeThe type of the bitmap (e.g., wxBITMAP_TYPE_JPEG)
qualityCompression quality from 0 to 100

◆ SetMapModeStyle()

void wxPdfDC::SetMapModeStyle ( wxPdfMapModeStyle  style)

Sets the map mode style.

Map mode style determines how logical coordinates and font sizes are scaled to the PDF page, allowing emulation of platform-specific behaviors or native PDF API scaling.

Parameters
styleThe map mode style to apply
See also
GetMapModeStyle()

◆ SetResolution()

void wxPdfDC::SetResolution ( int  ppi)

Sets the resolution for the DC.

Parameters
ppiResolution in pixels per inch
See also
GetResolution()

The documentation for this class was generated from the following files: