Class Image

Image class

Represents image.

public sealed class Image : BaseParagraph

Constructors

NameDescription
Image()The default constructor.

Properties

NameDescription
BitmapSize { get; }Gets the image bitmap size.
File { get; set; }Gets or sets the image file.
FileType { get; set; }Gets or sets the image file type.
FixHeight { get; set; }Gets or sets the image height.
FixWidth { get; set; }Gets or sets the image width.
virtual HorizontalAlignment { get; set; }Gets or sets a horizontal alignment of paragraph
virtual Hyperlink { get; set; }Gets or sets the fragment hyperlink(for pdf generator).
ImageScale { get; set; }Gets or sets the image scale.
ImageStream { get; set; }Gets or sets the image stream.
IsApplyResolution { get; set; }Gets or sets a bool value that indicates whether the image use resolution during generation
IsBlackWhite { get; set; }Gets or sets a bool value that indicates whether the image is forced to be black-and-white. If TIFF image of CCITT subformat is used, this property must be set to true.
IsFirstParagraphInColumn { get; set; }Gets or sets a bool value that indicates whether this paragraph will be at next column. Default is false.(for pdf generation)
IsInLineParagraph { get; set; }Gets or sets a paragraph is inline. Default is false.(for pdf generation)
IsInNewPage { get; set; }Gets or sets a bool value that force this paragraph generates at new page. Default is false.(for pdf generation)
IsKeptWithNext { get; set; }Gets or sets a bool value that indicates whether current paragraph remains in the same page along with next paragraph. Default is false.(for pdf generation)
Margin { get; set; }Gets or sets a outer margin for paragraph (for pdf generation)
Title { get; set; }Gets or sets a string value that indicates the title of the image.
virtual VerticalAlignment { get; set; }Gets or sets a vertical alignment of paragraph
ZIndex { get; set; }Gets or sets a int value that indicates the Z-order of the graph. A graph with larger ZIndex will be placed over the graph with smaller ZIndex. ZIndex can be negative. Graph with negative ZIndex will be placed behind the text in the page.

Methods

NameDescription
override Clone()Clone the image.
static GetMimeType(Image)Returns mime type for image.

Examples

The following example shows how to convert images (PNG, JPEG, GIF, BMP, or other image formats) to a PDF file.

[C#]
	// The path to the documents directory.
	string dataDir = "YOUR_DATA_DIRECTORY";

	// The path to your image (bmp, png, gif, jpeg, etc.) File.
	string imageFile = Path.Combine(dataDir, "Image-to-PDF.png");

	// The path to output PDF File.
	string pdfFile = Path.Combine(dataDir, "Image-to-PDF.pdf");

	//Initialize empty PDF document
	using(Document pdfDocument = new Document()) 
	{
	  pdfDocument.Pages.Add();
	  Image image = new Image();

	  // Load sample image file
	  image.File = imageFile;
	  pdfDocument.Pages[1].Paragraphs.Add(image);

	  // Save output PDF document
	  pdfDocument.Save(pdfFile);
	}
[VB.NET]

    ' The path to the documents directory.
    Dim dataDir = "YOUR_DATA_DIRECTORY"

    ' The path to your image (bmp, png, gif, jpeg, etc.) File.
    Dim imageFile = Path.Combine(dataDir, "Image-to-PDF.png")

    ' The path to output PDF File.
    Dim pdfFile = Path.Combine(dataDir, "Image-to-PDF.pdf")
 
    'Initialize empty PDF document
    Using pdfDocument As Document = New Document()
        pdfDocument.Pages.Add()
        Dim image As Image = New Image()
 
        ' Load sample image file
        image.File = imageFile
        pdfDocument.Pages(1).Paragraphs.Add(image)
 
        ' Save output PDF document
        pdfDocument.Save(pdfFile)
    End Using

See Also