wxPdfDocument  1.4.0
Library for generating PDF documents from wxWidgets applications
Loading...
Searching...
No Matches
wxPdfDC Class Reference

Class representing a PDF drawing context. More...

#include <pdfdc.h>

Inheritance diagram for wxPdfDC:

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.
wxPdfDocumentGetPdfDocument ()
 Returns the associated PDF document.
void SetResolution (int ppi)
 Sets the resolution for the DC.
int GetResolution () const
 Returns the current resolution.
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/3]

wxPdfDC::wxPdfDC ( )

Default constructor.

◆ wxPdfDC() [2/3]

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();
}
wxPdfDC()
Default constructor.
@ wxPDF_MAPMODESTYLE_PDF
same font sizes and text position as with the wxPdfDocument API
Definition pdfdc.h:31

◆ wxPdfDC() [3/3]

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:151
virtual void AddPage(int orientation=-1, bool useDefaultPageSize=true)
Adds a new page to the document.
virtual int BeginTemplate(double x=0, double y=0, double width=0, double height=0)
Starts a new Template.
virtual void UseTemplate(int templateId)
Uses a template in current page or in another template.
virtual int EndTemplate()
Terminates a template.
virtual bool SaveAsFile(const wxString &name=wxEmptyString)
Saves the document to a file on disk.
See also
wxPdfDocument::BeginTemplate(), wxPdfDocument::EndTemplate(), wxPdfDocument::UseTemplate()

Member Function Documentation

◆ 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()

◆ 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 file:
  • E:/github/wxpdfdoc-current/include/wx/pdfdc.h