Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Jun 21, 2024 8:45 am

Dear team,
I am having a html with form fields and I tried to convert it into a pdf using below code and it is converted fine. but no form fields read from html into PDF. please do the needful.

<form action="">
<fieldset>

<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br><br>
</fieldset>
</form>

public string htmltopdf(string htmlFileinput)
{
string htmlString = File.ReadAllText(htmlFileinputpath);
Spire.License.LicenseProvider.SetLicenseKey(SpireLicenseKey);

Spire.Pdf.HtmlConverter.Qt.HtmlConverter.PluginPath = SpirePluginsPath;

// Spire.Pdf.HtmlConverter.Qt.HtmlConverter.Convert(htmlFileinput, strOutputPDFFileName, true, 10 * 1000, new SizeF(612, 792), new Spire.Pdf.Graphics.PdfMargins(3, 3, 3, 10));
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.Convert(htmlString, strOutputPDFFileName, true, 100000, new Size(1080, 1000), new Spire.Pdf.Graphics.PdfMargins(3, 3, 3, 10), Spire.Pdf.HtmlConverter.LoadHtmlType.SourceCode);

System.Diagnostics.Process.Start(strOutputPDFFileName);
return strOutputPDFFileName;
}

ushanandhini_1297
 
Posts: 16
Joined: Mon Apr 20, 2015 11:34 am

Fri Jun 21, 2024 10:23 am

Hello,

Thanks for your inquiry.
Do you want to keep the form fields in the pdf file? If so, sorry, the feature you mentioned is not supported at the moment. Even if you convert the html to pdf in the browser, the form fields cannot be preserved, only the values ​​in the form will be preserved. If there is any misunderstanding, please feel free to write back.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF