Hi,
We are building a simple library that converts CAD formats to PDF.
While playing with DWG format we realized that converting 3D objects to PDF requires special code (sample file here) that does not work with the one to convert DWG containing 2D objects (sample file here).
We are using this code with Aspose.CAD 18.3.0 and Aspose.PDF 18.1.0:
using (var cadImage = (CadImage)Image.Load(input))
{
var rasterizationOptions = new CadRasterizationOptions
{
//TypeOfEntities = ?
};
DefineUnitSystem(cadImage.UnitType, out var currentUnitIsMetric, out var currentUnitCoefficient);
if (currentUnitIsMetric)
{
const double metersCoeff = 1 / 1000.0;
var scaleFactor = metersCoeff / currentUnitCoefficient;
rasterizationOptions.PageWidth = (float)(210 * scaleFactor);
rasterizationOptions.PageHeight = (float)(297 * scaleFactor);
rasterizationOptions.UnitType = UnitType.Millimeter;
}
else
{
rasterizationOptions.PageWidth = (float)(8.27f / currentUnitCoefficient);
rasterizationOptions.PageHeight = (float)(11.69f / currentUnitCoefficient);
rasterizationOptions.UnitType = UnitType.Inch;
}
rasterizationOptions.AutomaticLayoutsScaling = true;
cadImage.Save(output, new PdfOptions
{
VectorRasterizationOptions = rasterizationOptions
});
}
The code comes from here.
And we would like to know if there is a way to calculate TypeOfEntities based on the information in cadImage?
Or any other general code that works for converting any DWG to PDF - that could contain 3D objects?
Thank you!