Skip to content

949285 Added Sample Code for 2025 Volume 1 Main Release PDF Features. #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2025
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
22 changes: 22 additions & 0 deletions Brushes/Hatch-brush/.NET/Hatch-brush.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hatch-brush", "Hatch-brush\Hatch-brush.csproj", "{43313999-B898-44C1-A495-D25C2280888A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{43313999-B898-44C1-A495-D25C2280888A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43313999-B898-44C1-A495-D25C2280888A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43313999-B898-44C1-A495-D25C2280888A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43313999-B898-44C1-A495-D25C2280888A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
15 changes: 15 additions & 0 deletions Brushes/Hatch-brush/.NET/Hatch-brush/Hatch-brush.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Hatch_brush</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Empty file.
28 changes: 28 additions & 0 deletions Brushes/Hatch-brush/.NET/Hatch-brush/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf;
using Syncfusion.Drawing;

//Create a new PDF document
PdfDocument document = new PdfDocument();
//Add a page to the document
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Define colors for the hatch brush
Color systemForeColor = Color.FromArgb(255, 255, 255, 0);
Color systemBackColor = Color.FromArgb(255, 78, 167, 46);

// Create a new PDF hatch brush with a pattern and colors
PdfHatchBrush pdfHatchBrush = new PdfHatchBrush(PdfHatchStyle.Plaid, new PdfColor(systemForeColor), new PdfColor(systemBackColor));

//Draw rectangle on the page
graphics.DrawRectangle(PdfPens.Black, pdfHatchBrush, new Rectangle(100, 100, 300, 200));

//Create file stream.
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the PDF document to file stream.
document.Save(outputFileStream);
}
//Close the document.
document.Close(true);
22 changes: 22 additions & 0 deletions Tagged PDF/Custom-Role-Mapping/.NET/Custom-Role-Mapping.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Custom-Role-Mapping", "Custom-Role-Mapping\Custom-Role-Mapping.csproj", "{F3023308-36C9-4327-877C-5CBF1D06AB72}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F3023308-36C9-4327-877C-5CBF1D06AB72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3023308-36C9-4327-877C-5CBF1D06AB72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3023308-36C9-4327-877C-5CBF1D06AB72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3023308-36C9-4327-877C-5CBF1D06AB72}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Custom_Role_Mapping</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Binary file not shown.
55 changes: 55 additions & 0 deletions Tagged PDF/Custom-Role-Mapping/.NET/Custom-Role-Mapping/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf;
using Syncfusion.Drawing;

// Create a new PDF document
PdfDocument document = new PdfDocument();

// Create a role map to define custom structure roles
PdfRoleMap roleMap = new PdfRoleMap();
roleMap.Add("WorkBook", "Document"); // Mapping "WorkBook" to "Document"
roleMap.Add("WorkSheet", "Sect"); // Mapping "WorkSheet" to "Sect"

// Define a custom structure type
string customStructureType = "WorkBook";
string standardStructureType = "";

// Try to get the standard structure type for the custom role
bool found = roleMap.TryGetStandardType(customStructureType, out standardStructureType);
document.StructureRoleMap = roleMap; // Assign role map to the document

// Set document metadata
document.DocumentInformation.Title = "Custom Role Map";

// Add a new page to the PDF
PdfPage page = document.Pages.Add();

// Create a custom structure element with a specified role
PdfStructureElement structureElement = new PdfStructureElement("WorkBook");
structureElement.ActualText = "Simple paragraph element"; // Set alternative text for accessibility

// Define the content text
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.";

// Create a text element and associate it with the structure element
PdfTextElement element = new PdfTextElement(text);
element.PdfTag = structureElement;

//Load the font file as stream
FileStream fontStream = new FileStream(Path.GetFullPath(@"Data/Font.ttf"), FileMode.Open, FileAccess.Read);

// Set font and color for the text
element.Font = new PdfTrueTypeFont(fontStream, 10);
element.Brush = new PdfSolidBrush(new PdfColor(89, 89, 93));

// Draw text on the page
PdfLayoutResult result = element.Draw(page, new RectangleF(0, 0, page.Graphics.ClientSize.Width, 200));

//Create file stream.
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the PDF document to file stream.
document.Save(outputFileStream);
}
//Close the document.
document.Close(true);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDF-for-Universal-Accessibility", "PDF-for-Universal-Accessibility\PDF-for-Universal-Accessibility.csproj", "{C4C14E31-D7E7-461D-BBE1-45E558A705B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C4C14E31-D7E7-461D-BBE1-45E558A705B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4C14E31-D7E7-461D-BBE1-45E558A705B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4C14E31-D7E7-461D-BBE1-45E558A705B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4C14E31-D7E7-461D-BBE1-45E558A705B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>PDF_for_Universal_Accessibility</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf;
using Syncfusion.Drawing;

//Create a new PDF document
PdfDocument document = new PdfDocument();

//Set Pdf File version 2.0
document.FileStructure.Version = PdfVersion.Version2_0;

//Set true to auto tag all elements in document
document.AutoTag = true;
document.DocumentInformation.Title = "PDF Universal Accessibility 2";

// Add a new page
PdfPage page = document.Pages.Add();

//Load the font file as stream
FileStream fontStream = new FileStream(Path.GetFullPath(@"Data/Font.ttf"), FileMode.Open, FileAccess.Read);

// Initialize the structure element with tag type paragraph
PdfStructureElement paragraphStructure = new PdfStructureElement(PdfTagType.Paragraph);

// Represents the text that is the exact replacement for PdfTextElement
paragraphStructure.ActualText = "Simple paragraph element";
string paragraphText = "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 textElement = new PdfTextElement(paragraphText);

// Adding tag to the text element
textElement.PdfTag = paragraphStructure;

// Create font for the text element
textElement.Font = new PdfTrueTypeFont(fontStream, 10);
textElement.Brush = new PdfSolidBrush(new PdfColor(89, 89, 93));

// Draw text element with tag
textElement.Draw(page, new RectangleF(0, 0, page.Graphics.ClientSize.Width, 200));

//Create file stream.
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the PDF document to file stream.
document.Save(outputFileStream);
}
//Close the document.
document.Close(true);
22 changes: 22 additions & 0 deletions Tagged PDF/Well-Tagged-PDF/.NET/Well-Tagged-PDF.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Well-Tagged-PDF", "Well-Tagged-PDF\Well-Tagged-PDF.csproj", "{27A4CC9D-7C18-4483-A89C-7A68D22AB5FC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{27A4CC9D-7C18-4483-A89C-7A68D22AB5FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27A4CC9D-7C18-4483-A89C-7A68D22AB5FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27A4CC9D-7C18-4483-A89C-7A68D22AB5FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27A4CC9D-7C18-4483-A89C-7A68D22AB5FC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
Empty file.
48 changes: 48 additions & 0 deletions Tagged PDF/Well-Tagged-PDF/.NET/Well-Tagged-PDF/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf;
using Syncfusion.Drawing;

//Create a new PDF document
PdfDocument document = new PdfDocument(PdfConformanceLevel.Pdf_A4);

//Set Pdf File version 2.0
document.FileStructure.Version = PdfVersion.Version2_0;

//Set true to auto tag all elements in document
document.AutoTag = true;
document.DocumentInformation.Title = "Well Tagged PDF";

// Add a new page
PdfPage page = document.Pages.Add();

//Load the font file as stream
FileStream fontStream = new FileStream(Path.GetFullPath(@"Data/Font.ttf"), FileMode.Open, FileAccess.Read);

// Initialize the structure element with tag type paragraph
PdfStructureElement paragraphStructure = new PdfStructureElement(PdfTagType.Paragraph);

// Represents the text that is the exact replacement for PdfTextElement
paragraphStructure.ActualText = "Simple paragraph element";
string paragraphText = "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 textElement = new PdfTextElement(paragraphText);

// Adding tag to the text element
textElement.PdfTag = paragraphStructure;

// Create font for the text element
textElement.Font = new PdfTrueTypeFont(fontStream, 10);
textElement.Brush = new PdfSolidBrush(new PdfColor(89, 89, 93));

// Draw text element with tag
textElement.Draw(page, new RectangleF(0, 0, page.Graphics.ClientSize.Width, 200));

//Create file stream.
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the PDF document to file stream.
document.Save(outputFileStream);
}
//Close the document.
document.Close(true);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Well_Tagged_PDF</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
22 changes: 22 additions & 0 deletions ZUGFeRD/Factur-X/.NET/Factur-X.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Factur-X", "Factur-X\Factur-X.csproj", "{48333744-D512-43D0-A937-20333130A1E1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{48333744-D512-43D0-A937-20333130A1E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48333744-D512-43D0-A937-20333130A1E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48333744-D512-43D0-A937-20333130A1E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48333744-D512-43D0-A937-20333130A1E1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading
Loading