Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions PDF_conformance_with_tags/PDF_conformance_with_tags.sln
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="20.3.0.59" />
</ItemGroup>

</Project>
38 changes: 38 additions & 0 deletions PDF_conformance_with_tags/PDF_conformance_with_tags/Program.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
25 changes: 25 additions & 0 deletions create_accessible_PDF/create_accessible_PDF.sln
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions create_accessible_PDF/create_accessible_PDF/Program.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="20.3.0.59" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions create_autotag_PDF/create_autotag_PDF.sln
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions create_autotag_PDF/create_autotag_PDF/Program.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
12 changes: 12 additions & 0 deletions create_autotag_PDF/create_autotag_PDF/create_autotag_PDF.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="20.3.0.59" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions word_to_PDF_with_tags/word_to_PDF_with_tags.sln
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
33 changes: 33 additions & 0 deletions word_to_PDF_with_tags/word_to_PDF_with_tags/Program.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="20.3.0.59" />
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="20.3.0.59" />
</ItemGroup>

</Project>