To render a PDF document directly to a Device Context, do the following:
- Create a PdfXpress object and initialize it.
- Create a PdfDocument object from an existing PDF file.
- Create a RenderDcOptions object.
- Set the RenderDcOptions:
- ForDeviceTechnology – we chose Display
- Get the Device Context for the display by calling GetDC().
- Call RenderPageOptionsToDC() on the PdfDocument object.
This will render the document directly to the Device Context, in this case the display.
VB6 Example | ![]() |
---|---|
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long Private Sub PrintButton_Click() Dim pdf As New PdfXpress pdf.InitializePaths "C:\Users\Public\Documents\Accusoft\PDFXpress\V5.0\Support\Font", _ "C:\Users\Public\Documents\Accusoft\PDFXpress\V5.0\Support\CMap" Dim doc As New PdfDocument doc.SetParentControl pdf doc.OpenDocument "C:\myfile.pdf", "" Dim options As New RenderDcOptions options.ForDeviceTechnology = PDF_DeviceTechnology_Display Dim hDC As Long hDC = GetDC(0) doc.RenderPageOptionsToDc 0, hDC, options ReleaseDC 0, hDC Set options = Nothing Set doc = Nothing pdf.Terminate Set pdf = Nothing End Sub |