Skip to content
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,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36221.1 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fillable-form-fields-from-HTML-to-PDF-Converter", "Fillable-form-fields-from-HTML-to-PDF-Converter\Fillable-form-fields-from-HTML-to-PDF-Converter.csproj", "{70A501A7-093A-4E77-AE84-1EDFE2A5243F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{70A501A7-093A-4E77-AE84-1EDFE2A5243F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70A501A7-093A-4E77-AE84-1EDFE2A5243F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70A501A7-093A-4E77-AE84-1EDFE2A5243F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70A501A7-093A-4E77-AE84-1EDFE2A5243F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FC5888A1-82B1-4C5C-AA60-36BBCD924490}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<title>Fillable PDF Form</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.form-container {
width: 400px;
margin: 100px auto;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
label {
display: block;
margin-top: 15px;
}
input, select {
width: 100%;
padding: 8px;
margin-top: 5px;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="form-container">
<h2>Job Application Form</h2>
<form>
<label for="name">Name:</label>
<input type="text" name="name" />

<label for="email">Email:</label>
<input type="email" name="email" />

<label for="gender">Gender:</label>
<select name="gender">
<option value="male">Male</option>
<option value="female">Female</option>
</select>

<label for="signature">Signature:</label>
<input type="text" name="signature" />
</form>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Syncfusion.Drawing;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Interactive;
using Syncfusion.Pdf.Parsing;

// Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
// Enable form conversion
BlinkConverterSettings settings = new BlinkConverterSettings
{
EnableForm = true
};
htmlConverter.ConverterSettings = settings;
// Convert the HTML file to a PDF document
using (PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html")))
{
// Set default appearance for form fields
document.Form.SetDefaultAppearance(false);

// Save the PDF document to a memory stream
using (MemoryStream stream = new MemoryStream())
{
// Load the saved PDF document
document.Save(stream);
// Load the PDF document containing form fields
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream);
// Fill the form fields
PdfLoadedForm form = loadedDocument.Form;
// Fill the "name" field
if (form.Fields["name"] is PdfLoadedTextBoxField nameField)
{
nameField.Text = "XYZ";
}
// Fill the "email" field
if (form.Fields["email"] is PdfLoadedTextBoxField emailField)
{
emailField.Text = "[email protected]";
}
// Select "Male" in the "gender" dropdown
if (form.Fields["gender"] is PdfLoadedComboBoxField genderField)
{
genderField.SelectedValue = "Male";
}
// Fill the "signature" field
if (form.Fields["signature"] is PdfLoadedTextBoxField signatureTextBox)
{
// Get the original field's position and page
RectangleF bounds = signatureTextBox.Bounds;
PdfPageBase page = signatureTextBox.Page;
// Remove the original textbox field
form.Fields.Remove(signatureTextBox);
// Create a new signature field at the same location
PdfSignatureField signatureField = new PdfSignatureField(page, "ClientSignature")
{
Bounds = bounds
};
// Add the new signature field to the form
form.Fields.Add(signatureField);
}
// Save the PDF document
loadedDocument.Save(Path.GetFullPath(@"Output/Output2.pdf"));
}
}
Loading