diff --git a/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF.sln b/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF.sln new file mode 100644 index 00000000..725b2f9a --- /dev/null +++ b/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.37516.0 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Converting-Metafile-to-PDF", "Converting-Metafile-to-PDF\Converting-Metafile-to-PDF.csproj", "{4AC761AC-C0CB-4022-93B4-DF27830765AF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4AC761AC-C0CB-4022-93B4-DF27830765AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4AC761AC-C0CB-4022-93B4-DF27830765AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AC761AC-C0CB-4022-93B4-DF27830765AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4AC761AC-C0CB-4022-93B4-DF27830765AF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8683346D-D856-4171-A269-2B4AFB761FD7} + EndGlobalSection +EndGlobal diff --git a/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Converting-Metafile-to-PDF.csproj b/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Converting-Metafile-to-PDF.csproj new file mode 100644 index 00000000..59e666ff --- /dev/null +++ b/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Converting-Metafile-to-PDF.csproj @@ -0,0 +1,20 @@ + + + + Exe + net8.0 + Converting_Metafile_to_PDF + enable + enable + + + + + + + + + Always + + + diff --git a/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Data/Input.emf b/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Data/Input.emf new file mode 100644 index 00000000..90e5591d Binary files /dev/null and b/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Data/Input.emf differ diff --git a/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Output/gitkeep.txt b/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Program.cs b/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Program.cs new file mode 100644 index 00000000..e7fc60b1 --- /dev/null +++ b/Images/Converting-Metafile-to-PDF/.NET/Converting-Metafile-to-PDF/Program.cs @@ -0,0 +1,29 @@ +using Syncfusion.Drawing; +using Syncfusion.Metafile; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + +//Create a new PDF document. +PdfDocument document = new PdfDocument(); +//Open the WMF file as a stream. +using (FileStream metafileStream = new FileStream(Path.GetFullPath(@"Data/Input.emf"), FileMode.Open, FileAccess.Read)) +{ + //Create a new instance of the MetafileRenderer class. + MetafileRenderer renderer = new MetafileRenderer(); + //Convert the Metafile stream to a PdfTemplate. + PdfTemplate template = renderer.ConvertToPdfTemplate(metafileStream); + //Set the page size to match the template size. + document.PageSettings.Size = new SizeF(template.Size); + //Remove page margins. + document.PageSettings.Margins.All = 0; + //Add a page to the document. + PdfPage page = document.Pages.Add(); + //Get the PDF page graphics. + PdfGraphics graphics = page.Graphics; + //Draw the template on the PDF page. + graphics.DrawPdfTemplate(template, PointF.Empty); +} +//Save the PDF document. +document.Save(Path.GetFullPath(@"Output/Output.pdf")); +//Close the document. +document.Close(true); \ No newline at end of file