Accusoft.PdfXpress5.ActiveX
Render to Device Context
Send Feedback
PDF Xpress 5 for ActiveX - User Guide > How To > Modify PDF Document Content > Render to Device Context

Glossary Item Box

To render a PDF document directly to a Device Context, do the following:

  1. Create a PdfXpress object and initialize it.
  2. Create a PdfDocument object from an existing PDF file.
  3. Create a RenderDcOptions object.
  4. Set the RenderDcOptions:
  5. Get the Device Context for the display by calling GetDC().
  6. Call RenderPageOptionsToDC() on the PdfDocument object.

This will render the document directly to the Device Context, in this case the display.

VB6 Example Copy Code
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
©2012. Accusoft Corporation. All Rights Reserved.