←Select platform

DrawDocument Method

Summary

Renders the specified page of the PDF file.

Syntax

C#
VB
C++
public void DrawDocument( 
   IntPtr hdc, 
   int resolution, 
   int pageNumber 
) 
Public Sub DrawDocument( _ 
   ByVal hdc As IntPtr, _ 
   ByVal resolution As Integer, _ 
   ByVal pageNumber As Integer _ 
)  
public: 
void DrawDocument(  
   IntPtr hdc, 
   int resolution, 
   int pageNumber 
)  

Parameters

hdc
The HDC where the PDF file should be rendered.

resolution
The resolution at which to render the PDF file.

pageNumber
The page number to be rendered.

Example

C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.Pdf; 
using Leadtools.Svg; 
using Leadtools.WinForms; 
 
public void PDFFileDrawDocumentExample() 
{ 
   string sourceFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf"); 
   string destinationFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_DrawDocument.tif"); 
 
   PDFFile pdfFile = new PDFFile(sourceFileName); 
 
   // Create an image 
   using (RasterImage image = new RasterImage(RasterMemoryFlags.Conventional, 2550, 3300, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, null, 0)) 
   { 
      // Make the image white 
      FillCommand fillCmd = new FillCommand(RasterColor.White); 
      fillCmd.Run(image); 
 
      // Get a handle to the drawing surface 
      IntPtr hDC = RasterImagePainter.CreateLeadDC(image); 
 
      // Render the image data 
      pdfFile.DrawDocument(hDC, 300, 1); 
 
      // Save the image in another format 
      using (RasterCodecs codecs = new RasterCodecs()) 
         codecs.Save(image, destinationFileName, RasterImageFormat.TifLzw, image.BitsPerPixel); 
 
      // Clean up 
      RasterImagePainter.DeleteLeadDC(hDC); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Pdf 
Imports Leadtools.WinForms 
Imports Leadtools.Svg 
Imports Leadtools.ImageProcessing 
 
Public Sub PDFFileDrawDocumentExample() 
   Dim sourceFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf") 
   Dim destinationFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD_DrawDocument.tif") 
 
   Dim pdfFile As PDFFile = New PDFFile(sourceFileName) 
 
   ' Create an image 
   Using image As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, 2550, 3300, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, Nothing, 0) 
      ' Make the image white 
      Dim fillCmd As FillCommand = New FillCommand(RasterColor.White) 
      fillCmd.Run(image) 
 
      ' Get a handle to the drawing surface 
      Dim hDC As IntPtr = RasterImagePainter.CreateLeadDC(image) 
 
      ' Render the image data 
      pdfFile.DrawDocument(hDC, 300, 1) 
 
      ' Save the image in another format 
      Using codecs As RasterCodecs = New RasterCodecs() 
         codecs.Save(image, destinationFileName, RasterImageFormat.TifLzw, image.BitsPerPixel) 
      End Using 
 
      ' Clean up 
      RasterImagePainter.DeleteLeadDC(hDC) 
   End Using 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

See Also

Reference

PDFFile Class

PDFFile Members

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly