Class: PDFDC


new PDFDC()

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: - To translate a single GDI drawing into a single page PDF document. - To translate a single GDI drawing into an object which can be reused many times throughout a PDF document (i.e. as a Form XObject). - To translate many GDI drawings into single page or multipage PDF document. ... 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:
// Start with a PDFDoc to put the picture into, and a PDFDC to translate GDI to PDF
PDFDoc pdfdoc;
PDFDC pdfDc;

// Create a page to put the GDI content onto
Page page = pdfdoc.PageCreate();

// Begin the translation from GDI to PDF.
// Provide the page to place the picture onto, and the bounding box for the content.
// We're going to scale the GDI content to fill the page while preserving the aspect
// ratio.
// Get back a GDI Device Context
HDC hDC = pdfDc.Begin( page, page.GetCropBox() );

... perform GDI drawing ...

// Complete the translation

// Add the page to the document

// Save the PDF document
pdfdoc.Save("PDFDC_is_cool.pdf", SDF::SDFDoc::e_remove_unused, NULL);