C# Class ConvertPDF.PDFConvert

Create by : TaGoH URL of the last version: http://www.codeproject.com/KB/cs/GhostScriptUseWithCSharp.aspx Description: Class to convert a pdf to an image using GhostScript DLL A big Credit for this code go to:Rangel Avulso I mainly create a better interface and refactor it to made it ready to use!
显示文件 Open project: nguyenq/VietOCR3.NET Class Usage Examples

Public Properties

Property Type Description
output StringBuilder

Public Methods

Method Description
AnsiZtoString ( IntPtr strz ) : string

Convert a Pointer to a string to a real string

Convert ( string inputFile, string outputFile ) : bool

Convert a single file!

You must pass all the parameter for the conversion as Proprieties of this class

Convert ( string inputFile, string outputFile, string parameters ) : bool

Convert a single file!

Thanks to tchu_2000 for the help!

GetRevision ( ) : GhostScriptRevision
Initialize ( string sArgs ) : bool
PDFConvert ( ) : System
PDFConvert ( IntPtr objHandle ) : System
gsdll_stderr ( IntPtr intGSInstanceHandle, IntPtr strz, int intBytes ) : int
gsdll_stdin ( IntPtr intGSInstanceHandle, IntPtr strz, int intBytes ) : int
gsdll_stdout ( IntPtr intGSInstanceHandle, IntPtr strz, int intBytes ) : int

Private Methods

Method Description
ClearParameters ( GCHandle &aGCHandle, GCHandle &gchandleArgs ) : void

Remove the memory allocated

Convert ( string inputFile, string outputFile, bool throwException, string options ) : bool

Convert a single file!

You must pass all the parameter for the conversion as Proprieties of this class

CopyMemory ( IntPtr Destination, IntPtr Source, uint Length ) : void
GetGeneratedArgs ( string inputFile, string outputFile, string otherParameters ) : string[]

This function create the list of parameters to pass to the dll with parameters given directly from the program

Be very Cautious using this! code provided and modified from tchu_2000

SaveOutputToImage ( object sender, System e ) : void
StringToAnsiZ ( string str ) : byte[]

Convert a Unicode string to a null terminated Ansi string for Ghostscript. The result is stored in a byte array

gsapi_delete_instance ( IntPtr instance ) : void
gsapi_delete_instance32 ( IntPtr instance ) : void
gsapi_delete_instance64 ( IntPtr instance ) : void
gsapi_exit ( IntPtr instance ) : void
gsapi_exit32 ( IntPtr instance ) : int
gsapi_exit64 ( IntPtr instance ) : int
gsapi_init_with_args ( IntPtr instance, int argc, IntPtr argv ) : int
gsapi_init_with_args32 ( IntPtr instance, int argc, IntPtr argv ) : int
gsapi_init_with_args64 ( IntPtr instance, int argc, IntPtr argv ) : int
gsapi_new_instance ( IntPtr &pinstance, IntPtr caller_handle ) : int
gsapi_new_instance32 ( IntPtr &pinstance, IntPtr caller_handle ) : int
gsapi_new_instance64 ( IntPtr &pinstance, IntPtr caller_handle ) : int
gsapi_revision ( GS_Revision &pGSRevisionInfo, int intLen ) : int
gsapi_revision32 ( GS_Revision &pGSRevisionInfo, int intLen ) : int
gsapi_revision64 ( GS_Revision &pGSRevisionInfo, int intLen ) : int
gsapi_set_stdio ( IntPtr lngGSInstance, StdioCallBack gsdll_stdin, StdioCallBack gsdll_stdout, StdioCallBack gsdll_stderr ) : int
gsapi_set_stdio32 ( IntPtr lngGSInstance, StdioCallBack gsdll_stdin, StdioCallBack gsdll_stdout, StdioCallBack gsdll_stderr ) : int
gsapi_set_stdio64 ( IntPtr lngGSInstance, StdioCallBack gsdll_stdin, StdioCallBack gsdll_stdout, StdioCallBack gsdll_stderr ) : int

Method Details

AnsiZtoString() public static method

Convert a Pointer to a string to a real string
public static AnsiZtoString ( IntPtr strz ) : string
strz System.IntPtr the pointer to the string in memory
return string

Convert() public method

Convert a single file!
You must pass all the parameter for the conversion as Proprieties of this class
public Convert ( string inputFile, string outputFile ) : bool
inputFile string The file PDf to convert
outputFile string The image file that will be created
return bool

Convert() public method

Convert a single file!
Thanks to tchu_2000 for the help!
public Convert ( string inputFile, string outputFile, string parameters ) : bool
inputFile string The file PDf to convert
outputFile string The image file that will be created
parameters string You must pass all the parameter for the conversion here
return bool

GetRevision() public method

public GetRevision ( ) : GhostScriptRevision
return GhostScriptRevision

Initialize() public method

public Initialize ( string sArgs ) : bool
sArgs string
return bool

PDFConvert() public method

public PDFConvert ( ) : System
return System

PDFConvert() public method

public PDFConvert ( IntPtr objHandle ) : System
objHandle System.IntPtr
return System

gsdll_stderr() public method

public gsdll_stderr ( IntPtr intGSInstanceHandle, IntPtr strz, int intBytes ) : int
intGSInstanceHandle System.IntPtr
strz System.IntPtr
intBytes int
return int

gsdll_stdin() public method

public gsdll_stdin ( IntPtr intGSInstanceHandle, IntPtr strz, int intBytes ) : int
intGSInstanceHandle System.IntPtr
strz System.IntPtr
intBytes int
return int

gsdll_stdout() public method

public gsdll_stdout ( IntPtr intGSInstanceHandle, IntPtr strz, int intBytes ) : int
intGSInstanceHandle System.IntPtr
strz System.IntPtr
intBytes int
return int

Property Details

output public_oe property

public StringBuilder output
return StringBuilder