提升了PDF转换成HTML的图像质量以及在表中添加重复列

每月定期更新的Aspose.PDF for .NET 18.3现已发布并可供下载。就像每个新版本一样,Aspose.PDF for .NET 18.3包含针对之前版本中报告的问题的修复。这个新版本我们还添加了一些有吸引力和令人兴奋的功能,以满足各种场景。我们一直在努力提供一个强大,稳定和功能丰富的发行版本,Aspose.PDF for .NET 18.3包含了新的功能和增强功能。API的发行说明部分给出了此版本API改进和变更的概述。

改进了PDF到HTML转换的图像质量

为了生成更好质量的图像,当从PDF文档生成HTML时,可以使用HtmlSaveOptions.ImageResolution属性来分辨输出图像。这样输出HTML将包含更好的图像质量。 以下代码片段显示了将PDF转换为HTML时ImageResolution属性的用法:

Document document = new Document(myDir + "input.pdf");
string workingDir = Directory.GetCurrentDirectory();
string outputFilePath = Path.Combine(myDir, "output.html");
HtmlSaveOptions options = new HtmlSaveOptions();
options.ImageResolution = 300; options.PartsEmbeddingMode =
HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;
options.RasterImagesSavingMode =
HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
options.LettersPositioningMethod =
HtmlSaveOptions.LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
document.Save(outputFilePath, options);

在表格中添加重复列

在API的早期版本中,您已经可以使用添加重复行功能通过设置Aspose.Pdf.Table类的RepeatingRowsCount属性。我们在Aspose.PDF for .NET 18.3中实现了添加重复列功能。RepeatingColumnsCount属性已经添加到Aspose.Pdf.Table类中,以便重复表格上的列,这些列太宽而无法放在单个页面上。 您可以查看下面的代码片段,查看使用RepeatingColumnsCount属性的示例:

string outFile = GetOutputPath("40515.pdf");
// Added document
// Added document
Document doc = new Document();
Aspose.Pdf.Page page = doc.Pages.Add();

//Instantiate an outer table that takes up the entire page
Aspose.Pdf.Table outerTable = new Aspose.Pdf.Table();
outerTable.ColumnWidths = "100%";
outerTable.HorizontalAlignment = HorizontalAlignment.Left;

//Instantiate a table object that will be nested inside
//outerTable that will break
//inside the same page
Aspose.Pdf.Table mytable = new Aspose.Pdf.Table();
mytable.Broken = TableBroken.VerticalInSamePage;
mytable.ColumnAdjustment = ColumnAdjustment.AutoFitToContent;

//Add the outerTable to the page paragraphs
//Add mytable to outerTable
page.Paragraphs.Add(outerTable);
var bodyRow = outerTable.Rows.Add();
var bodyCell = bodyRow.Cells.Add();
bodyCell.Paragraphs.Add(mytable);
mytable.RepeatingColumnsCount = 5;
//comment out this or the top section to test if the table renders
//page.Paragraphs.Add(mytable);

//Add header Row
Aspose.Pdf.Row row = mytable.Rows.Add();
row.Cells.Add("header 1");
row.Cells.Add("header 2");
row.Cells.Add("header 3");
row.Cells.Add("header 4");
row.Cells.Add("header 5");
row.Cells.Add("header 6");
row.Cells.Add("header 7");
row.Cells.Add("header 11");
row.Cells.Add("header 12");
row.Cells.Add("header 13");
row.Cells.Add("header 14");
row.Cells.Add("header 15");
row.Cells.Add("header 16");
row.Cells.Add("header 17");

for (int RowCounter = 0; RowCounter <= 5; RowCounter++)
{
//Create rows in the table and then cells in the rows
Aspose.Pdf.Row row1 = mytable.Rows.Add();
row1.Cells.Add("col " + RowCounter.ToString() + ", 1");
row1.Cells.Add("col " + RowCounter.ToString() + ", 2");
row1.Cells.Add("col " + RowCounter.ToString() + ", 3");
row1.Cells.Add("col " + RowCounter.ToString() + ", 4");
row1.Cells.Add("col " + RowCounter.ToString() + ", 5");
row1.Cells.Add("col " + RowCounter.ToString() + ", 6");
row1.Cells.Add("col " + RowCounter.ToString() + ", 7");
row1.Cells.Add("col " + RowCounter.ToString() + ", 11");
row1.Cells.Add("col " + RowCounter.ToString() + ", 12");
row1.Cells.Add("col " + RowCounter.ToString() + ", 13");
row1.Cells.Add("col " + RowCounter.ToString() + ", 14");
row1.Cells.Add("col " + RowCounter.ToString() + ", 15");
row1.Cells.Add("col " + RowCounter.ToString() + ", 16");
row1.Cells.Add("col " + RowCounter.ToString() + ", 17");
}
doc.Save(outFile);

其他资源

我们始终推荐用户使用我们API的最新版本,所以我们建议您下载最新版本的Aspose.PDF for .NET 18.3并坚持以下资源,这些资源将帮助您使用API: