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字体文件效果不好,因此就不考虑使用了。

posted on   因思道客  阅读(292)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· 易语言 —— 开山篇
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 【全网最全教程】使用最强DeepSeekR1+联网的火山引擎,没有生成长度限制,DeepSeek本体

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示