Class PdfImage
Represents the base class for images.
Inheritance
System.Object
PdfImage
Inherited Members
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public abstract class PdfImage : PdfShapeElement, IPdfWrapper
Constructors
PdfImage()
Declaration
protected PdfImage()
Properties
Height
Declaration
public virtual int Height { get; }
Property Value
Type |
---|
System.Int32 |
HorizontalResolution
Declaration
public virtual float HorizontalResolution { get; }
Property Value
Type |
---|
System.Single |
Metadata
Gets or sets Xmp metadata of the image.
Declaration
public XmpMetadata Metadata { get; set; }
Property Value
Type |
---|
XmpMetadata |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Load the image from the disk with enable metadata extraction.
PdfBitmap image = new PdfBitmap(File.OpenRead("Autumn Leaves.jpg"), true);
//Get image metadata
XmpMetadata metadata = image.Metadata;
//Create custom schema.
CustomSchema customSchema = new CustomSchema(metadata, "custom", "http://www.syncfusion.com");
customSchema["Author"] = "Syncfusion";
customSchema["creationDate"] = DateTime.Now.ToString();
customSchema["DOCID"] = "SYNCSAM001";
//Set image metadata
image.Metadata = metadata;
//Draw the image
graphics.DrawImage(image, 0, 0);
//Save and close the document
MemoryStream stream = new MemoryStream();
doc.Save(stream);
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Load the image from the disk with enable metadata extraction.
Dim image As New PdfBitmap(File.OpenRead("Autumn Leaves.jpg"), true)
'Get image metadata
Dim metadata As XmpMetadata = image.Metadata
//Create custom schema.
Dim customSchema As New CustomSchema(metadata, "custom", "http://www.syncfusion.com")
customSchema("Author") = "Syncfusion"
customSchema("creationDate") = DateTime.Now.ToString()
customSchema("DOCID") = "SYNCSAM001"
'Set image metadata
image.Metadata = metadata
'Draw the image
graphics.DrawImage(image, 0, 0)
'Save the document.
Dim ms As New MemoryStream()
doc.Save(stream)
'Close the document.
doc.Close(True)
PhysicalDimension
Declaration
public virtual SizeF PhysicalDimension { get; }
Property Value
Type |
---|
SizeF |
VerticalResolution
Declaration
public virtual float VerticalResolution { get; }
Property Value
Type |
---|
System.Single |
Width
Declaration
public virtual int Width { get; }
Property Value
Type |
---|
System.Int32 |
Methods
FromStream(Stream)
Creates PdfImage from stream.
Declaration
public static PdfImage FromStream(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream. |
Returns
Type | Description |
---|---|
PdfImage | Returns a created PdfImage object. |
GetPixelSize(Single, Single)
Calculates the width and height of the image.
Declaration
protected static SizeF GetPixelSize(float width, float height)
Parameters
Type | Name | Description |
---|---|---|
System.Single | width | Width of the image in points. |
System.Single | height | Height of the image in points. |
Returns
Type | Description |
---|---|
SizeF | Calculates the width and height of the image. |
GetPointSize(Single, Single)
Calculates size of the image in points.
Declaration
protected SizeF GetPointSize(float width, float height)
Parameters
Type | Name | Description |
---|---|---|
System.Single | width | Width in pixels. |
System.Single | height | Height in pixels. |
Returns
Type | Description |
---|---|
SizeF | size of the image in points. |
GetPointSize(Single, Single, Single, Single)
Calculates size of the image in points.
Declaration
protected SizeF GetPointSize(float width, float height, float horizontalResolution, float verticalResolution)
Parameters
Type | Name | Description |
---|---|---|
System.Single | width | Width in pixels. |
System.Single | height | Height in pixels. |
System.Single | horizontalResolution | Horizontal resolution. |
System.Single | verticalResolution | Vertical resolution. |
Returns
Type | Description |
---|---|
SizeF | size of the image in points. |
SetResolution(Single, Single)
Sets resolution of the image.
Declaration
protected void SetResolution(float horizontalResolution, float verticalResolution)
Parameters
Type | Name | Description |
---|---|---|
System.Single | horizontalResolution | Horizontal resolution of the image. |
System.Single | verticalResolution | Vertical resolution of the image. |