Hi,
I’m trying to convert html to pdf document with a form inside. But after I have converted and flatten the form the style/css for the input boxes is different. Is there any way to retain exactly how the page looks?
Kind Regards,
Diogo Gomes
Hi,
I’m trying to convert html to pdf document with a form inside. But after I have converted and flatten the form the style/css for the input boxes is different. Is there any way to retain exactly how the page looks?
Kind Regards,
Diogo Gomes
Thank you for contacting support.
I would like to request you to please share the source HTML file along with other necessary resources including images, CSS file etc, if any, as a zipped file. Please also share generated PDF file and the code snippet that you are using for this conversion, so that we may investigate further to help you out.
Aspose.zip (146.8 KB)
Please find the example attached, as requested. let me know if you need anything else.
Thanks
Diogo
Thank you for sharing requested data.
I have worked with the documents shared by you and have observed better PDF rendered by Aspose.Pdf. All the text appears exactly the same as on the HTML page. Only difference is the fill color of fields and the border of those fields. I have attached the generated PDF file for your kind reference HTMLPage_17.12.pdf. Please let us know if this PDF file is fine or if you want us to further improve this rendering. Below is the sample code I have used for this conversion.
HtmlLoadOptions options = new HtmlLoadOptions(@"D:\djgomes\Aspose\");
// Load HTML file
Document doc = new Document(@"D:\djgomes\Aspose\HTMLPage.html", options);
// Save HTML file
doc.Save(@"D:\djgomes\Aspose\HTMLPage_17.12.pdf");
I hope this will be helpful. Please let us know if you need any further assistance.
Thanks for the answer, however the html page will be coming trough as a URL and the pdf still needs to be read only. The issue is after flattening the pdf I lose the css that the input fields have. Is there anyway to keep the css or change it to the one bellow?
.Form input.ReadOnly{
border: 1px solid #ccc;
box-sizing: border-box;
color: #666;
font-size: 14px;
vertical-align: middle;
background-color: #fff;
}
AsposeFormating.png (21.2 KB)
Many thanks,
Diogo
I would like to request you to please share a narrowed down sample web application reproducing the issue so that we may reproduce it exactly the way you are facing it. Make sure that the path to your resource files e.g css, images etc, in the constructor of HtmlLoadOptions class, is getting set properly as in line of code below:
HtmlLoadOptions options = new HtmlLoadOptions(ssOptionsUrl);
If you are referring to make this change in the HTML file then please share an updated HTML file as a zipped file to let us investigate this scenario.
To make a PDF file read only, you may set document privileges as in the code below, instead of flattening the PDF document.
Document pdfDocument = new Document(@"D:\djgomes\Aspose\HTMLPage_17.12.pdf");
// Instantiate Document Privileges object
// Apply restrictions on all privileges
DocumentPrivilege documentPrivilege = DocumentPrivilege.ForbidAll;
//Instantiate PdfFileSecurity object
PdfFileSecurity fileSecurity = new PdfFileSecurity(pdfDocument);
//Set privileges
fileSecurity.SetPrivilege(documentPrivilege);
//Save secured pdf
pdfDocument.Save(@"D:\djgomes\Aspose\HTMLPage_17.12_Secured.pdf");
Please share requested data if the issue persists, so that we may proceed further to help you out.