#include <PDFDC.h>
Public Member Functions | |
PDFDC () | |
~PDFDC () | |
HDC | Begin (Page in_page, const Rect in_bbox, bool in_preserveAspectRatio=true) |
void | End () |
void | SetDPI (const TRN_UInt32 dpi=72) |
void | Destroy () |
Note: PDFDC is deprecated. Please use PDFDCEx instead.
PDFDC is a utility class used to represent a PDF Device Context (DC).
Windows developers can use standard GDI or GDI+ API-s to write on PDFDC and to generate PDF documents based on their existing drawing functions. PDFDC can also be used to implement file conversion from any printable file format to PDF.
PDFDC class can be used in many ways to translate from GDI to PDF:
Very few code changes are required to perform the translation from GDI to PDF as PDFDC provides a GDI Device Context handle which can be passed to all GDI function requiring an HDC. PDFDC does not use a "Virtual Printer" approach so the translation should be of both high quality and speed. Unfortunately this also means that StartDoc, EndDoc, StartPage and EndPage cannot be called with an HDC created with PDFDC::Begin.
For more advanced translations or creations of PDF documents, such as security handling, the use of other PDFNet classes will be required.
An example use of PDFDC can be found in PDFDCTest.cpp:
pdftron::PDF::PDFDC::PDFDC | ( | ) |
Default constructor. Creates an empty new GDI to PDF translator.
pdftron::PDF::PDFDC::~PDFDC | ( | ) |
Destructor
HDC pdftron::PDF::PDFDC::Begin | ( | Page | in_page, |
const Rect | in_bbox, | ||
bool | in_preserveAspectRatio = true |
||
) |
Begin the process of translating GDI drawing into a PDF, starting with the creation of a GDI Device Context.
in_page | the page which will hold the converted GDI drawing. |
in_bbox | the location where the PDF objects will be placed on in_page |
in_preserveAspectRatio | if true the aspect ratio of the GDI primitives will be preserved and the PDF objects will be centered within in_box. |
If you wish to create a reusable FormX Object from the transformed page, create the page with the aspect ratio of the GDI drawing.
void pdftron::PDF::PDFDC::Destroy | ( | ) |
Frees the native memory of the object.
void pdftron::PDF::PDFDC::End | ( | ) |
Closes the GDI Device Context, translating the GDI instruction to PDF, and adds the PDF objects to the page in the location specified by PDFDC::Begin( page, box, ...).
An | exception is thrown if there are any fatal errors in the the translation process. |
void pdftron::PDF::PDFDC::SetDPI | ( | const TRN_UInt32 | dpi = 72 | ) |
Sets the conversion scale for translating between GDI drawing and PDF objects.
DPI stands for Dots Per Inch. This parameter is used to specify the output image size and quality. A typical screen resolution for monitors these days is 92 DPI, but printers could use 200 DPI or more. In the case of GDI to PDF translation, this method fixes the scale or allows it to adjust to each GDI drawing between a Begin/End pair. Set the conversion DPI
dpi | The resolution used to handle device dependent features in GDI (such as bitmap patterns, raster ops, etc). Please note that this parameter does not affect the size the PDF nor does it affect the resolution of embedded images. |