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

Free Support Forum - aspose.com

How to position html elements in PDF


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 = @"


//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

//Save the pdf document


I also tried with the new API, without luck:

string html = @”
// 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

I also tried with position:absolute or fixed, and it doesn’t work.
Any idea?

Hi Roger,

for using our API’s.

have tested the scenario and I am able to notice the same problem. For the sake
of correction, I have logged this problem as PDFNEWNET-39939 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.

Hello Nayyer,

thank you for the quick response.

In the meantime, are there any workaround you can think of to allow me to position an html item in pdf? Im open to any suggestions…

do you know if previous versions of aspose pdf have the issue?

Hi Roger,

Thanks for your patience.

I am afraid currently I cannot share any workaround regarding position related issues for HTML to PDF conversion. However we request you to please be patient and wait for the resolution. The team will start investigating this problem as per their schedule and as soon as we have some definite updates, we will let you know. Please be patient and spare us little time.