diff --git a/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word.sln b/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word.sln new file mode 100644 index 0000000..687e641 --- /dev/null +++ b/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-fillable-PDF-from-Word", "Create-fillable-PDF-from-Word/Create-fillable-PDF-from-Word.csproj", "{E30CA867-4ADD-43D7-9BB6-BE0369E6FA71}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E30CA867-4ADD-43D7-9BB6-BE0369E6FA71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E30CA867-4ADD-43D7-9BB6-BE0369E6FA71}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E30CA867-4ADD-43D7-9BB6-BE0369E6FA71}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E30CA867-4ADD-43D7-9BB6-BE0369E6FA71}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {54A592B9-E6C5-4762-A50F-590624BD75BA} + EndGlobalSection +EndGlobal diff --git a/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Create-fillable-PDF-from-Word.csproj b/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Create-fillable-PDF-from-Word.csproj new file mode 100644 index 0000000..07ab41b --- /dev/null +++ b/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Create-fillable-PDF-from-Word.csproj @@ -0,0 +1,22 @@ + + + + Exe + net8.0 + Create_fillable_PDF_from_Word + + + + + + + + + Always + + + Always + + + + diff --git a/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Data/Template.docx b/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Data/Template.docx new file mode 100644 index 0000000..bd43f5b Binary files /dev/null and b/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Data/Template.docx differ diff --git a/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Output/.gitkeep b/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Output/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Program.cs b/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Program.cs new file mode 100644 index 0000000..e04aca9 --- /dev/null +++ b/Create-fillable-PDF-from-Word/.NET/Create-fillable-PDF-from-Word/Program.cs @@ -0,0 +1,37 @@ +using System.IO; +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIORenderer; +using Syncfusion.Pdf; + +namespace Create_fillable_PDF_from_Word +{ + class Program + { + static void Main(string[] args) + { + //Open the file as Stream. + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open)) + { + //Load an existing Word document. + using (WordDocument wordDocument = new WordDocument(fileStream, Syncfusion.DocIO.FormatType.Automatic)) + { + //Creates an instance of DocIORenderer. + using (DocIORenderer renderer = new DocIORenderer()) + { + //Sets true to preserve the Word document form field as editable PDF form field in PDF document. + renderer.Settings.PreserveFormFields = true; + //Converts Word document into PDF document. + using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument)) + { + //Save the PDF document to a file stream. + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) + { + pdfDocument.Save(outputStream); + } + } + } + } + } + } + } +} diff --git a/Images/Fillable-PDF.png b/Images/Fillable-PDF.png new file mode 100644 index 0000000..9cd6a4c Binary files /dev/null and b/Images/Fillable-PDF.png differ diff --git a/README.md b/README.md index d0c12b2..ec64287 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,54 @@ -# Create-fillable-PDF-from-Word-c-sharp -This repository contains the examples to create an fillable PDF from Word document in C# using Syncfusion .NET Word library +# Convert Word document with form fields into fillable PDF in C# + +This repository contains examples that illustrates how to convert Word document with form fields into fillable PDF programmatically in C#. The Syncfusion® [.NET Word library](https://www.syncfusion.com/document-processing/word-framework/net/word-library?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) (DocIO) create a fillable PDF from a Word Document with just few lines of code and also it does not require Microsoft Word application to be installed in the machine. + +## Key Features + +[Create fillable PDF from Word document](https://github.com/SyncfusionExamples/Create-fillable-PDF-from-Word-c-sharp/tree/master/Create-fillable-PDF) - Convert Word documents with form fields into fillable PDFs while preserving the form fields as editable + +

+Fillable PDF in C# +

+ +## Syncfusion® .NET Word Library +The Syncfusion® DocIO is a [.NET Word library](https://www.syncfusion.com/document-processing/word-framework/net/word-library?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) allows you to add advanced Word document processing functionalities to any .NET application and does not require Microsoft Word application to be installed in the machine. It is a non-UI component that provides a full-fledged document instance model similar to the Microsoft Office COM libraries to iterate with the document elements explicitly and perform necessary manipulation. + +Take a moment to peruse the [documentation](https://help.syncfusion.com/document-processing/word/word-library/net/overview?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), where you can find basic Word document processing options along with the features like [mail merge](https://help.syncfusion.com/document-processing/word/word-library/net/working-with-mail-merge?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [merge](https://help.syncfusion.com/document-processing/word/word-library/net/word-document/merging-word-documents?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [split](https://help.syncfusion.com/document-processing/word/word-library/net/word-document/split-word-documents?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) and [compare documents](https://help.syncfusion.com/document-processing/word/word-library/net/word-document/compare-word-documents?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [find and replace](https://help.syncfusion.com/document-processing/word/word-library/net/working-with-find-and-replace?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) text in the Word document, [protect](https://help.syncfusion.com/document-processing/word/word-library/net/working-with-security?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) the Word documents, and most importantly, the [PDF](https://help.syncfusion.com/document-processing/word/conversions/word-to-pdf/overview?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) and [Image](https://help.syncfusion.com/document-processing/word/conversions/word-to-image/overview?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) conversions with code examples. + +Compatible Microsoft Word Versions +---------------------------------- + +* Microsoft Word 97-2003 +* Microsoft Word 2007 +* Microsoft Word 2010 +* Microsoft Word 2013 +* Microsoft Word 2016 +* Microsoft Word 2019 +* Microsoft 365 + +Supported File Formats +---------------------- + +* Creates, reads, and edits popular text file formats like [DOC](https://help.syncfusion.com/document-processing/word/word-library/net/word-file-formats#doc-to-docx-and-docx-to-doc?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), DOT, [DOCM](https://help.syncfusion.com/document-processing/word/word-library/net/word-file-formats#macros?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), DOTM, [DOCX](https://help.syncfusion.com/document-processing/word/word-library/net/word-file-formats#doc-to-docx-and-docx-to-doc?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [DOTX](https://help.syncfusion.com/document-processing/word/word-library/net/word-file-formats#templates?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [HTML](https://help.syncfusion.com/document-processing/word/word-library/net/html?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [RTF](https://help.syncfusion.com/document-processing/word/word-library/net/rtf?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [TXT](https://help.syncfusion.com/document-processing/word/word-library/net/text?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), and [XML (WordML)](https://help.syncfusion.com/document-processing/word/word-library/net/word-file-formats#word-processing-xml-xml?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples). +* Converts Word documents also to [PDF](https://help.syncfusion.com/document-processing/word/conversions/word-to-pdf/overview?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [Image](https://help.syncfusion.com/document-processing/word/conversions/word-to-image/overview?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), and [ODT](https://help.syncfusion.com/document-processing/word/word-library/net/word-to-odt?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) files. + +## How to run the examples +- Download this project to a location in your disk. +- Open the solution file using Visual Studio. +- Rebuild the solution to install the required NuGet packages. +- Run the application. + +## Resources + +- **Product page:** [Syncfusion® Word Framework](https://www.syncfusion.com/document-processing/word-framework/net?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) +- **Documentation:** [Protect and unprotect Word document using Syncfusion® Word library](https://help.syncfusion.com/document-processing/word/word-library/net/working-with-security) +- **GitHub Examples:** [Syncfusion® Word library examples](https://github.com/SyncfusionExamples/DocIO-Examples?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) +- **Online demo:** [Syncfusion® Word library - Online demos](https://ej2aspnetcore.azurewebsites.net/aspnetcore/word/wordtopdf#/material3) + +## Support and feedback +For any other queries, reach our [Syncfusion® support team](https://support.syncfusion.com/?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) or post the queries through the [community forums](https://www.syncfusion.com/forums?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples). + +Request new feature through [Syncfusion® feedback portal](https://www.syncfusion.com/feedback?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples). + +## License +This is a commercial product and requires a paid license for possession or use. Syncfusion's licensed software, including this component, is subject to the terms and conditions of [Syncfusion's EULA](https://www.syncfusion.com/license/studio/22.2.5/syncfusion_essential_studio_eula.pdf?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples). You can purchase a licnense [here](https://www.syncfusion.com/sales/products?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) or start a free 30-day trial [here](https://www.syncfusion.com/account/manage-trials/start-trials?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples).