How to C#: Converter
Use Convert SDK for C#
Basic SDK Concept
  |  
Home ›› XDoc.Converter ›› C# Converter: Basic SDK Concept

C#: XDoc.Converter Basic SDK Concept


Details for XDoc.Converter Enumerations, Classes, and API References






This C# online guide provides basic SDK concepts of RasterEdge XDoc.Converter for .NET, including enumerations, classes and API references. And these three aspects will be talked respectively. (Click below to have a quick navigation)


Enumerations


Classes


API References




C#: XDoc.Converter Enumerations



There are three types of enumerations which are FileType, ConvertResult and FitToPageMode.


Enum: FileType


Values

Description

IMG_BMP

For .bmp file.

IMG_GIF

For .gif file.

IMG_JPEG

For .jpg file.

IMG_PNG

For .png file.

IMG_JPEG2000

For .jp2 file.

IMG_SVG

For .svg file.

IMG_PSD

For Photoshop .psd file.

DOC_TIFF

For .tif, .tiff file.

DOC_PDF

For .pdf file.

DOC_DICOM

For .dcm file.

DOC_MSDOCX

For MS Office .docx file.

DOC_MSXLSX

For MS Office .xlsx file.

DOC_MSPPTX

For MS Office .pptx file.

DOC_MSDOC

For MS Office .doc file.

DOC_MSXLS

For MS Office .xls file.

DOC_MSPPT

For MS Office .ppt file.

INVALID

Invalid file type for this C# project.


Enum: ConvertResult


Values

Description

NO_ERROR

No error.

FILE_TYPE_UNMATCH

Return this error if the file type of input file or stream does not match to the interface.

FILE_TYPE_UNSUPPORT

Return this error if a feature does not support to a certain file type in this C# project.

UNKNOWN_ERROR

Return this for all other errors.


Enum: FitToPageMode


Values

Description

None

Use image size for target page.

FitToWidth

Resize image to fit target page width.

FitToHeight

Resize image to fit target page height.

FitToPage

Resize image to fit target page.



Remark: using FitToPageMode.FitToPage may cause image be distorted.




C#: XDoc.Converter Classes



C# users can control documents and images saving options and three classes are involved. Please see details below.


Class: BaseSaveOption


Property

Type

Description

FileType

FileType

The target file type.


Class: ImageSaveOption


Property

Type

Description

UseDefaultResolution

Bool

Flag to indicate if use the resolution defined in input file.

Defult: true

ResolutionX

Float

Horizontal resolution of output image in pixel per inch.

This property is only applied while UseDefaultResolution is set to false.

Default: 96.0F

ResolutionY

Float

Vertical resolution of output image in pixel per inch.

This property is only applied while UseDefaultResolution is set to false.

Default: 96.0F


Class: DocumentSaveOption


Property

Type

Description

UseDefaultPageSize

Bool

Flag to indicate if use the page size defined in input file.

Default: true.

FitToPageMode

FitToPageMode

Mode used to resize the input image size to fit the page size in output document.

Default: FitToPageMode.None.

PageWidth

Float

Target page width in inch.

Only applied while UseDefaultPageSIze is set to false.

Default: 8.27F

PageHeight

Float

Target page height in inch.

Only applied while UseDefaultPageSIze is set to false.

Default: 11.7F



C#: XDoc.Converter API References




The following part provides all API References that will be used for documents and images conversion in C#.



API References for Class: ImageConverter


public static FileType GetImageType(String filePath)


public static FileType GetImageType(Stream fileStream)


public static ConvertResult ToImage(String srcFilePath, String desFilePath, FileType fileType)


public static ConvertResult ToImage(String srcFilePath, String desFilePath, ImageSaveOption option)


public static ConvertResult ToImage(Stream srcStream, Stream desStream, FileType fileType)


public static ConvertResult ToImage(Stream srcStream, Stream desStream, ImageSaveOption option)


public static ConvertResult ToDocument(String srcFilePath, String desFilePath, FileType fileType)


public static ConvertResult ToDocument (String srcFilePath, String desFilePath, DocumentSaveOption option)


public static ConvertResult ToDocument (Stream srcStream, Stream desStream, FileType fileType)


public static ConvertResult ToDocument (Stream srcStream, Stream desStream, DocumentSaveOption option)



API: public static FileType GetImageType(String filePath)


Argument

Type

Description

[filePath]

String

File path of a document.


Return is FileType.


API: public static FileType GetImageType(Stream fileStream)


Argument

Type

Description

[fileStream]

Stream

A document stream.


Return is FileType.


API: public static ConvertResult ToImage(String srcFilePath, Sting desFilePath, FileType fileType)


Arguments

Type

Description

[srcFilePath]

String

File path of input image file.

[desFilePath]

String

File path of output image file.

[fileType]

FileType

File type of output image file.


Return is ConvertResult.


API: public static ConvertResult ToImage(String srcFilePath, Sting desFilePath, ImageSaveOption option)


Arguments

Type

Description

[srcFilePath]

String

File path of input image file.

[desFilePath]

String

File path of output image file.

[option]

ImageSaveOption

Save setting of output image file.


Return is ConvertResult.


API: public static ConvertResult ToDocument(String srcFilePath, Sting desFilePath, FileType fileType)


Arguments

Type

Description

[srcFilePath]

String

File path of input image file.

[desFilePath]

String

File path of output image file.

[fileType]

FileType

File type of output document file.


Return is ConvertResult.


API: public static ConvertResult ToDocument(String srcFilePath, Sting desFilePath, DocumentSaveOption option)


Arguments

Type

Description

[srcFilePath]

String

File path of input image file.

[desFilePath]

String

File path of output image file.

[option]

DocumentSaveOption

Save setting of output document file.


Return is ConvertResult.



API References for Class: DocumentConverter


public static FileType GetDocumentType(String filePath)


public static FileType GetDocumentType(Stream fileStream)


public static ConvertResult ToImage(String srcFilePath, String desFilePath, FileType fileType)


public static ConvertResult ToImage(String srcFilePath, String desFilePath, ImageSaveOption option)


public static ConvertResult ToImage(Stream srcStream, Stream desStream, FileType fileType)


public static ConvertResult ToImage(Stream srcStream, Stream desStream, ImageSaveOption option)


public static ConvertResult ToDocument(String srcFilePath, String desFilePath, FileType fileType)


public static ConvertResult ToDocument (String srcFilePath, String desFilePath, DocumentSaveOption option)


public static ConvertResult ToDocument (Stream srcStream, Stream desStream, FileType fileType)


public static ConvertResult ToDocument (Stream srcStream, Stream desStream, DocumentSaveOption option)


public static ConvertResult ToImages(String srcFilePath, String[] desFilePaths, FileType fileType)


public static ConvertResult ToImages(String srcFilePath, String[] desFilePaths, ImageSaveOption option)


public static ConvertResult ToImages(Stream srcStream, Stream[] desStreams, FileType fileType)


public static ConvertResult ToImages(Stream srcStream, Stream[] desStreams, ImageSaveOption option)



API: public static FileType GetDocumentType(String filePath)


Argument

Type

Description

[filePath]

String

File path of a document.


Return is FileType.


API: public static FileType GetDocumentType(Stream fileStream)


Argument

Type

Description

[fileStream]

Stream

A document stream.


Return is FileType.


API: public static ConvertResult ToImage(String srcFilePath, Sting desFilePath, FileType fileType)


Arguments

Type

Description

[srcFilePath]

String

File path of input document file.

[desFilePath]

String

File path of output image file.

[fileType]

FileType

File type of output image file.


Return is ConvertResult.


API: public static ConvertResult ToImage(String srcFilePath, Sting desFilePath, ImageSaveOption option)


Arguments

Type

Description

[srcFilePath]

String

File path of input document file.

[desFilePath]

String

File path of output image file.

[option]

ImageSaveOption

Save setting of output image file.


Return is ConvertResult.


API: public static ConvertResult ToDocument(String srcFilePath, Sting desFilePath, FileType fileType)


Arguments

Type

Description

[srcFilePath]

String

File path of input document file.

[desFilePath]

String

File path of output document file.

[fileType]

FileType

File type of output document file.


Return is ConvertResult.


API: public static ConvertResult ToDocument(String srcFilePath, Sting desFilePath, DocumentSaveOption option)


Arguments

Type

Description

[srcFilePath]

String

File path of input document file.

[desFilePath]

String

File path of output document file.

[option]

DocumentSaveOption

Save setting of the output document file.


Return is ConvertResult.


API: public static ConvertResult ToImages(String srcFilePath, Sting[] desFilePaths, FileType fileType)


Arguments

Type

Description

[srcFilePath]

String

File path of input document file.

[desFilePath]

String[]

An array of file paths for output image files.

Length of the array SHOULD BE equal to the page count of document.

[fileType]

FileType

File type of output image file.


Return is ConvertResult.


API: public static ConvertResult ToImages(String srcFilePath, Sting desFilePaths, ImageSaveOption option)


Arguments

Type

Description

[srcFilePath]

String

File path of input document file.

[desFilePath]

String[]

An array of file paths for output image files.

Length of the array SHOULD BE equal to the page count of document.

[option]

ImageSaveOption

Save setting of the output image file.


Return is ConvertResult.