diff --git a/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF.sln b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF.sln new file mode 100644 index 000000000..738728faf --- /dev/null +++ b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mail-merge-Word-to-PDF", "Mail-merge-Word-to-PDF\Mail-merge-Word-to-PDF.csproj", "{C7C9CB0A-077F-4617-B958-EF13E70AE542}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C7C9CB0A-077F-4617-B958-EF13E70AE542}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7C9CB0A-077F-4617-B958-EF13E70AE542}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7C9CB0A-077F-4617-B958-EF13E70AE542}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7C9CB0A-077F-4617-B958-EF13E70AE542}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/App.config b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/App.config new file mode 100644 index 000000000..b50c74f35 --- /dev/null +++ b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Data/Template.docx b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Data/Template.docx new file mode 100644 index 000000000..233d5d421 Binary files /dev/null and b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Data/Template.docx differ diff --git a/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Mail-merge-Word-to-PDF.csproj b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Mail-merge-Word-to-PDF.csproj new file mode 100644 index 000000000..87d9ee2ee --- /dev/null +++ b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Mail-merge-Word-to-PDF.csproj @@ -0,0 +1,72 @@ + + + + + Debug + AnyCPU + {C7C9CB0A-077F-4617-B958-EF13E70AE542} + Exe + Mail_merge_Word_to_PDF + Mail-merge-Word-to-PDF + v4.6.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Syncfusion.Compression.Base.29.1.33\lib\net462\Syncfusion.Compression.Base.dll + + + ..\packages\Syncfusion.DocIO.WinForms.29.1.33\lib\net462\Syncfusion.DocIO.Base.dll + + + ..\packages\Syncfusion.DocToPDFConverter.WinForms.29.1.33\lib\net462\Syncfusion.DocToPdfConverter.Base.dll + + + ..\packages\Syncfusion.Licensing.29.1.33\lib\net462\Syncfusion.Licensing.dll + + + ..\packages\Syncfusion.OfficeChart.Base.29.1.33\lib\net462\Syncfusion.OfficeChart.Base.dll + + + ..\packages\Syncfusion.Pdf.WinForms.29.1.33\lib\net462\Syncfusion.Pdf.Base.dll + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Program.cs b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Program.cs new file mode 100644 index 000000000..6f59a04ae --- /dev/null +++ b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Program.cs @@ -0,0 +1,37 @@ +using Syncfusion.DocIO.DLS; +using Syncfusion.DocToPDFConverter; +using Syncfusion.Pdf; +using System.IO; + +namespace Mail_merge_Word_to_PDF +{ + internal class Program + { + static void Main(string[] args) + { + // Opens the template Word document + using (WordDocument document = new WordDocument("../../Data/Template.docx")) + { + // Defines the merge field names and corresponding values + string[] fieldNames = new string[] { "EmployeeId", "Name", "Phone", "City" }; + string[] fieldValues = new string[] { "1001", "Peter", "+122-2222222", "London" }; + + // Performs the mail merge operation + document.MailMerge.Execute(fieldNames, fieldValues); + + // Converts the merged Word document to PDF + using (DocToPDFConverter render = new DocToPDFConverter()) + { + using (PdfDocument pdfDocument = render.ConvertToPDF(document)) + { + // Saves the PDF document to the specified file path + using (FileStream docStream1 = new FileStream(Path.GetFullPath(@"../../Result.pdf"), FileMode.Create, FileAccess.Write)) + { + pdfDocument.Save(docStream1); + } + } + } + } + } + } +} diff --git a/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Properties/AssemblyInfo.cs b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..4af573dd0 --- /dev/null +++ b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Mail-merge-Word-to-PDF")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Mail-merge-Word-to-PDF")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c7c9cb0a-077f-4617-b958-ef13e70ae542")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/packages.config b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/packages.config new file mode 100644 index 000000000..877edeb2d --- /dev/null +++ b/Mail-Merge/Mail-merge-Word-to-PDF/.NET-Framework/Mail-merge-Word-to-PDF/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file