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
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.14.36408.4 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Disable-Auto-Formatting-in-FormFields", "Disable-Auto-Formatting-in-FormFields\Disable-Auto-Formatting-in-FormFields.csproj", "{34749AFC-1835-4920-BB8C-CB1BA56D30DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{34749AFC-1835-4920-BB8C-CB1BA56D30DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34749AFC-1835-4920-BB8C-CB1BA56D30DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34749AFC-1835-4920-BB8C-CB1BA56D30DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34749AFC-1835-4920-BB8C-CB1BA56D30DC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FC101EA9-8443-4983-8315-FD8699DF19F9}
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>Disable_Auto_Formatting_in_FormFields</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,25 @@
using Syncfusion.Pdf.Parsing;

// Load the existing PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read));

// Access the form field named "email" from the PDF form
PdfLoadedField field = loadedDocument.Form.Fields["email"] as PdfLoadedField;

// Disable automatic formatting to prevent behaviors like JavaScript execution
loadedDocument.Form.DisableAutoFormat = true;

// Check if the field is a text box and assign a plain string value
if (field is PdfLoadedTextBoxField textBoxField)
{
// Set the text box value to a raw email string without formatting
textBoxField.Text = "12345@gmail.com";
}

// Save the modified PDF document to a new file using a file stream
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
loadedDocument.Save(outputStream);
}
// Close and dispose the document to release resources
loadedDocument.Close(true);
Loading