Sring65
3
using Aspose.CAD;
using Aspose.CAD.FileFormats.Cad;
using Aspose.CAD.ImageOptions;
namespace CAD2PDF
{
internal class doCadToPdf
{
public static string run(string inputStream, String outputFilePath=null)
{
if (!File.Exists(inputStream)) return null;
LoadOptions opts = new LoadOptions();
opts.SpecifiedEncoding=CodePages.SimpChinese;
opts.CustomFontFolders=new String[] { Path.GetDirectoryName(inputStream) };
opts.CustomFontFolderOptions=CustomFontFolderOptions.ReplaceFolderForAll;
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
cadRasterizationOptions.BackgroundColor=Color.White;
cadRasterizationOptions.PageWidth=1600;
cadRasterizationOptions.PageHeight=1600 + 105F;
cadRasterizationOptions.AutomaticLayoutsScaling=true;
cadRasterizationOptions.NoScaling=false;
cadRasterizationOptions.DrawType= CadDrawTypeMode.UseObjectColor;
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.VectorRasterizationOptions=cadRasterizationOptions;
using (CadImage cadImage = (CadImage)Image.Load(inputStream, opts))
{
if (string.IsNullOrEmpty(outputFilePath))
outputFilePath = inputStream + ".pdf";
cadImage.Save(outputFilePath, pdfOptions);
return outputFilePath;
}
}
}
}