Hi,
I am trying to generate pdf with inline style in the html. But the alignments are not properly shown in the pdf.
Please look into the below html text.
table {
bOrder: 1px solid #E8EEF4;
bOrder-collapse: collapse;
}
table td {
bOrder: 1px solid #E8EEF4;
}
.mainDiv
{
width:100%;
height:100%;
}
.DivTopLeft1
{
height: 135px;
margin-left: 376px;
width: 365px;
}
}
.DivTopLeft2
{
height:135px;
width:365px;
}
.TableTopLeft2
{
margin-top: -140px;
}
.DivTopLeft3
{
height:135px;
width:365px;
}
.TableTopLeft3
{
margin-top: 25px;
}
.DivTopRight
{
height:135px;width:365px;
}
.TableTopRight
{
margin-top: 44px;
}
.DivBottom
{
height:235px;
}
.TableBottom
{
background-color:Aqua;
}
multipleTable
TopLeft1 Table | |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
TopLeft2 Table | |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
TopLeft3 Table | |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
TopRight Table |
BottomLeft Table | |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
------------------------------
Below This is the code block
// Render the view html to a string.
string htmlText = this.htmlViewRenderer.RenderViewToString(this, viewName, model);
// Instantiate an object PDF class
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// add the section to PDF document sections collection
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
//// Read the contents of HTML file into StreamReader object
//StreamReader r = File.OpenText(@“D:/pdftest/HTML2pdf.html”);
//Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, htmlText);
// enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
//Add the text paragraphs containing HTML text to the section
section.Paragraphs.Add(text2);
// Specify the URL which serves as images database
pdf.HtmlInfo.ImgUrl = “D:/pdftest/MemoryStream/”;
pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.TreatAsPlainText;
pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = true;
//Save the pdf document
pdf.Save(“D:/pdftest/MemoryStream/HTML2pdf.pdf”);
Thanks!