Hello,
We are converting the one of our form html into pdf. We were using the attached code (Program.cs) since many years, but one of our customer came with an issue that the generate pdf is editable, need to flattern. I didn’t find the ways to flattern the output pdf file in Aspose HTML component. Can you please help us here? I have attached the required files.
Program.zip (764 Bytes)
form.zip (962 Bytes)
@srinudhulipalla
We have logged a ticket in our issue tracking system to flatten HTML form fields as HTMLNET-3921. We will inform you via this forum thread once there is an update available on it. We apologize for your inconvenience.
However, you can use Aspose.PDF to achieve your requirement after converting HTML to PDF. Please read the following article.
How to Flatten PDF Form Fields in C#
@srinudhulipalla
We have implemented a new option that allows you to flatten form fields in a PDF document. An example of its usage is shown in the following code snippet.
Please use this code example with the next version of Aspose.HTML for .NET 22.12. We will inform you once new version of Aspose.HTML is available.
string customizedHTML = File.ReadAllText(@"C:\temp\form.html");
MemoryStream outStream = new MemoryStream();
// Save the document to stream.
using (var document = new Aspose.Html.HTMLDocument(customizedHTML.ToString(), @"C:\inetpub\wwwroot\cDevWorkflow\"))
{
// Create the PDF Device and specify the output file to render
using (var device = new Aspose.Html.Rendering.Pdf.PdfDevice(outStream))
{
device.Options.PageSetup.AnyPage.Margin = new Aspose.Html.Drawing.Margin(0, 0, 0, 0);
device.Options.PageSetup.AdjustToWidestPage = true;
device.Options.Css.MediaType = MediaType.Screen;
// Flatten all form fields
device.Options.FormFieldBehaviour = FormFieldBehaviour.Flattened;
// Render HTML to PDF
document.RenderTo(device);
byte[] pdfBytes = outStream.ToArray();
string filePath = @"C:\temp\output.pdf";
using (FileStream oSourceStream = File.Create(filePath))
{
oSourceStream.Seek(0, SeekOrigin.End);
oSourceStream.Write(pdfBytes, 0, pdfBytes.Length);
}
}
}
The issues you have found earlier (filed as HTMLNET-3921) have been fixed in this update. This message was posted using Bugs notification tool by avpavlysh