Hello,
I’m trying to position an html element, a table in my case, in a pdf document. I tried various methods and nothing seems to work. Please tell me what I’m doing wrong.
Here’s the code, which is super simple:
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
//Create a section in the pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//Create string variables with text containing html tags
string s = @"
cell1 |
“;
//Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(s);
text1.IsHtmlTagSupported = true;
//Add the text paragraphs containing HTML text to the section
sec1.Paragraphs.Add(text1);
//Save the pdf document
pdf1.Save(@“c:\TestHtml.pdf”);
***
I also tried with the new API, without luck:
string html = @”
cell1 |
";
// instantiate HtmlLoadOptions object and set desrired properties.
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PageInfo.Margin.Bottom = 10;
htmlLoadOptions.PageInfo.Margin.Top = 20;
//Load HTML string
Document doc = new Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)), htmlLoadOptions);
//Save PDF file
doc.Save(@“c:\output.pdf”);
I also tried with position:absolute or fixed, and it doesn’t work.
Any idea?