We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Export Html to Pdf : Text Align-Center not maintained if Background color is specified

We used below html as input to generate the pdf :


Test for Inline style and CSS support

<p style=“text-align: center; font-size: 20pt;”>
<span style=“background-color:yellow;”>Your Name
Your Area

The pdf that is generated failed to maintain the center alignment of 1st span. The second span was correctly center aligned.

Please find attached pdf for the same.

Regards,
Saurabh

Hi Saurabh,


Thanks for your inquiry. I am afraid I am unable to notice the subjected issue, while tested the scenario with Aspose.Pdf for .NET 9.4.0 using DOM approach for HTML to PDF conversion. Please download and try latest version of Aspose.Pdf for .NET, hopefully it will help you to accomplish the task.

Moreover, it seems you are evaluating the Aspose.Pdf for .NET. You may request for 30 days temporary license to evaluate our product without
any limitation. Please also check license implementation details.

Please feel free to contact us for any further assistance.

Best Regards,

Hi,


Thank you for the prompt reply. I would like to update you that we are using the same version of Aspose.Pdf to generate the pdf (i.e. v9.4.0).

If needed we can share the sample visual studio solution with you.

Regards,
Saurabh

Hi Saurabh,


Thanks for your feedback. Please confirm are you still getting issue using DOM approach with license implementation? If issue persist then please share your sample source code and html file, we will test the scenario at our end and will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,
smahajan:
If needed we can share the sample visual studio solution with you.
Hi Saurabh,

As shared by Tilal, if you are still faceing any issue while using latest Document Object Model (DOM) of Aspose.Pdf namespace, please share the sample project which can help us in replicating this issue at our end.
Hi,

Thanks for the quick response. I have attached the visual studio solution (Vs2013) that can help you reproduce the issue. As updated earlier, I am using a Trial version of Aspose.Net library.

I have also added the sample pdf file generated by the above solution. Where the 1st text is centre aligned with yellow background and the 2nd text is centre aligned with no background color.

Please use 7zip to open the attachment.

Let me know in case if there are any queries.

Regards,
Saurabh

Hi Saurabh,


Thank you for sharing sample project. In your source code you are using old generator for the purpose, as suggested above please use DOM approach for HTML to PDF conversion and also request a 30 days free temporary license to evaluate Aspose.Pdf without any limitation. It will help you to resolve the issue. However, please note currently DOM approach supports HTML file to PDF conversion. It does not support insertion of HTML string. We have already logged the requirement in our issue tracking system as PDFNEWNET-35804. We will notify you as soon it is resolved.


string testStr = " Test for
Inline style and CSS support <p
style=“text-align: center; font-size: 15px;”><span
style=“background-color:yellow;”>This text has yellow background
color and is center aligned.

<p
style=“text-align: center; font-size: 15px;”>This
text has no background color and is center
aligned.
";<o:p></o:p>

byte[] inputBytes = Encoding.UTF8.GetBytes(testStr);

MemoryStream inputStream = new MemoryStream(inputBytes);

// load HTML file

Document doc = new Document(inputStream, htmloptions);

doc.Save(myDir+"HTMLtoPDFDOM.pdf");

Please feel free to contact us for any further assistance.


Best Regards,

Hi,


Thank you for the reply. We used above way of generating pdf and it solved the mentioned problem. But we are stuck at one point. The input to this pdf is HTML. We want to have a fixed header on every page which is HTML as well. And this fixed header should start at a given margin from the top.

We used TextStamp the way described here. But this does not handle html correctly and outputted it as string on the pdf.

Could you please let us know how we can achieve the same?

Thanks,
Saurabh

Hi Saurabh,


Thanks for your inquiry. I am afraid currently Aspose.Pdf does not support to include HTML string in existing PDF document. However, we have good news that the feature is implemented in upcoming release of Aspose.Pdf for .NET i.e. 9.5.0. We will update you as soon as it is released and gets available for download, then you may add header footer with HTML string to existing PDF document.

We are sorry for the inconvenience caused.

Best Regards,

Hi Saurabh,


Thanks for your patience.

The feature to insert HTML in existing PDF file using new Document Object Model (DOM) is logged as PDFNEWNET-35804 in our issue tracking system and this feature is implemented in upcoming release of Aspose.Pdf for .NET 9.5.0. In order to accomplish this requirement, please try using following code snippet.

[C#]

string outFile = “out.pdf”;<o:p></o:p>

Document doc = new Document();

Helper.SetLicense();

Page page = doc.Pages.Add();

HtmlFragment fragment = new HtmlFragment("Test html");

page.Paragraphs.Add(fragment);

doc.Save(outFile);

The issues you have found earlier (filed as PDFNEWNET-35804) have been fixed in Aspose.Pdf for .NET 9.5.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(10)