Skip to content

Commit 541209b

Browse files
committed
977281: Added EMF to PDF Converter sample code.
1 parent c41e62a commit 541209b

7 files changed

Lines changed: 184 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36408.4 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-EMF-to-PDF", "Convert-EMF-to-PDF\Convert-EMF-to-PDF.csproj", "{31495091-2413-4172-8197-4D714A487C9B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{31495091-2413-4172-8197-4D714A487C9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{31495091-2413-4172-8197-4D714A487C9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{31495091-2413-4172-8197-4D714A487C9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{31495091-2413-4172-8197-4D714A487C9B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {3007161A-3616-4ABD-91C7-A153F79A32CE}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{31495091-2413-4172-8197-4D714A487C9B}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>Convert_EMF_to_PDF</RootNamespace>
10+
<AssemblyName>Convert-EMF-to-PDF</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Syncfusion.Compression.Base, Version=30.2462.7.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
37+
<HintPath>..\packages\Syncfusion.Compression.Base.30.2.7\lib\net462\Syncfusion.Compression.Base.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Syncfusion.Licensing, Version=30.2462.7.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Syncfusion.Licensing.30.2.7\lib\net462\Syncfusion.Licensing.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Syncfusion.Pdf.Base, Version=30.2462.7.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
43+
<HintPath>..\packages\Syncfusion.Pdf.WinForms.30.2.7\lib\net462\Syncfusion.Pdf.Base.dll</HintPath>
44+
</Reference>
45+
<Reference Include="System" />
46+
<Reference Include="System.Core" />
47+
<Reference Include="System.Drawing" />
48+
<Reference Include="System.Xml.Linq" />
49+
<Reference Include="System.Data.DataSetExtensions" />
50+
<Reference Include="Microsoft.CSharp" />
51+
<Reference Include="System.Data" />
52+
<Reference Include="System.Net.Http" />
53+
<Reference Include="System.Xml" />
54+
</ItemGroup>
55+
<ItemGroup>
56+
<Compile Include="Program.cs" />
57+
<Compile Include="Properties\AssemblyInfo.cs" />
58+
</ItemGroup>
59+
<ItemGroup>
60+
<None Include="App.config" />
61+
<None Include="packages.config" />
62+
</ItemGroup>
63+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
64+
</Project>
Binary file not shown.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Syncfusion.Pdf;
2+
using Syncfusion.Pdf.Graphics;
3+
using System;
4+
using System.Drawing;
5+
using System.Drawing.Imaging;
6+
7+
namespace Convert_EMF_to_PDF
8+
{
9+
internal class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
// Create a new PDF document
14+
PdfDocument doc = new PdfDocument();
15+
16+
// Set all page margins to zero
17+
doc.PageSettings.Margins.All = 0;
18+
19+
// Add a new page to the document
20+
PdfPage page = doc.Pages.Add();
21+
22+
// Create PDF graphics object for drawing on the page
23+
PdfGraphics graphics = page.Graphics;
24+
25+
// Define layout format for rendering metafile content
26+
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
27+
28+
// Enable splitting of images across pages if needed
29+
format.SplitImages = true;
30+
31+
// Enable splitting of text lines across pages if needed
32+
format.SplitTextLines = true;
33+
34+
// Load the EMF (Enhanced Metafile) image from file
35+
Metafile metaChart = new Metafile(@"../../Data/Input.emf");
36+
37+
// Convert the metafile to a PDF-compatible format
38+
PdfMetafile pdfMetaChart = new PdfMetafile(metaChart);
39+
40+
// Draw the metafile image on the entire page area
41+
graphics.DrawImage(pdfMetaChart, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height));
42+
43+
// Save the document to a file
44+
doc.Save(@"Output.pdf");
45+
46+
// Close the document and release resources
47+
doc.Close(true);
48+
}
49+
}
50+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Convert-EMF-to-PDF")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Convert-EMF-to-PDF")]
13+
[assembly: AssemblyCopyright("Copyright © 2025")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("31495091-2413-4172-8197-4d714a487c9b")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Syncfusion.Compression.Base" version="30.2.7" targetFramework="net472" />
4+
<package id="Syncfusion.Licensing" version="30.2.7" targetFramework="net472" />
5+
<package id="Syncfusion.Pdf.WinForms" version="30.2.7" targetFramework="net472" />
6+
</packages>

0 commit comments

Comments
 (0)