diff --git a/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF.sln b/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF.sln new file mode 100644 index 000000000..8a3fbda63 --- /dev/null +++ b/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.168 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mail-merged-Word-into-PDF", "Mail-merged-Word-into-PDF\Mail-merged-Word-into-PDF.csproj", "{060C9D44-A053-43CB-8A16-BFB8BCCCE580}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {060C9D44-A053-43CB-8A16-BFB8BCCCE580}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {060C9D44-A053-43CB-8A16-BFB8BCCCE580}.Debug|Any CPU.Build.0 = Debug|Any CPU + {060C9D44-A053-43CB-8A16-BFB8BCCCE580}.Release|Any CPU.ActiveCfg = Release|Any CPU + {060C9D44-A053-43CB-8A16-BFB8BCCCE580}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BF422962-51A0-4C08-B7DB-51C26692639F} + EndGlobalSection +EndGlobal diff --git a/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF/Letter Formatting.docx b/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF/Letter Formatting.docx new file mode 100644 index 000000000..3b70afdd2 Binary files /dev/null and b/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF/Letter Formatting.docx differ diff --git a/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF/Mail-merged-Word-into-PDF.csproj b/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF/Mail-merged-Word-into-PDF.csproj new file mode 100644 index 000000000..5915cbdf6 --- /dev/null +++ b/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF/Mail-merged-Word-into-PDF.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp2.1 + Mail_merged_Word_into_PDF + + + + + + + diff --git a/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF/Program.cs b/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF/Program.cs new file mode 100644 index 000000000..b120ace4b --- /dev/null +++ b/Word-to-PDF-Conversion/Mail-merged-Word-into-PDF/.NET-Standard/Mail-merged-Word-into-PDF/Program.cs @@ -0,0 +1,38 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIORenderer; +using Syncfusion.Pdf; +using System.IO; + +namespace Mail_merged_Word_into_PDF +{ + class Program + { + static void Main(string[] args) + { + //Opens the Word template document + FileStream fileStreamPath = new FileStream(@"../../../Letter Formatting.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx)) + { + string[] fieldNames = { "ContactName", "CompanyName", "Address", "City", "Country", "Phone" }; + string[] fieldValues = { "Nancy Davolio", "Syncfusion", "507 - 20th Ave. E.Apt. 2A", "Seattle, WA", "USA", "(206) 555-9857-x5467" }; + //Performs the mail merge + document.MailMerge.Execute(fieldNames, fieldValues); + //Create instance for DocIORenderer for Word to PDF conversion + DocIORenderer render = new DocIORenderer(); + //Converts Word document to PDF. + PdfDocument pdfDocument = render.ConvertToPDF(document); + //Release the resources used by the Word document and DocIO Renderer objects. + render.Dispose(); + document.Dispose(); + //Saves the PDF file. + FileStream outputStream = new FileStream(@"Ouput.pdf", FileMode.CreateNew, FileAccess.Write); + pdfDocument.Save(outputStream); + //Closes the instance of PDF document object. + pdfDocument.Close(); + //Dispose the instance of FileStream. + outputStream.Dispose(); + } + } + } +} diff --git a/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process.sln b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process.sln new file mode 100644 index 000000000..1d5ff65ea --- /dev/null +++ b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Word-to-PDF-Batch-process", "Word-to-PDF-Batch-process\Word-to-PDF-Batch-process.csproj", "{2BD87830-E669-478E-AB71-D96123882EFC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2BD87830-E669-478E-AB71-D96123882EFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2BD87830-E669-478E-AB71-D96123882EFC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2BD87830-E669-478E-AB71-D96123882EFC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2BD87830-E669-478E-AB71-D96123882EFC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C6634722-7F6B-43D8-875D-405DC8865D70} + EndGlobalSection +EndGlobal diff --git a/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Chart.docx b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Chart.docx new file mode 100644 index 000000000..8a9a36faf Binary files /dev/null and b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Chart.docx differ diff --git a/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Equation.docx b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Equation.docx new file mode 100644 index 000000000..5f3496c42 Binary files /dev/null and b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Equation.docx differ diff --git a/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Letter Formatting.docx b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Letter Formatting.docx new file mode 100644 index 000000000..3b70afdd2 Binary files /dev/null and b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Letter Formatting.docx differ diff --git a/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Template.docx b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Template.docx new file mode 100644 index 000000000..08d4faa9a Binary files /dev/null and b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/Template.docx differ diff --git a/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/WordToRTF.docx b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/WordToRTF.docx new file mode 100644 index 000000000..0d449aa59 Binary files /dev/null and b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Data/WordToRTF.docx differ diff --git a/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Program.cs b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Program.cs new file mode 100644 index 000000000..2ee2747f2 --- /dev/null +++ b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Program.cs @@ -0,0 +1,40 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIORenderer; +using Syncfusion.Pdf; + +namespace Word_to_PDF_Batch_process +{ + class Program + { + static void Main(string[] args) + { + //Gets multiple word document from the data folder + var files = Directory.GetFiles(@"../../../Data/"); + Parallel.ForEach(files, file => + { + //Open the file as Stream + FileStream SourceStream = File.Open(file, FileMode.Open, FileAccess.Read); + //Loads file stream into Word document + WordDocument srcDoc = new WordDocument(SourceStream, FormatType.Automatic); + //Instantiation of DocIORenderer for Word to PDF conversion + DocIORenderer renderer = new DocIORenderer(); + //Converts Word document into PDF document + PdfDocument pdfDocument = renderer.ConvertToPDF(srcDoc); + //Saves the PDF file + FileStream outputStream = new FileStream(@file + ".pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite); + pdfDocument.Save(outputStream); + // Dispose the objects + pdfDocument.Close(true); + srcDoc.Close(); + renderer.Dispose(); + SourceStream.Dispose(); + outputStream.Dispose(); + }); + Console.WriteLine("Process Completed!!"); + } + } +} diff --git a/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Word-to-PDF-Batch-process.csproj b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Word-to-PDF-Batch-process.csproj new file mode 100644 index 000000000..77d6a1ea6 --- /dev/null +++ b/Word-to-PDF-Conversion/Word-to-PDF-Batch-process/.NET-Standard/Word-to-PDF-Batch-process/Word-to-PDF-Batch-process.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp2.1 + Word_to_PDF_Batch_process + + + + + + +