Class PdfMetafile
Class representing metafile image
Implements
Inherited Members
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfMetafile : PdfImage, IPdfWrapper, IDisposable
Remarks
This API is not supported in WinRT, Windows Phone, ASP.NET Core, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile("MetaChart.emf");
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
'Create a Metafile instance
Dim metaChart As New PdfMetafile("MetaChart.emf")
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
Constructors
PdfMetafile(Metafile)
Initializes a new instance of the PdfMetafile class with System.Drawing.Imaging.Metafile
Declaration
public PdfMetafile(Metafile metafile)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Imaging.Metafile | metafile | The metafile. |
Remarks
This constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
Metafile metaFile = new Metafile("MetaChart.emf");
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile(metaFile);
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
Dim metaFile As New Metafile("MetaChart.emf")
'Create a Metafile instance
Dim metaChart As New PdfMetafile(metaFile)
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
PdfMetafile(Stream)
Initializes a new instance of the PdfMetafile class from stream of the metafile
Declaration
public PdfMetafile(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream. |
Remarks
This API is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
byte[] data = File.ReadAllBytes("MetaChart.emf");
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile(new MemoryStream(data));
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
Dim data As Byte() = File.ReadAllBytes("MetaChart.emf")
'Create a Metafile instance
Dim metaChart As New PdfMetafile(New MemoryStream(data))
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
PdfMetafile(String)
Initializes a new instance of the PdfMetafile class with metafile path
Declaration
public PdfMetafile(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The metafile path. |
Remarks
This constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile("MetaChart.emf");
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
'Create a Metafile instance
Dim metaChart As New PdfMetafile("MetaChart.emf")
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
Properties
ImageResolution
Gets or sets the resolution of the image
Declaration
public int ImageResolution { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile("MetaChart.emf");
//Set image resolution.
metaChart.ImageResolution = 72;
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
'Create a Metafile instance
Dim metaChart As New PdfMetafile("MetaChart.emf")
'Set image resolution.
metaChart.ImageResolution = 72
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
PageScale
Gets or sets the page scale.
Declaration
public float PageScale { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The page scale. |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile("MetaChart.emf");
//Set page scale.
metaChart.PageScale = 1.2f;
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
'Create a Metafile instance
Dim metaChart As New PdfMetafile("MetaChart.emf")
'Set page scale.
metaChart.PageScale = 1.2F
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
PageUnit
Gets or sets the page graphics unit.
Declaration
public GraphicsUnit PageUnit { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.GraphicsUnit | The page unit. |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile("MetaChart.emf");
//Set the page unit.
metaChart.PageUnit = GraphicsUnit.Point;
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
'Create a Metafile instance
Dim metaChart As New PdfMetafile("MetaChart.emf")
'Set the page unit.
metaChart.PageUnit = GraphicsUnit.Point
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
Quality
Gets or sets the quality of the image.
Declaration
public long Quality { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Remarks
When the image is stored into PDF not as a mask, you may reduce its quality, which saves the disk space.
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile("MetaChart.emf");
//Set image quality.
metaChart.Quality = 10;
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
'Create a Metafile instance
Dim metaChart As New PdfMetafile("MetaChart.emf")
'Set image quality.
metaChart.Quality = 10
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile("MetaChart.emf");
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Dispose the metafile.
metaChart.Dispose();
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
'Create a Metafile instance
Dim metaChart As New PdfMetafile("MetaChart.emf")
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Dispose the metafile.
metaChart.Dispose()
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
Finalize()
Releases unmanaged resources and performs other cleanup operations before the PdfMetafile is reclaimed by garbage collection.
Declaration
protected void Finalize()
Layout(PdfLayoutParams)
Layouts the element.
Declaration
protected override PdfLayoutResult Layout(PdfLayoutParams param)
Parameters
Type | Name | Description |
---|---|---|
PdfLayoutParams | param | Layout parameters. |
Returns
Type | Description |
---|---|
PdfLayoutResult | Returns lay outing results. |
Overrides
Layout(HtmlToPdfLayoutParams)
Layouts the HtmlToPdf element.
Declaration
protected override PdfLayoutResult Layout(HtmlToPdfLayoutParams param)
Parameters
Type | Name | Description |
---|---|---|
HtmlToPdfLayoutParams | param | Layout parameters. |
Returns
Type | Description |
---|---|
PdfLayoutResult | Returns lay outing results. |
Overrides
SetTransparency(Single, Single, PdfBlendMode, Boolean)
Sets the transparency.
Declaration
public void SetTransparency(float alphaPen, float alphaBrush, PdfBlendMode blendMode, bool transparency)
Parameters
Type | Name | Description |
---|---|---|
System.Single | alphaPen | The alpha value for pen operations. |
System.Single | alphaBrush | The alpha value for brush operations. |
PdfBlendMode | blendMode | The blend mode. |
System.Boolean | transparency | Transparency is applied or not. |
Remarks
This API is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create the layout format
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//Split text and image between pages
format.SplitImages = true;
format.SplitTextLines = true;
//Create a Metafile instance
PdfMetafile metaChart = new PdfMetafile("MetaChart.emf");
//Set transparency.
metaChart.SetTransparency(0.5f, 0.5f, PdfBlendMode.Overlay, true);
//Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create the layout format
Dim format As New PdfMetafileLayoutFormat()
'Split text and image between pages
format.SplitImages = True
format.SplitTextLines = True
'Create a Metafile instance
Dim metaChart As New PdfMetafile("MetaChart.emf")
'Set transparency.
metaChart.SetTransparency(0.5F, 0.5F, PdfBlendMode.Overlay, True)
'Draw the Metafile in the page
metaChart.Draw(page, PointF.Empty, format)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)