htmlsupporttest.zip (5.9 KB)
SupportTestPDF.zip (57.3 KB)
.Attached is a zip with the html file and a zip file with the file converted to PDF.
Notice the second page of the PDF file generated is not displayed correctly.
Thanks
htmlsupporttest.zip (5.9 KB)
SupportTestPDF.zip (57.3 KB)
.Attached is a zip with the html file and a zip file with the file converted to PDF.
Notice the second page of the PDF file generated is not displayed correctly.
Thanks
We were able to reproduce the issue in our environment while testing the scenario with latest version of the API. Hence, an issue as HTMLNET-3233 has been logged in our issue tracking system for the sake of correction. We will further look into its details and let you know once it is rectified. Please be patient and spare us some time.
We are sorry for the inconvenience.
I understand that Aspose should be able to convert an HTML file to PDF.
That was the purpose of buying the license.
Can you please send me code that will convert the html file that I sent you to PDF.
The PDF including the second page should display as it appears in the html file.
Thank you.
We are afraid that we could not fully understand your inquiry. The code to convert HTML to PDF has already been shared in this forum thread in your first post. We also used the same code snippet for testing. Please clarify what else functionality you want to perform using the API?
The code that was used created a pdf with the second page not displaying correctly.
You therefore logged an issue. Do you have code that would convert the html file that I sent to PDF correctly? There are many ways to convert Html to PDf in Aspose and I’d like to see code that accomplished that.
The api should be able to do that. Please let me know If the Aspose API cannot convert the html to PDF correctly. It does not have to be on one page. Each page can be an A4.
Thank you.
We tried using both Aspose.PDF and Aspose.Words (as they both offer HTML to PDF Conversion) but, output PDF was not correct. Please also note that Aspose.HTML is specialized to deal with HTML documents and we are already working on it to improve the conversion feature.
Furthermore, we tried to convert the HTML to a Single Page PDF document, and the output result was better using Aspose.PDF. Please check the below code snippet and attached output PDF:
Aspose.Pdf.HtmlLoadOptions objLoadOptions = new Aspose.Pdf.HtmlLoadOptions();
objLoadOptions.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
objLoadOptions.IsRenderToSinglePage = true;
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "htmlsupporttest.html", objLoadOptions);
doc.Save(dataDir + "test.pdf", SaveFormat.Pdf);
test.pdf (155.9 KB)
Thank you for sending that code.
It works if I don’t have custom fonts referenced in the style sheet of the html page.
I get the error ’ Font embedding is prohibited because of font license restrictions* if I convert the html t to PDF using Apsose.PDf as you do above.
If I use Aspose.Html.Converters.Converter.ConvertHTML, I do not get an error and the fonts show up correctly.
How can I get the fonts or at least not get the error when using the code you sent using Aspose.PDF?
(I do not want to use the Aspose.Html because radio buttons do not show when opening the PDF in Acrobat reader.)
Thanks
With Aspose.PDF, please try to use the Document.DisableFontLicenseVerifications = true; property after initializing the Document as below in order to prevent the fonts related exception:
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "htmlsupporttest.html", objLoadOptions);
doc.DisableFontLicenseVerifications = true;
I get the error ‘Font embedding is prohibited because of font license restrictions’ already on the first line you sent, the line that creates a new PDF document using the html page. The html page has the custom fonts so it already generates an error.
My code now:
Dim doc As Aspose.Pdf.Document = New Aspose.Pdf.Document(htmlfilename, objLoadOptions)
doc.DisableFontLicenseVerifications = True
Is there a way to create the pdf file with no parameters, set the DisableFontLicenseVerifications to true,
and then add the html as the contents of the PDF document.
Dim doc As Aspose.Pdf.Document = New Aspose.Pdf.Document() 'no parameters
doc.DisableFontLicenseVerifications = True
Can you send me the code to convert the contents of the htm file and add it to doc - the PDF document.
Perhaps that would be a solution.
Thank you.
I tried the following code to add the html to the PDF created with no parameters. I get no errors. The fonts show correctly, but the PDF does NOT show correctly. (Radio buttons are in the wrong place, values of textboxes are in the wrong place etc.)
Can you let me know how I can create the PDF that will render the html correctly.
Dim doc As Aspose.Pdf.Document = New Aspose.Pdf.Document()
doc.DisableFontLicenseVerifications = True
Dim currpage As Page = doc.Pages.Add()
Dim htmlFrag1 As HtmlFragment = New HtmlFragment(File.ReadAllText(newhtmlfileOutOfProject))
currpage.Paragraphs.Add(htmlFrag1)
doc.Save(strDestinationFilePDF)
Thank you.
Can you please share your sample HTML page in .zip format with us? We will test the scenario in our environment and address it accordingly.
Attached is an html file .zip format.
Can you send me other code that will generate the PDF correctly.
I will need it to work with the custom fonts also.
Thank you.
htmlsupporttest.zip (5.8 KB)
While using the above code snippet with your recently shared HTML file, we did not notice any exception at our end. The generated output PDF is also attached for your reference. Furthermore, could you please make sure that all Windows Fonts are installed at your side properly. Also, please share complete environment details where you are using the API so that we can again try to reproduce the issue you are facing and share our feedback with you.
test.pdf (155.9 KB)
In the post above, you suggested that I use the following to avoid the error from the custom fonts.
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + “htmlsupporttest.html”, objLoadOptions);
doc.DisableFontLicenseVerifications = true;
The first line already generated an error when trying to create a doc from the html that contains the custom fonts, so I created a PDF document with no parameters and did the following to add the html to the document.I did not get error, but It did not render the html to the PDF correctly.
Here is the code:
Dim doc As Aspose.Pdf.Document = New Aspose.Pdf.Document()
doc.DisableFontLicenseVerifications = True
Dim currpage As Page = doc.Pages.Add()
Dim htmlFrag1 As HtmlFragment = New HtmlFragment(File.ReadAllText(newhtmlfileOutOfProject))
currpage.Paragraphs.Add(htmlFrag1)
doc.Save(strDestinationFilePDF)
The code you sent me in your last reply renders the html to PDF beautifully, but gives an exception if there are custom fonts. Please test the html file I sent you with this code. The file does not include custom fonts.
The code I sent you should work for custom fonts, but does not even convert from html to PDF without the custom fonts.
Thank you.
We understand your concerns. We request you to please share a sample HTML that has custom fonts references inside it. We did not face any issue while converting the HTML into PDF which you have shared in this forum thread so far.
Please share a sample HTML that has custom fonts references so that we can perform detailed testing on it and share our feedback with you accordingly.
Could you please try the code below to convert the html file I sent you.
The file does not have custom fonts and I’d like to add them after this converts correctly.
When I run the code, the PDF layout is not good.
Can you send me the output if it is correct. If not, can you send me the code that will convert it.
The code should include ‘doc.DisableFontLicenseVerifications = True’, so I can add custom fonts.
Dim doc As Aspose.Pdf.Document = New Aspose.Pdf.Document()
doc.DisableFontLicenseVerifications = True
Dim currpage As Page = doc.Pages.Add()
Dim htmlFrag1 As HtmlFragment = New HtmlFragment(File.ReadAllText(newhtmlfileOutOfProject))
currpage.Paragraphs.Add(htmlFrag1)
doc.Save(strDestinationFilePDF)
Thank you
We were able to notice that using the above code snippet, the layout of the output PDF was not correct. An issue as PDFNET-50216 has been logged in our issue tracking system for the sake of correction. We will look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.
We are sorry for the inconvenience.
The issues you have found earlier (filed as HTMLNET-3225) have been fixed in this update. This message was posted using Bugs notification tool by pavel.petrushechkin
We have added the new option which allows to create single page documents. The following code snippet shows how to use it:
using (var document = new Aspose.Html.HTMLDocument("input.htm"))
{
var options = new Aspose.Html.Saving.PdfSaveOptions();
options.PageSetup.PageLayoutOptions = PageLayoutOptions.FitToContentHeight;
Aspose.Html.Converters.Converter.ConvertHTML(document, options, "out.pdf");
}