Skip to content

Commit

Permalink
Committed the samples for the below topics.
Browse files Browse the repository at this point in the history
Working with Attachment
Working with Barcode
Working with Bookmarks
Working with Header and Footer
Working with Hyperlinks
Working with Image Extraction
Merge PDF documents
PDF Templates
Working with Security
Working with Shapes
Working with Table
Working with Text Extraction
  • Loading branch information
SowmiyaLoganathan committed Jul 28, 2022
1 parent 67c05d9 commit 334c2a2
Show file tree
Hide file tree
Showing 427 changed files with 9,608 additions and 0 deletions.
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 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adding-attachment-to-a-PDF-document", "Adding-attachment-to-a-PDF-document\Adding-attachment-to-a-PDF-document.csproj", "{CF6C4C9C-A9F6-4C5B-90E7-046DA33765CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CF6C4C9C-A9F6-4C5B-90E7-046DA33765CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF6C4C9C-A9F6-4C5B-90E7-046DA33765CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF6C4C9C-A9F6-4C5B-90E7-046DA33765CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF6C4C9C-A9F6-4C5B-90E7-046DA33765CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3B9561AB-79AC-439B-862F-30C4E017A13C}
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>net6.0</TargetFramework>
<RootNamespace>Adding_attachment_to_a_PDF_document</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.NET" Version="20.1.0.61" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!!!
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// See https://aka.ms/new-console-template for more information

using Syncfusion.Pdf;
using Syncfusion.Pdf.Interactive;

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

//Get stream from an existing PDF document.
Stream fileStream = new FileStream(Path.GetFullPath("../../../Input.txt"), FileMode.Open, FileAccess.Read);

//Creates an attachment with properties.
PdfAttachment attachment = new PdfAttachment("Input.txt", fileStream);
attachment.ModificationDate = DateTime.Now;
attachment.Description = "Input.txt";
attachment.MimeType = "application/txt";

//Adds the attachment to the document.
document.Attachments.Add(attachment);

//Create file stream.
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../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,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adding-the-attachments-to-an-existing-PDF-document", "Adding-the-attachments-to-an-existing-PDF-document\Adding-the-attachments-to-an-existing-PDF-document.csproj", "{700076D0-515D-452C-8A48-1DFC8E4E5EE8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{700076D0-515D-452C-8A48-1DFC8E4E5EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{700076D0-515D-452C-8A48-1DFC8E4E5EE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{700076D0-515D-452C-8A48-1DFC8E4E5EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{700076D0-515D-452C-8A48-1DFC8E4E5EE8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {88283A14-1DB2-40F3-A2B0-25DEB81C9713}
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>net6.0</TargetFramework>
<RootNamespace>Adding_the_attachments_to_an_existing_PDF_document</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.NET" Version="20.1.0.61" />
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!!!
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// See https://aka.ms/new-console-template for more information

using Syncfusion.Pdf.Interactive;
using Syncfusion.Pdf.Parsing;

//Get stream from an existing PDF document.
FileStream docStream = new FileStream(Path.GetFullPath("../../../Input.pdf"), FileMode.Open, FileAccess.Read);

//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);

//Get stream from the text file.
Stream fileStream = new FileStream(Path.GetFullPath("../../../Input.txt"), FileMode.Open, FileAccess.Read);

//Creates an attachment.
PdfAttachment attachment = new PdfAttachment("Input.txt", fileStream);
attachment.ModificationDate = DateTime.Now;
attachment.Description = "Input.txt";
attachment.MimeType = "application/txt";

//Create attachment.
if (loadedDocument.Attachments == null)
loadedDocument.CreateAttachment();

//Add the attachment to the document.
loadedDocument.Attachments.Add(attachment);

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

//Close the document.
loadedDocument.Close(true);
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 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Extract-and-saving-an-attachment-to-the-disk", "Extract-and-saving-an-attachment-to-the-disk\Extract-and-saving-an-attachment-to-the-disk.csproj", "{C4D05435-AB1B-427A-983A-209165254A9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C4D05435-AB1B-427A-983A-209165254A9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4D05435-AB1B-427A-983A-209165254A9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4D05435-AB1B-427A-983A-209165254A9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4D05435-AB1B-427A-983A-209165254A9B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BF66796C-CA28-409C-BB42-942B9FAE96AE}
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>net6.0</TargetFramework>
<RootNamespace>Extract_and_saving_an_attachment_to_the_disk</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.NET" Version="20.1.0.61" />
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!!!
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// See https://aka.ms/new-console-template for more information

using Syncfusion.Pdf.Interactive;
using Syncfusion.Pdf.Parsing;

//Get stream from the existing PDF document.
FileStream docStream = new FileStream(Path.GetFullPath("../../../Input.pdf"), FileMode.Open, FileAccess.Read);

//Load the PDF document.
PdfLoadedDocument document = new PdfLoadedDocument(docStream);

//Iterates the attachments.
foreach (PdfAttachment attachment in document.Attachments)
{
//Extracts the attachment and saves it to the disk.
FileStream s = new FileStream(Path.GetFullPath("../../../"+ attachment.FileName), FileMode.Create);
s.Write(attachment.Data, 0, attachment.Data.Length);
s.Dispose();
}

//Close the document.
document.Close(true);
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 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Remove-attachment-from-an-existing-PDF-document", "Remove-attachment-from-an-existing-PDF-document\Remove-attachment-from-an-existing-PDF-document.csproj", "{34FD36EF-4563-494D-9263-5FB50868116D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{34FD36EF-4563-494D-9263-5FB50868116D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34FD36EF-4563-494D-9263-5FB50868116D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34FD36EF-4563-494D-9263-5FB50868116D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34FD36EF-4563-494D-9263-5FB50868116D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2FAE4116-4E4E-429E-8A99-36D22FAF0EF1}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// See https://aka.ms/new-console-template for more information

using Syncfusion.Pdf.Parsing;

//Get stream from the existing PDF document.
FileStream docStream = new FileStream(Path.GetFullPath("../../../Input.pdf"), FileMode.Open, FileAccess.Read);

//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);

//Removes an attachment.
loadedDocument.Attachments.RemoveAt(0);

//PdfAttachment attachment = document.Attachments[0];
//document.Attachments.Remove(attachment);

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

//Close the document.
loadedDocument.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>net6.0</TargetFramework>
<RootNamespace>Remove_attachment_from_an_existing_PDF_document</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.NET" Version="20.1.0.61" />
</ItemGroup>

</Project>
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 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add-a-barcode-to-the-PDF-document-without-displaying-text", "Add-a-barcode-to-the-PDF-document-without-displaying-text\Add-a-barcode-to-the-PDF-document-without-displaying-text.csproj", "{BBB11B62-92CE-4BA8-95D7-E331F726F322}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BBB11B62-92CE-4BA8-95D7-E331F726F322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBB11B62-92CE-4BA8-95D7-E331F726F322}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBB11B62-92CE-4BA8-95D7-E331F726F322}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBB11B62-92CE-4BA8-95D7-E331F726F322}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {97341A8D-CC6B-42B7-A462-0EE36DF8AEE2}
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>net6.0</TargetFramework>
<RootNamespace>Add_a_barcode_to_the_PDF_document_without_displaying_text</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.NET" Version="20.1.0.61" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// See https://aka.ms/new-console-template for more information

using Syncfusion.Drawing;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Barcode;

//Creating new PDF Document.
PdfDocument document = new PdfDocument();

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

//Create a new instance for the Codabar barcode.
PdfCode39Barcode barcode = new PdfCode39Barcode();

//Set the barcode location.
barcode.Location = new PointF(10, 10);

//Set the barcode text.
barcode.Text = "123456789";

//Disable the barcode text.
barcode.TextDisplayLocation = TextLocation.None;

//Printing barcode on to the PDF document.
barcode.Draw(page);

//Create file stream.
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the PDF document to file stream.
document.Save(outputFileStream);
}

//Close the document.
document.Close(true);


Loading

0 comments on commit 334c2a2

Please sign in to comment.