-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
920569 Added widget annotation sample.
- Loading branch information
1 parent
a8654b9
commit b0d3700
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...e-widget-annotation-in-PDF-document/.NET/Modify-the-widget-annotation-in-PDF-document.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.11.35327.3 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modify-the-widget-annotation-in-PDF-document", "Modify-the-widget-annotation-in-PDF-document\Modify-the-widget-annotation-in-PDF-document.csproj", "{CCB9348A-9780-471A-B1D8-24302CE07ED7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{CCB9348A-9780-471A-B1D8-24302CE07ED7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CCB9348A-9780-471A-B1D8-24302CE07ED7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CCB9348A-9780-471A-B1D8-24302CE07ED7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CCB9348A-9780-471A-B1D8-24302CE07ED7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {2BEE5587-7C68-4AA1-B722-EC1E82301ABA} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+213 KB
...notation-in-PDF-document/.NET/Modify-the-widget-annotation-in-PDF-document/Data/Input.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
...the-widget-annotation-in-PDF-document/Modify-the-widget-annotation-in-PDF-document.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>Modify_the_widget_annotation_in_PDF_document</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Empty file.
37 changes: 37 additions & 0 deletions
37
...t-annotation-in-PDF-document/.NET/Modify-the-widget-annotation-in-PDF-document/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Syncfusion.Pdf.Interactive; | ||
using Syncfusion.Pdf.Parsing; | ||
using Syncfusion.Pdf; | ||
|
||
//Load the PDF document. | ||
FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); | ||
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); | ||
// Loop through each page in the loaded PDF document. | ||
foreach (PdfLoadedPage page in loadedDocument.Pages) | ||
{ | ||
// Access the form within the loaded document. | ||
PdfLoadedForm form = loadedDocument.Form; | ||
// Check if the forms are null. | ||
if (form == null) | ||
{ | ||
// Loop through each annotation on the current page. | ||
foreach (PdfLoadedAnnotation annot in page.Annotations) | ||
{ | ||
// Check if the annotation is a widget annotation. | ||
if (annot is PdfLoadedWidgetAnnotation) | ||
{ | ||
// Cast the annotation to a PdfLoadedWidgetAnnotation type. | ||
PdfLoadedWidgetAnnotation widget = annot as PdfLoadedWidgetAnnotation; | ||
// Set the widget's text value to "true". | ||
widget.Text = "true"; | ||
} | ||
} | ||
} | ||
} | ||
//Create file stream. | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) | ||
{ | ||
//Save the PDF document to file stream. | ||
loadedDocument.Save(outputFileStream); | ||
} | ||
//Close the document. | ||
loadedDocument.Close(true); |