Skip to content

955040 Added FT page sample code #159

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
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}") = "Convert-HTML-to-PDF-document", "Convert-HTML-to-PDF-document\Convert-HTML-to-PDF-document.csproj", "{8C7649A5-76C7-4869-91AA-6D5F662AC198}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8C7649A5-76C7-4869-91AA-6D5F662AC198}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C7649A5-76C7-4869-91AA-6D5F662AC198}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C7649A5-76C7-4869-91AA-6D5F662AC198}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C7649A5-76C7-4869-91AA-6D5F662AC198}.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>Convert-HTML-to-PDF-document</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="29.1.41" />
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
using Syncfusion.Pdf.HtmlToPdf;

//Initialize the HTML to PDF converter.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();

//Convert URL to PDF document.
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");
//Create file stream.
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the PDF document
document.Save(fileStream);
}
//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}") = "Create-Fillable-PDF-Forms", "Create-Fillable-PDF-Forms\Create-Fillable-PDF-Forms.csproj", "{18D5CCA6-18F2-42EA-88B2-C776DCDEA246}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{18D5CCA6-18F2-42EA-88B2-C776DCDEA246}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18D5CCA6-18F2-42EA-88B2-C776DCDEA246}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18D5CCA6-18F2-42EA-88B2-C776DCDEA246}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18D5CCA6-18F2-42EA-88B2-C776DCDEA246}.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>Create-Fillable-PDF-Forms</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Syncfusion.Pdf.Parsing;

// Load the existing PDF document.
using (FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read))
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream))
{
// Create the form if it doesn't exist.
if (loadedDocument.Form == null)
loadedDocument.CreateForm();

// Fill in the name text box.
PdfLoadedTextBoxField name = loadedDocument.Form.Fields[1] as PdfLoadedTextBoxField;
name.Text = "John Milton";

// Fill in the email text box.
PdfLoadedTextBoxField email = loadedDocument.Form.Fields[2] as PdfLoadedTextBoxField;
email.Text = "[email protected]";

// Select a gender radio button (0 = first option).
PdfLoadedRadioButtonListField gender = loadedDocument.Form.Fields[3] as PdfLoadedRadioButtonListField;
gender.SelectedIndex = 0;

// Fill in the date of birth field.
PdfLoadedTextBoxField dob = loadedDocument.Form.Fields[0] as PdfLoadedTextBoxField;
dob.Text = "May 12, 2000";

// Select a country from the combo box.
PdfLoadedComboBoxField country = loadedDocument.Form.Fields[4] as PdfLoadedComboBoxField;
country.SelectedValue = "Alabama";

// Check the newsletter subscription box.
PdfLoadedCheckBoxField newsletter = loadedDocument.Form.Fields[5] as PdfLoadedCheckBoxField;
newsletter.Checked = true;

// Ensure proper rendering in PDF viewers.
loadedDocument.Form.SetDefaultAppearance(false);

// Save the updated PDF to a new file.
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
loadedDocument.Save(outputStream);
}

// Close the PDF document.
loadedDocument.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}") = "Generating-Accessible-PDF-document", "Generating-Accessible-PDF-document\Generating-Accessible-PDF-document.csproj", "{CFF443D6-AA37-4C7A-9DE7-334651E659DB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CFF443D6-AA37-4C7A-9DE7-334651E659DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CFF443D6-AA37-4C7A-9DE7-334651E659DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFF443D6-AA37-4C7A-9DE7-334651E659DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFF443D6-AA37-4C7A-9DE7-334651E659DB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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>Generating-Accessible-PDF-document</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,72 @@
using Syncfusion.Drawing;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;

// Create a new PDF document
using (PdfDocument document = new PdfDocument())
{
// Set document metadata
document.DocumentInformation.Title = "Tagged PDF with Top-Centered Image and Text";

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

// Load image stream
using (FileStream imgStream = new FileStream(Path.GetFullPath(@"Data/Image.jpg"), FileMode.Open, FileAccess.Read))
{
PdfBitmap image = new PdfBitmap(imgStream);

// Define desired image size
float imageWidth = 200;
float imageHeight = 100;

// Calculate X and Y to center image at the top
float pageWidth = page.Graphics.ClientSize.Width;
float imageX = (pageWidth - imageWidth) / 2;
float imageY = 20;

// Set the tag type and alternate text for accessibility
PdfStructureElement imageElement = new PdfStructureElement(PdfTagType.Figure)
{
AlternateText = "GreenTree"
};
image.PdfTag = imageElement;

// Draw the image at the top center
page.Graphics.DrawImage(image, new RectangleF(imageX, imageY, imageWidth, imageHeight));

// Add paragraph text below the image
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. "
+ "The company is known for its commitment to innovation, quality, and customer satisfaction, catering to both amateur and professional cycling enthusiasts.\n\n"
+ "In addition to bicycles, Adventure Works Cycles also provides a wide range of cycling accessories, apparel, and maintenance tools through retail and online platforms. "
+ "The company invests heavily in research and development to improve performance and safety in its products. "
+ "With an integrated global supply chain, efficient logistics operations, and a customer-centric approach, Adventure Works Cycles continues to be a recognized brand in the global cycling industry.";

// Create structure element for paragraph
PdfStructureElement paragraphStructure = new PdfStructureElement(PdfTagType.Paragraph)
{
ActualText = "Company introduction paragraph"
};

// Create and configure the text element
PdfTextElement textElement = new PdfTextElement(paragraphText)
{
PdfTag = paragraphStructure,
Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 12),
Brush = new PdfSolidBrush(new PdfColor(89, 89, 93))
};

// Draw the text below the image
float textY = imageY + imageHeight + 20;
textElement.Draw(page, new RectangleF(20, textY, pageWidth - 40, 400));
}

// Save the PDF document
using (FileStream outputFile = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
document.Save(outputFile);
}
}
22 changes: 22 additions & 0 deletions FT page/Protect-PDF-documents/.NET/Protect-PDF-documents.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}") = "Protect-PDF-documents", "Protect-PDF-documents\Protect-PDF-documents.csproj", "{1B2AC0AB-F0B6-4123-9A22-AD59C3A2C1BB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B2AC0AB-F0B6-4123-9A22-AD59C3A2C1BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B2AC0AB-F0B6-4123-9A22-AD59C3A2C1BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B2AC0AB-F0B6-4123-9A22-AD59C3A2C1BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B2AC0AB-F0B6-4123-9A22-AD59C3A2C1BB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Syncfusion.Pdf.Parsing;
using Syncfusion.Pdf.Security;

// Load the PDF document from a file stream
using (FileStream inputFileStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read))
{
// Load the PDF document
PdfLoadedDocument document = new PdfLoadedDocument(inputFileStream);
// Gets a security object for the document
PdfSecurity security = document.Security;
// Configure key size and encryption algorithm
security.KeySize = PdfEncryptionKeySize.Key256Bit;
security.Algorithm = PdfEncryptionAlgorithm.AES;
// Assign owner and user passwords
security.OwnerPassword = "owner123";
security.UserPassword = "user123";
// Save the PDF document in to a file stream
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
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>Protect-PDF-documents</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
22 changes: 22 additions & 0 deletions FT page/Split-PDF-files/.NET/Split-PDF-files-in-C#.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}") = "Split-PDF-files", "Split-PDF-files\Split-PDF-files.csproj", "{283A1CFF-09CC-44B3-89BA-FABA4425EC4C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{283A1CFF-09CC-44B3-89BA-FABA4425EC4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{283A1CFF-09CC-44B3-89BA-FABA4425EC4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{283A1CFF-09CC-44B3-89BA-FABA4425EC4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{283A1CFF-09CC-44B3-89BA-FABA4425EC4C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
Binary file not shown.
Empty file.
28 changes: 28 additions & 0 deletions FT page/Split-PDF-files/.NET/Split-PDF-files/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Syncfusion.Pdf;
using Syncfusion.Pdf.Parsing;

// Create the FileStream object to read the input PDF file
using (FileStream inputFileStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
// Load the PDF document from the input stream
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream))
{
// Iterate over the pages of the loaded document
for (int pageIndex = 0; pageIndex < loadedDocument.PageCount; pageIndex++)
{
// Create a new PdfDocument object to hold the output
using (PdfDocument outputDocument = new PdfDocument())
{
// Import the page from the loadedDocument to the outputDocument
outputDocument.ImportPage(loadedDocument, pageIndex);

// Create the FileStream object to write the output PDF file
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/" + pageIndex + ".pdf"), FileMode.Create, FileAccess.Write))
{
// Save the outputDocument into the outputFileStream
outputDocument.Save(outputFileStream);
}
}
}
}
}
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>Split-PDF-files</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Loading