Aspose提供控件都是可以试用的,于是简单测试了下。
Aspose.CAD支持DGN转PDF,对于一些还使用station的图纸的确挺好。
Aspose转PDF不能使用SHX字体,这造成如果使用SHX字体,则无法使用Aspose.CAD转PDF。(参见:https://forum.aspose.com/t/text-missing-in-generated-pdf-from-dwg/201211)
Aspose.CAD can render only build-in system fonts. Autocad also uses it’s own .shx fonts. If such font type appears we change it with a default font during the rendering process. The Rasterization option contains the “Quality” property. To reduce result pdf file size you can user the following parameters:
rasterizationOptions.Quality.ObjectsPrecision = RasterizationQualityValue.Low;
//the most influence option for result pdf file size
rasterizationOptions.Quality.Text = RasterizationQualityValue.Low;
下面是DGN、DWG文件转PDF的效果
//DGN转PDF
private void button1_Click(object sender, EventArgs e)
{
// This code example demonstrates how to convert DGN to PDF
// Input DGN file
string sourceFilePath = "Sample.dgn";
// Load the DGN file
DgnImage image = (DgnImage)Aspose.CAD.Image.Load(sourceFilePath);
// Initialize PDF Options
PdfOptions pdfOptions = new PdfOptions();
// Save as PDF
image.Save("sample_converted.pdf", pdfOptions);
}
//dgn转dwg
private void button2_Click(object sender, EventArgs e)
{
string sourceFilePath = "Sample.dgn";
// Load the DGN file
Aspose.CAD.Image image = (Aspose.CAD.Image)Aspose.CAD.Image.Load(sourceFilePath);
// Initialize PDF Options
PdfOptions pdfOptions = new PdfOptions();
// Save as PDF
image.Save("sample_convertedDWG.pdf", pdfOptions);
}
//dwg转pdf
private void button3_Click(object sender, EventArgs e)
{
string sourceFilePath = "Sample.dwg";
Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath);
foreach (CadStyleTableObject style in cadImage.Styles)
{
if (style.StyleName == "Roman")
{
// Specify the font for one particular style
style.PrimaryFontName = "Arial";
}
}
}
通过Aspose.CAD遍历图元没有测试。不过由于其转换带shx字体文件效果不好,因此就不考虑使用了。
标签:DGN,PDF,sourceFilePath,测试,pdf,Aspose,CAD From: https://www.cnblogs.com/instr/p/17129058.html