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

Free Support Forum - aspose.com

Text Margins ignored when IsHtmlTagSupported = true

Hello,

We're evaluating Aspose.PDF (8.1.0) for a large, enterprise application. One of our requirements is to be able to print text input from a HTML WSIWYG editor. However, Apose.PDF seems to ignore margins for Text objects when IsHtmlTagSupported = true. If IsHtmlTagSupported = false, margins work as expected. Is there a workaround for this?

Sample code:

Pdf pdf = new Pdf
{
IsTruetypeFontMapCached = false,
Title = "My Title"
};

Section section = pdf.Sections.Add();

Text text1 = new Text("First paragraph");
text1.IsHtmlTagSupported = true; // comment this out and margins work
text1.Margin.Top = 100;
text1.Margin.Bottom = 100;
section.Paragraphs.Add(text1);

Text text2 = new Text("Second Paragraph");
text2.IsHtmlTagSupported = true; // comment this out and margins work
text2.Margin.Top = 100;
text2.Margin.Bottom = 100;
section.Paragraphs.Add(text2);

pdf.Save(@"C:\dev\test.pdf");

Hi there,


Sorry for the inconvenience faced. While using the latest version of Aspose.Pdf for .NET 8.1.0, I've managed to reproduce this issue on my side and logged the issue in our bug tracking system as PDFNEWNET-35508 for further investigation and resolution. I've also linked your request to this issue and you will be notified via this thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,

I am also experiencing same use with Aspose.pdf 10.6 version for java. Is it resolved?

Hi Mamatha,


Thanks for your inquiry. We have resolved the issue in new DOM as following. HtmlFragment is used to add Html string in new generator (Aspose.Pdf). New Generator is more improved and efficient. It can be used for both creating PDF from scratch or manipulating existing PDF.

As you are using Java, so please check documentation to add html string using DOM, it will help you to accomplish the task.

Document pdf = new
Document();<o:p></o:p>

Aspose.Pdf.Page section = pdf.Pages.Add();

HtmlFragment text1 = new HtmlFragment("First paragraph");

text1.Margin.Top = 100;

text1.Margin.Bottom = 100;

section.Paragraphs.Add(text1);

HtmlFragment text2 = new HtmlFragment("Second Paragraph");

text2.Margin.Top = 100;

text2.Margin.Bottom = 100;

section.Paragraphs.Add(text2);

pdf.Save(myDir + "testishtmlmargins.pdf");

Please feel free to contact us for any further assistance.


Best Regards,