diff --git a/PDF_conformance_with_tags/PDF_conformance_with_tags.sln b/PDF_conformance_with_tags/PDF_conformance_with_tags.sln new file mode 100644 index 0000000..2df329e --- /dev/null +++ b/PDF_conformance_with_tags/PDF_conformance_with_tags.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32901.82 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDF_conformance_with_tags", "PDF_conformance_with_tags\PDF_conformance_with_tags.csproj", "{3932D5D1-E9AC-4FAC-9EB6-EBB739FF2BE3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3932D5D1-E9AC-4FAC-9EB6-EBB739FF2BE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3932D5D1-E9AC-4FAC-9EB6-EBB739FF2BE3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3932D5D1-E9AC-4FAC-9EB6-EBB739FF2BE3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3932D5D1-E9AC-4FAC-9EB6-EBB739FF2BE3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C39C3311-9FD3-4DEA-9AC6-FDFA091D0066} + EndGlobalSection +EndGlobal diff --git a/PDF_conformance_with_tags/PDF_conformance_with_tags/Data/Arial.ttf b/PDF_conformance_with_tags/PDF_conformance_with_tags/Data/Arial.ttf new file mode 100644 index 0000000..ad7d8ea Binary files /dev/null and b/PDF_conformance_with_tags/PDF_conformance_with_tags/Data/Arial.ttf differ diff --git a/PDF_conformance_with_tags/PDF_conformance_with_tags/PDF_conformance_with_tags.csproj b/PDF_conformance_with_tags/PDF_conformance_with_tags/PDF_conformance_with_tags.csproj new file mode 100644 index 0000000..0f8fee4 --- /dev/null +++ b/PDF_conformance_with_tags/PDF_conformance_with_tags/PDF_conformance_with_tags.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/PDF_conformance_with_tags/PDF_conformance_with_tags/Program.cs b/PDF_conformance_with_tags/PDF_conformance_with_tags/Program.cs new file mode 100644 index 0000000..34e74c6 --- /dev/null +++ b/PDF_conformance_with_tags/PDF_conformance_with_tags/Program.cs @@ -0,0 +1,38 @@ +using System; +using System.IO; +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + +namespace PDF_conformance_with_tags +{ + class Program + { + static void Main(string[] args) + { + //Create new PDF document. + using (PdfDocument doc = new PdfDocument(PdfConformanceLevel.Pdf_A3A)) + { + //Enable auto-tagging. + doc.AutoTag = true; + //Set the document title. + doc.DocumentInformation.Title = "PDF conformance"; + //Create new page. + PdfPage page = doc.Pages.Add(); + string text = "Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base."; + //Initialize the PDF text element. + PdfTextElement element = new PdfTextElement(text); + FileStream fontStream = new FileStream(@"../../../Data/Arial.ttf", FileMode.Open, FileAccess.Read); + PdfFont font = new PdfTrueTypeFont(fontStream, 14); + //Create font for the text element. + element.Font = font; + element.Brush = new PdfSolidBrush(new PdfColor(89, 89, 93)); + //Draw text element with tag. + element.Draw(page, new RectangleF(0, 0, page.Graphics.ClientSize.Width, 200)); + FileStream output = new FileStream("PDFA3a.pdf", FileMode.CreateNew); + //Save the document. + doc.Save(output); + } + } + } +} diff --git a/README.md b/README.md index a9d69a6..e7d0645 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,36 @@ -# create-accessible-pdf-csharp -This repository contains examples to create a new tagged PDF document and converting word to tagged PDF using Syncfusion PDF library. +# Create PDF Documents Using C# +The [Syncfusion .NET PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net) allows you can easily create a tagged PDF document. This repository contains examples to create a new tagged PDF document and converting word to tagged PDF using Syncfusion PDF library. + +Sample name | Description +--- | --- +[Simple accessible PDF](https://github.com/SyncfusionExamples/create-accessible-pdf-csharp/blob/master/create_accessible_PDF) | Create a simple accessible PDF document. +[Auto-tag PDF](https://github.com/SyncfusionExamples/create-accessible-pdf-csharp/blob/master/create_autotag_PDF) | Auto-tag feature to automatically tag PDF elements with the appropriate tag types. +[PDF conformance with tags](https://github.com/SyncfusionExamples/create-accessible-pdf-csharp/blob/master/PDF_conformance_with_tags) | Create a PDF conformance document with accessibility tags. +[Word to PDF document with tags](https://github.com/SyncfusionExamples/create-accessible-pdf-csharp/blob/master/word_to_PDF_with_tags) | Convert a Word to PDF document with tags. + +# 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 package. +* Run the application. + +# Resources +* **Product page:** [Syncfusion PDF Framework](https://www.syncfusion.com/document-processing/pdf-framework/net) +* **Documentation page:** [Syncfusion .NET PDF library](https://help.syncfusion.com/file-formats/pdf/overview) +* **Online demo:** [Syncfusion .NET PDF library - Online demos](https://ej2.syncfusion.com/aspnetcore/PDF/CompressExistingPDF#/bootstrap5) +* **Blog:** [Syncfusion .NET PDF library - Blog](https://www.syncfusion.com/blogs/category/pdf) +* **Knowledge Base:** [Syncfusion .NET PDF library - Knowledge Base](https://www.syncfusion.com/kb/windowsforms/pdf) +* **EBooks:** [Syncfusion .NET PDF library - EBooks](https://www.syncfusion.com/succinctly-free-ebooks) +* **FAQ:** [Syncfusion .NET PDF library - FAQ](https://www.syncfusion.com/faq/) + +# Support and feedback +* For any other queries, reach our [Syncfusion support team](https://www.syncfusion.com/support/directtrac/incidents/newincident?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/eula/es/?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). + +# About Syncfusion +Founded in 2001 and headquartered in Research Triangle Park, N.C., Syncfusion has more than 26,000+ customers and more than 1 million users, including large financial institutions, Fortune 500 companies, and global IT consultancies. + +Today, we provide 1600+ components and frameworks for web ([Blazor](https://www.syncfusion.com/blazor-components?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [ASP.NET Core](https://www.syncfusion.com/aspnet-core-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [ASP.NET MVC](https://www.syncfusion.com/aspnet-mvc-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [ASP.NET WebForms](https://www.syncfusion.com/jquery/aspnet-webforms-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [JavaScript](https://www.syncfusion.com/javascript-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [Angular](https://www.syncfusion.com/angular-ui-components?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [React](https://www.syncfusion.com/react-ui-components?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [Vue](https://www.syncfusion.com/vue-ui-components?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), and [Flutter](https://www.syncfusion.com/flutter-widgets?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples)), mobile ([Xamarin](https://www.syncfusion.com/xamarin-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [Flutter](https://www.syncfusion.com/flutter-widgets?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [UWP](https://www.syncfusion.com/uwp-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), and [JavaScript](https://www.syncfusion.com/javascript-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples)), and desktop development ([WinForms](https://www.syncfusion.com/winforms-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [WPF](https://www.syncfusion.com/wpf-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [WinUI(Preview)](https://www.syncfusion.com/winui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [Flutter](https://www.syncfusion.com/flutter-widgets?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) and [UWP](https://www.syncfusion.com/uwp-ui-controls?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples)). We provide ready-to-deploy enterprise software for dashboards, reports, data integration, and big data processing. Many customers have saved millions in licensing fees by deploying our software. diff --git a/create_accessible_PDF/create_accessible_PDF.sln b/create_accessible_PDF/create_accessible_PDF.sln new file mode 100644 index 0000000..5ed45d2 --- /dev/null +++ b/create_accessible_PDF/create_accessible_PDF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32901.82 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "create_accessible_PDF", "create_accessible_PDF\create_accessible_PDF.csproj", "{545ED43D-5EE9-45B7-BBEA-4DE5F0E679BC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {545ED43D-5EE9-45B7-BBEA-4DE5F0E679BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {545ED43D-5EE9-45B7-BBEA-4DE5F0E679BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {545ED43D-5EE9-45B7-BBEA-4DE5F0E679BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {545ED43D-5EE9-45B7-BBEA-4DE5F0E679BC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BA9C2C03-E6AC-46E6-BC19-693E13AD943A} + EndGlobalSection +EndGlobal diff --git a/create_accessible_PDF/create_accessible_PDF/Program.cs b/create_accessible_PDF/create_accessible_PDF/Program.cs new file mode 100644 index 0000000..62440f4 --- /dev/null +++ b/create_accessible_PDF/create_accessible_PDF/Program.cs @@ -0,0 +1,41 @@ +using System; +using System.IO; +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + +namespace create_accessible_PDF +{ + class Program + { + static void Main(string[] args) + { + + //Create new PDF document. + using (PdfDocument doc = new PdfDocument()) + { + //Set the document title. + doc.DocumentInformation.Title = "PdfTextElement"; + //Create a new page. + PdfPage page = doc.Pages.Add(); + //Initialize the structure element with tag type paragraph. + PdfStructureElement structureElement = new PdfStructureElement(PdfTagType.Paragraph); + //Represents the text that is the exact replacement for PdfTextElement. + structureElement.ActualText = "Simple paragraph element"; + string text = "Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European, and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base."; + //Initialize the PDF text element. + PdfTextElement element = new PdfTextElement(text); + //Adding tag to the text element. + element.PdfTag = structureElement; + //Create font for the text element. + element.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); + element.Brush = new PdfSolidBrush(new PdfColor(89, 89, 93)); + //Draw text element with tag. + element.Draw(page, new RectangleF(0, 0, page.Graphics.ClientSize.Width, 200)); + FileStream output = new FileStream("TaggedPDF.pdf", FileMode.CreateNew); + //Save the document. + doc.Save(output); + } + } + } +} diff --git a/create_accessible_PDF/create_accessible_PDF/create_accessible_PDF.csproj b/create_accessible_PDF/create_accessible_PDF/create_accessible_PDF.csproj new file mode 100644 index 0000000..0f8fee4 --- /dev/null +++ b/create_accessible_PDF/create_accessible_PDF/create_accessible_PDF.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/create_autotag_PDF/create_autotag_PDF.sln b/create_autotag_PDF/create_autotag_PDF.sln new file mode 100644 index 0000000..b7496c9 --- /dev/null +++ b/create_autotag_PDF/create_autotag_PDF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32901.82 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "create_autotag_PDF", "create_autotag_PDF\create_autotag_PDF.csproj", "{5CD8C5CC-5665-44A4-A6A4-035D742A6ED5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5CD8C5CC-5665-44A4-A6A4-035D742A6ED5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5CD8C5CC-5665-44A4-A6A4-035D742A6ED5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5CD8C5CC-5665-44A4-A6A4-035D742A6ED5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5CD8C5CC-5665-44A4-A6A4-035D742A6ED5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CD9B2802-8523-4BE8-A1E2-6138269494AC} + EndGlobalSection +EndGlobal diff --git a/create_autotag_PDF/create_autotag_PDF/Program.cs b/create_autotag_PDF/create_autotag_PDF/Program.cs new file mode 100644 index 0000000..3c7d39d --- /dev/null +++ b/create_autotag_PDF/create_autotag_PDF/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.IO; +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + +namespace create_autotag_PDF +{ + class Program + { + static void Main(string[] args) + { + using (PdfDocument doc = new PdfDocument()) + { + //Enable auto-tagging. + doc.AutoTag = true; + //Set the document title. + doc.DocumentInformation.Title = "PdfTextElement"; + //Create new page. + PdfPage page = doc.Pages.Add(); + string text = "Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base."; + //Initialize the PDF text element. + PdfTextElement element = new PdfTextElement(text); + //Create font for the text element. + element.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); + element.Brush = new PdfSolidBrush(new PdfColor(89, 89, 93)); + //Draw text element with tag. + element.Draw(page, new RectangleF(0, 0, page.Graphics.ClientSize.Width, 200)); + FileStream output = new FileStream("Auto-tagging.pdf", FileMode.CreateNew); + //Save the document. + doc.Save(output); + } + } + } +} diff --git a/create_autotag_PDF/create_autotag_PDF/create_autotag_PDF.csproj b/create_autotag_PDF/create_autotag_PDF/create_autotag_PDF.csproj new file mode 100644 index 0000000..0f8fee4 --- /dev/null +++ b/create_autotag_PDF/create_autotag_PDF/create_autotag_PDF.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/word_to_PDF_with_tags/word_to_PDF_with_tags.sln b/word_to_PDF_with_tags/word_to_PDF_with_tags.sln new file mode 100644 index 0000000..1fcaef5 --- /dev/null +++ b/word_to_PDF_with_tags/word_to_PDF_with_tags.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32901.82 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "word_to_PDF_with_tags", "word_to_PDF_with_tags\word_to_PDF_with_tags.csproj", "{A86C0EDD-6340-4B5C-B89C-7D9422056F1C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A86C0EDD-6340-4B5C-B89C-7D9422056F1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A86C0EDD-6340-4B5C-B89C-7D9422056F1C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A86C0EDD-6340-4B5C-B89C-7D9422056F1C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A86C0EDD-6340-4B5C-B89C-7D9422056F1C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FE770210-3226-40DA-8EC9-42FCD7319EEE} + EndGlobalSection +EndGlobal diff --git a/word_to_PDF_with_tags/word_to_PDF_with_tags/Data/DocToPDF.doc b/word_to_PDF_with_tags/word_to_PDF_with_tags/Data/DocToPDF.doc new file mode 100644 index 0000000..c568941 Binary files /dev/null and b/word_to_PDF_with_tags/word_to_PDF_with_tags/Data/DocToPDF.doc differ diff --git a/word_to_PDF_with_tags/word_to_PDF_with_tags/Program.cs b/word_to_PDF_with_tags/word_to_PDF_with_tags/Program.cs new file mode 100644 index 0000000..ed7cae9 --- /dev/null +++ b/word_to_PDF_with_tags/word_to_PDF_with_tags/Program.cs @@ -0,0 +1,33 @@ +using System; +using System.IO; +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIORenderer; +using Syncfusion.Pdf; + +namespace word_to_PDF_with_tags +{ + class Program + { + static void Main(string[] args) + { + //Opens the file as a stream. + FileStream docStream = new FileStream(@"../../../Data/DocToPDF.doc", FileMode.Open, FileAccess.Read); + //Loads file stream into Word document. + using (WordDocument wordDocument = new WordDocument(docStream, Syncfusion.DocIO.FormatType.Automatic)) + { + using (DocIORenderer render = new DocIORenderer()) + { + //Sets true to preserve document-structured tags in the converted PDF document. + render.Settings.AutoTag = true; + //Converts Word document into PDF document. + PdfDocument pdfDocument = render.ConvertToPDF(wordDocument); + //Saves the PDF file. + FileStream outputStream = new FileStream("output.pdf", FileMode.CreateNew); + pdfDocument.Save(outputStream); + //Closes the instance of PDF document object. + pdfDocument.Close(true); + } + } + } + } +} diff --git a/word_to_PDF_with_tags/word_to_PDF_with_tags/word_to_PDF_with_tags.csproj b/word_to_PDF_with_tags/word_to_PDF_with_tags/word_to_PDF_with_tags.csproj new file mode 100644 index 0000000..0b00ddb --- /dev/null +++ b/word_to_PDF_with_tags/word_to_PDF_with_tags/word_to_PDF_with_tags.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp3.1 + + + + + + + +