Aspose.CAD测试记录
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字体文件效果不好,因此就不考虑使用了。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· 易语言 —— 开山篇
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 【全网最全教程】使用最强DeepSeekR1+联网的火山引擎,没有生成长度限制,DeepSeek本体