Aspose.Pdf for .NET是一款可以帮助开发人员进行PDF文件创建、编辑和转换的控件,利用该产品可以在电脑上没有安装Adobe Acrobat 的情况下对PDF文件进行读写和转换操作,在新的16.12版本中该产品主要作了如下的更新:
1.在新的16.12版本中支持新的PDF/A_2U标准
string inFile = "Input.pdf";
string outFile = "Output.pdf";
string outLog = "log.xml";
PdfFormatConversionOptions opts = new PdfFormatConversionOptions(outLog, PdfFormat.PDF_A_2U, ConvertErrorAction.Delete);
doc.Convert(opts);
doc.Save(outFile);
2.在新的版本中对PDF文件的优化进行了加强,并且为OptimizationOption类引入了一些新的属性
document.OptimizeResources(new
Aspose.Pdf.Document.OptimizationOptions()
{
LinkDuplcateStreams = true,
RemoveUnusedObjects = true,
RemoveUnusedStreams = true,
CompressImages = true,
ResizeImages = true,
RemovePrivateInfo = true,
ImageQuality = 50,
MaxResoultion = 75
});
3.支持XML流转换
string inXml = "sample.xml";
string inXslt = "sample.xslt";
string outFile = "output.pdf";
doc.BindXml(new FileStream(inXml, FileMode.OpenOrCreate), new FileStream(inXslt, FileMode.OpenOrCreate));
doc.Save(outFile);
4.支持把XML格式的HTML文本转换为PDF
XML事例:
<?xml version='1.0' encoding='utf-8'?>
<Page>
<HtmlFragment>some text<Hyperlink URL="www.google.com" /></HtmlFragment>
</Page>
</Document>
转换代码:
string inXml = "sample.xml";
string outFile = "output.pdf";
doc.BindXml(inXml);
doc.Save(outFile);