Hi,
I've just started using Aspose PDF, and I'm experiencing a problem where a table built up in HTML, then passed through the Aspose PDF generator, breaks over a page. See attached image for the issue - I want the table to have one clean straight line along the bottom before continuing on the next page.
Original HTML is as follows:
<table style="text-align: center; vertical-align: middle; white-space:nowrap; overflow-wrap: break-word;">
<tr>
<td colspan="2" class="subheader">Subheader: subheading</td>
<td class="detailsheader">Comments</td>
<td class="detailsheader"></td>
</tr>
<tr>
<td class="attributeheader">Attribute 1</td><td class="detail">Attribute 1 Value</td>
<td class="comments" rowspan="6">Fusce ultricies sagittis quam, vitae ornare felis vestibulum in. Nulla ut accumsan quam. Pellentesque eget nulla sed eros molestie volutpat. Quisque maximus gravida egestas. Aenean scelerisque tellus nec sollicitudin consectetur. Integer massa sapien, consectetur sed dignissim vitae, hendrerit placerat lorem. Duis sem felis, tristique nec augue aliquam, sollicitudin dictum mi. Sed aliquet orci mi, quis commodo turpis </td>
<td class="emptycell" rowspan="6"></td>
</tr>
<tr>
<td class="attributeheader">Attribute 2</td><td class="detail">Attribute 2 Value</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="attributeheader">Attribute 3</td><td class="detail" >Attribute 3 Value</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="attributeheader">Attribute 4</td><td class="detail" >Attribute 4 Value</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="attributeheader">Attribute 5</td><td class="detail" >Attribute 5 Value</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="attributeheader">Attribute 6</td><td class="detail" >Attribute 6 Value</td>
<td> </td>
<td> </td>
</tr>
</table>
Our .NET code that parses the HTML is as follows. Our HTML is in the 'paragraph' element.
private static byte[] ConvertHtmlToPdf(DocumentMetadata metadata)
{
// memory strem for pdf
var ms = new MemoryStream();
// Create new pdf
var pdf = new Pdf();
// margin
pdf.PageSetup.Margin.Left = 25;
pdf.PageSetup.Margin.Right = 25;
pdf.PageSetup.Margin.Top = 30;
// Create the main document
var documentSection = new Section(pdf);
documentSection.FirstPageInfo = new PageSetup(documentSection);
foreach (var paragraph in metadata.Paragraphs)
{
if (paragraph.PageBreak == PageBreak.Before)
{
documentSection.Paragraphs.Add(new Text(CPAGEBREAK));
}
var documentTextReader = new StringReader(paragraph.Content);
var documentText = new Text(documentTextReader.ReadToEnd());
documentTextReader.Close();
documentTextReader.Dispose();
documentText.IsHtmlTagSupported = true;
documentText.IsKeptTogether = true;
documentText.IsKeptWithNext = true;
documentSection.Paragraphs.Add(documentText);
if (paragraph.PageBreak == PageBreak.After)
{
documentSection.Paragraphs.Add(new Text(CPAGEBREAK));
}
}
if (metadata.ShowHeaderOnPage != ShowHeaderOnPage.None)
{
// Create a header
var header = new HeaderFooter();
// Read the header
var htmlReader = new StringReader(metadata.HeaderContent);
var headerText = new Text(htmlReader.ReadToEnd());
htmlReader.Close();
htmlReader.Dispose();
headerText.IsHtmlTagSupported = true;
header.Paragraphs.Add(headerText);
header.Margin.Top = metadata.HeaderMarginTop;
header.Margin.Bottom = metadata.HeaderMarginBottom;
// Add the header to each page
documentSection.EvenHeader = header;
documentSection.OddHeader = header;
if (metadata.ShowHeaderOnPage == ShowHeaderOnPage.AllExceptFirstPage)
{
// Do not show on the first page
//documentSection.FirstPageInfo.Margin.Top = -0.5f;
documentSection.OddHeader.IsSubsequentPagesOnly = true;
}
}
if (metadata.ShowPageNumbers)
{
documentSection.StartingPageNumber = 1;
var footer = new HeaderFooter(documentSection);
documentSection.OddFooter = footer;
documentSection.EvenFooter = footer;
var footerText = new Text("Page $p of $P");
footerText.TextInfo.Alignment = AlignmentType.Center;
footer.Paragraphs.Add(footerText);
}
pdf.Sections.Add(documentSection);
// Save the pdf to the memory stream
pdf.Save(ms);
var msArray = ms.ToArray();
ms.Close();
ms.Dispose();
return msArray;
}
I've just started using Aspose PDF, and I'm experiencing a problem where a table built up in HTML, then passed through the Aspose PDF generator, breaks over a page. See attached image for the issue - I want the table to have one clean straight line along the bottom before continuing on the next page.
Original HTML is as follows:
<table style="text-align: center; vertical-align: middle; white-space:nowrap; overflow-wrap: break-word;">
<tr>
<td colspan="2" class="subheader">Subheader: subheading</td>
<td class="detailsheader">Comments</td>
<td class="detailsheader"></td>
</tr>
<tr>
<td class="attributeheader">Attribute 1</td><td class="detail">Attribute 1 Value</td>
<td class="comments" rowspan="6">Fusce ultricies sagittis quam, vitae ornare felis vestibulum in. Nulla ut accumsan quam. Pellentesque eget nulla sed eros molestie volutpat. Quisque maximus gravida egestas. Aenean scelerisque tellus nec sollicitudin consectetur. Integer massa sapien, consectetur sed dignissim vitae, hendrerit placerat lorem. Duis sem felis, tristique nec augue aliquam, sollicitudin dictum mi. Sed aliquet orci mi, quis commodo turpis </td>
<td class="emptycell" rowspan="6"></td>
</tr>
<tr>
<td class="attributeheader">Attribute 2</td><td class="detail">Attribute 2 Value</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="attributeheader">Attribute 3</td><td class="detail" >Attribute 3 Value</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="attributeheader">Attribute 4</td><td class="detail" >Attribute 4 Value</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="attributeheader">Attribute 5</td><td class="detail" >Attribute 5 Value</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="attributeheader">Attribute 6</td><td class="detail" >Attribute 6 Value</td>
<td> </td>
<td> </td>
</tr>
</table>
Our .NET code that parses the HTML is as follows. Our HTML is in the 'paragraph' element.
private static byte[] ConvertHtmlToPdf(DocumentMetadata metadata)
{
// memory strem for pdf
var ms = new MemoryStream();
// Create new pdf
var pdf = new Pdf();
// margin
pdf.PageSetup.Margin.Left = 25;
pdf.PageSetup.Margin.Right = 25;
pdf.PageSetup.Margin.Top = 30;
// Create the main document
var documentSection = new Section(pdf);
documentSection.FirstPageInfo = new PageSetup(documentSection);
foreach (var paragraph in metadata.Paragraphs)
{
if (paragraph.PageBreak == PageBreak.Before)
{
documentSection.Paragraphs.Add(new Text(CPAGEBREAK));
}
var documentTextReader = new StringReader(paragraph.Content);
var documentText = new Text(documentTextReader.ReadToEnd());
documentTextReader.Close();
documentTextReader.Dispose();
documentText.IsHtmlTagSupported = true;
documentText.IsKeptTogether = true;
documentText.IsKeptWithNext = true;
documentSection.Paragraphs.Add(documentText);
if (paragraph.PageBreak == PageBreak.After)
{
documentSection.Paragraphs.Add(new Text(CPAGEBREAK));
}
}
if (metadata.ShowHeaderOnPage != ShowHeaderOnPage.None)
{
// Create a header
var header = new HeaderFooter();
// Read the header
var htmlReader = new StringReader(metadata.HeaderContent);
var headerText = new Text(htmlReader.ReadToEnd());
htmlReader.Close();
htmlReader.Dispose();
headerText.IsHtmlTagSupported = true;
header.Paragraphs.Add(headerText);
header.Margin.Top = metadata.HeaderMarginTop;
header.Margin.Bottom = metadata.HeaderMarginBottom;
// Add the header to each page
documentSection.EvenHeader = header;
documentSection.OddHeader = header;
if (metadata.ShowHeaderOnPage == ShowHeaderOnPage.AllExceptFirstPage)
{
// Do not show on the first page
//documentSection.FirstPageInfo.Margin.Top = -0.5f;
documentSection.OddHeader.IsSubsequentPagesOnly = true;
}
}
if (metadata.ShowPageNumbers)
{
documentSection.StartingPageNumber = 1;
var footer = new HeaderFooter(documentSection);
documentSection.OddFooter = footer;
documentSection.EvenFooter = footer;
var footerText = new Text("Page $p of $P");
footerText.TextInfo.Alignment = AlignmentType.Center;
footer.Paragraphs.Add(footerText);
}
pdf.Sections.Add(documentSection);
// Save the pdf to the memory stream
pdf.Save(ms);
var msArray = ms.ToArray();
ms.Close();
ms.Dispose();
return msArray;
}