reviewLetter.zip (1.4 KB)
We were unable to notice any issue while using following code snippet with Aspose.PDF for .NET 20.3:
var objLoadOptions = new Aspose.Pdf.HtmlLoadOptions(dataDir);
// Set Page Margins
objLoadOptions.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
var doc = new Aspose.Pdf.Document(dataDir + "reviewLetter.html", objLoadOptions);
doc.Save(dataDir + "out20.3.pdf");
out20.3.pdf (128.7 KB)
Would you please try using latest version with shared code snippet and in case you still face any issue, please feel free to let us know.
Thanks for quick response on this. Yes the recommended code worked for file from disk!
Now, what do we need to make it work with loading from stream? We got blank file when we tried.
Thanks.
Would you please share the code snippet with which you are converting HTML to PDF using streams. We will test the scenario in our environment and address it accordingly.
The original problem was that we I did not set HtmlLoadOptions, it is working by given it:
public byte[] GenerateByFile(string fileName)
{
var objLoadOptions = new Aspose.Pdf.HtmlLoadOptions(fileName);
// Set Page Margins
objLoadOptions.PageInfo.Margin = new Aspose.Pdf.MarginInfo(0, 0, 0, 0);
Document pdfDocument = new Document(fileName, objLoadOptions);
var outStream = new MemoryStream();
pdfDocument.Save(outStream);
var bytes = outStream.ToArray();
return bytes;
}
However, for our production requirement we have stream/data generated on the fly and in memory. The below code did not work when we tried to load it from stream. We understand the HtmlLoadOptions can load from file only and there must be another way.
public byte[] Generate(string bodyHtml)
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(bodyHtml);
writer.Flush();
var objLoadOptions = new Aspose.Pdf.HtmlLoadOptions();
// Set Page Margins
objLoadOptions.PageInfo.Margin = new Aspose.Pdf.MarginInfo(0, 0, 0, 0);
Document pdfDocument = new Document(stream, objLoadOptions);
var outStream = new MemoryStream();
pdfDocument.Save(outStream);
var bytes = outStream.ToArray();
return bytes;
}
//This will result a blank file.
We tested the scenario using streams as well and were unable to notice the issue. Please check the code snippet that we used:
StringBuilder htmlPage = new StringBuilder();
htmlPage.Append(File.ReadAllText(dataDir + "reviewLetter.html"));
byte[] bytes = Encoding.UTF8.GetBytes(htmlPage.ToString());
var streamHtml = new MemoryStream(bytes);
var objLoadOptions = new Aspose.Pdf.HtmlLoadOptions();
// Set Page Margins
objLoadOptions.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
var doc = new Aspose.Pdf.Document(streamHtml, objLoadOptions);
doc.Save(dataDir + "out20.3.pdf");
The HtmlLoadOptions takes an argument of the path where those resources are located which are being used in HTML content e.g. images.
Would you kindly share a sample console application which is able to replicate the issue. We will again test the scenario in our environment and address it accordingly.
Thanks for prompt responses and inputs!
The recommended code snippet worked.
Thanks!
It is good to know that given suggestions worked for you. Please keep using our API and in case you need further assistance, please feel free to ask.
Hi,
Please find attached the sample html and pdf generated from it. Why do we see the gray background above the name “Alexander Burgess TEST!” Is it because of the unlicensed version or due to some css/html not supported? Is there a list of non-supported css attributes?Documents.zip (645.5 KB)
Thanks.
We were able to notice the background issue even with licensed version of the API. The issue seems related to positioning of DIV elements in HTML. However, we need to investigate it further to determine the reasons of issue and rectify them. For the purpose, we have logged an issue as PDFNET-47933 in our issue tracking system. We will look into details of it and keep you posted with the status of its resolution. Please be patient and spare us some time.
We are sorry for the inconvenience.
Thanks for the information Asad. Looking forward to the solution.
Hi Asad,
Any update on the issue? I am attaching latest version of the HTML which has all use cases and generated pdf. Can you please take a look and provide information on what are the chances of addressing all challenges?
Appreciate the efforts put in by the team to help us finalize our choice for the component.
Regards.
AsposeIssues9Apr2020.zip (1.3 MB)
We would like to share with you that issue was logged under free support model where issues have low priority and are resolved on first come first serve basis. We have logged your concerns and other provided details along with the ticket and will surely inform you as soon as we make some definite progress towards its investigation/rectification. Please spare us some time.
Thanks for the reply. I understand the prioritization need for issues being reported for a software. Is there a way we can have visibility/idea on timeline with respected to ticket/issue you create for the Aspose team?
Also, I found that our organization already have license for Aspose but not able to use it because of the issues.
Regards.
Thanks for your inquiry.
The issue has been logged in our internal issue management system and its ticket ID has been integrated with the thread. We are afraid that you may not be able to access it except you can notice the issue status at the end of the post. Along with that, we will keep you informed with its rectification status within this forum thread.
Please update your internal ticket with latest files I sent as it covers additional use cases and issues.
Thanks.
Hi,
Is there any update on the issues reported? Any appx timeline you can provide based on internal prioritization?
Thanks.
Regretfully the ticket is not yet resolved due to other high priority pending issues. We are afraid that we cannot share any ETA at the moment as there are other tasks and implementations in the queue. We will surely inform you as soon as we have some certain updates in this regard. Please spare us some time.
We are sorry for the inconvenience.
The issues you have found earlier (filed as PDFNET-47933) have been fixed in Aspose.PDF for .NET 22.12.