您好,我在使用Aspose.CAD 在将dwg导出pdf时,使用的方式是设置导出窗口,导出导出pdf时,导出的pdf出现视图外的内容。
我使用的版本是 24.3.0
导出窗口设定的长宽比是1.7669441141498217
导出的图纸大小是A0的,长宽比是1.41
导出的图纸相比我们设定的导出窗口更宽,所以在上方有导出窗口外的内容出现
下面是我们的代码,是不是我们这边使用的方法不对
代码
CadImage cadImage;//导入的dwg图纸
PdfOptions pdfOptions = new PdfOptions();
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.ExportAllLayoutContent = false;
rasterizationOptions.NoScaling = true;
CadVportTableObject newView = new CadVportTableObject();
newView.Name = "*Active";
newView.CenterPoint.X = 1317603;
newView.CenterPoint.Y = 607300;
newView.ViewHeight = 168200;
newView.UseAspectRatio = true;
newView.ViewAspectRatio = 1.7669441141498217;
for (int i = 0; i < cadImage.ViewPorts.Count; i++)
{
CadVportTableObject currentView = (CadVportTableObject)(cadImage.ViewPorts[i]);
if ((currentView.Name == null && cadImage.ViewPorts.Count == 1) ||
string.Equals(currentView.Name.ToLowerInvariant(), "*active"))
{
cadImage.ViewPorts[i] = newView;
break;
}
}
rasterizationOptions.PageWidth = 1189;
rasterizationOptions.PageHeight = 840;
rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor;
rasterizationOptions.VisibilityMode = VisibilityMode.AsPrint;
rasterizationOptions.Zoom = 1f;
rasterizationOptions.Layouts = new string[] { “Model” };
pdfOptions.VectorRasterizationOptions = rasterizationOptions;
cadImage.Save(outputFilePath, pdfOptions);
图纸.7z (375.3 KB)