Show / Hide Table of Contents

Class PDFDCEX

PDFDCEX 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 PDFDCEX and to generate PDF documents based on their existing drawing functions. PDFDCEX can also be used to implement file conversion from any printable file format to PDF. PDFDCEX 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 PDFDCEX provides a GDI Device Context handle which can be passed to all GDI function requiring an HDC. PDFDCEX does use a "Virtual Printer" approach so the translation should be of both high quality and speed. 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 PDFDCEX can be found in PDFDCTest.cpp:
// Start with a PDFDoc to put the picture into, and a PDFDCEX to translate GDI to PDF
PDFDoc pdfdoc;
PDFDCEX pdfdcex;
// Begin the translation from GDI to PDF, provide the PDFDoc to append the translated
// GDI drawing to and get back a GDI Device Context
HDC hDC = pdfdcex.Begin(pdfdoc);
 ::StartPage(hDC);
// ... perform GDI drawing ...
//::EndPage(hDC);
 // Complete the translation
 pdfdcex.EndDoc();
 // Save the PDF document
pdfdoc.Save("PDFDCEX_is_cool.pdf", SDF.SDFDoc.SaveOptions.e_remove_unused, NULL);
Inheritance
object
PDFDCEX
Implements
IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: pdftron.PDF
Assembly: PDFNet.dll
Syntax
public class PDFDCEX : IDisposable

Constructors

PDFDCEX()

Default constructor.Creates an empty new GDI to PDF translator.

Declaration
public PDFDCEX()

Methods

Begin(PDFDoc)

Begin the process of translating GDI drawing into a PDF, starting with the creation of a GDI Device Context.

The following is a listing of some standard U.S. page sizes: in inches

  • Letter = Rect(8.5, 11)
  • Legal = Rect(8.5, 14)
  • Ledger = Rect(17, 11)
  • Tabloid = Rect(11, 17)
  • Executive = Rect(7.25, 10.5)

The following is a listing of ISO standard page sizes: in 1/72 inch scale

  • 4A0 = Rect(4768, 6741)
  • 2A0 = Rect(3370, 4768)
  • A0 = Rect(2384, 3370)
  • A1 = Rect(1684, 2384)
  • A2 = Rect(1191, 1684)
  • A3 = Rect(842, 1191)
  • A4 = Rect(595, 842)
  • A5 = Rect(420, 595)
  • A6 = Rect(298, 420)
  • A7 = Rect(210, 298)
  • A8 = Rect(147, 210)
  • A9 = Rect(105, 147)
  • A10 = Rect(74, 105)
  • B0 = Rect(2835, 4008)
  • B1 = Rect(2004, 2835)
  • B2 = Rect(1417, 2004)
  • B3 = Rect(1001, 1417)
  • B4 = Rect(709, 1001)
  • B5 = Rect(499, 709)
  • B6 = Rect(354, 499)
  • B7 = Rect(249, 354)
  • B8 = Rect(176, 249)
  • B9 = Rect(125, 176)
  • B10 = Rect(88, 125)
  • C0 = Rect(2599, 3677)
  • C1 = Rect(1837, 2599)
  • C2 = Rect(1298, 1837)
  • C3 = Rect(918, 1298)
  • C4 = Rect(649, 918)
  • C5 = Rect(459, 649)
  • C6 = Rect(323, 459)
  • C7 = Rect(230, 323)
  • C8 = Rect(162, 230)
  • C9 = Rect(113, 162)
  • C10 = Rect(79, 113)
Declaration
public void Begin(PDFDoc in_pdfdoc)
Parameters
Type Name Description
PDFDoc in_pdfdoc

the document which the converted GDI pages will be appended to.

Begin(PDFDoc, Point)

Begin the process of translating GDI drawing into a PDF, starting with the creation of a GDI Device Context.

Declaration
public void Begin(PDFDoc in_pdfdoc, Point page_dimension)
Parameters
Type Name Description
PDFDoc in_pdfdoc

the document which the converted GDI pages will be appended to.

Point page_dimension

Width and Height, expressed in inches, defining the boundaries of the physical medium on which the page is intended to be displayed or printed. If page_dimension is not specified the default dimensions of the page are 8.5 x 11 inches.

Dispose()

Releases all resources used by the PDFDCEX

Declaration
public override sealed void Dispose()

Dispose(bool)

Declaration
[HandleProcessCorruptedStateExceptions]
protected virtual void Dispose(bool A_0)
Parameters
Type Name Description
bool A_0

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 PDFDCEX::Begin( page, box, ...).

Declaration
public void End()

EndPage()

Declaration
public int EndPage()
Returns
Type Description
int

~PDFDCEX()

Declaration
protected ~PDFDCEX()

StartPage()

Declaration
public Graphics StartPage()
Returns
Type Description
Graphics

a GDI Handle to Display Context.

Implements

IDisposable
In This Article
Back to top Generated by DocFX