You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Library/NET/Working-with-Images.md
+36-4Lines changed: 36 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -285,15 +285,43 @@ Syncfusion<sup>®</sup> PDF supports adding metafile vector images. During th
285
285
* EMF Plus Dual
286
286
* WMF (Windows Metafile)
287
287
288
-
The [PdfMetafile](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfMetafile.html) class is used to load metafile images. The [PdfMetafileLayoutFormat](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfMetafileLayoutFormat.html) class allows you to control how the metafile is paginated across multiple pages, including options to split text and images at page boundaries.
288
+
For cross-platform .NET applications, install the [Syncfusion.MetafileRenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.MetafileRenderer.Net.Core) NuGet package from [NuGet.org](https://www.nuget.org/). This package provides the `MetafileRenderer` class, which converts EMF and WMF streams into PDF templates that can be rendered in PDF documents.
289
289
290
-
The following code example illustrates this,
290
+
For Windows-specific applications, The [PdfMetafile](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfMetafile.html) class loads EMF images, and the [PdfMetafileLayoutFormat](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfMetafileLayoutFormat.html) class allows you to control how text and images are split across pages in the PDF document. The following code example illustrates this.
291
291
292
292
{% tabs %}
293
293
294
294
{% highlight c# tabtitle="C# [Cross-platform]" %}
295
295
296
-
//PDF doesn't support inserting a vector image C#.NET Cross platforms.
296
+
using Syncfusion.Drawing;
297
+
using Syncfusion.Metafile;
298
+
using Syncfusion.Pdf;
299
+
using Syncfusion.Pdf.Graphics;
300
+
301
+
//Create a new PDF document.
302
+
PdfDocument document = new PdfDocument();
303
+
//Open the EMF file as a stream.
304
+
using (FileStream metafileStream = new FileStream("Input.emf", FileMode.Open, FileAccess.Read))
305
+
{
306
+
//Create a new instance of the MetafileRenderer class.
307
+
MetafileRenderer renderer = new MetafileRenderer();
document.PageSettings.Size = new Syncfusion.Drawing.SizeF(template.Size);
312
+
//Remove page margins.
313
+
document.PageSettings.Margins.All = 0;
314
+
//Add a page to the document.
315
+
PdfPage page = document.Pages.Add();
316
+
//Get the PDF page graphics.
317
+
PdfGraphics graphics = page.Graphics;
318
+
//Draw the template on the PDF page.
319
+
graphics.DrawPdfTemplate(template, PointF.Empty);
320
+
}
321
+
//Save the PDF document.
322
+
document.Save("Output.pdf");
323
+
//Close the document.
324
+
document.Close(true);
297
325
298
326
{% endhighlight %}
299
327
@@ -359,7 +387,11 @@ doc.Close(True)
359
387
360
388
{% endtabs %}
361
389
362
-
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Images/Insert-vector-image-in-a-PDF-document/).
390
+
You can download a complete working Cross-platform sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Images/Converting-Metafile-to-PDF/.NET).
391
+
392
+
You can download a complete working Window-specific sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Images/Insert-vector-image-in-a-PDF-document/).
393
+
394
+
N> EMF and WMF images can be converted on cross-platform .NET applications by using the `Syncfusion.MetafileRenderer.Net.Core` NuGet package. On Windows-specific platforms, you can also use the PdfMetafile class for rendering Metafile images directly into PDF documents.
0 commit comments