我正在做一个将autocad文件.dwg转换成PDF的asp.net项目。
我使用以下代码来完成此操作:
using (var image = Aspose.CAD.Image.Load(filePath))
{
// create an instance of CadRasterizationOptions & set resultant page size
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions()
{
PageSize = new Aspose.CAD.SizeF(image.Size.Width, image.Size.Height),
};
// save resultant PDF
image.Save("****" + "***", new Aspose.CAD.ImageOptions.PdfOptions() { VectorRasterizationOptions = rasterizationOptions });
}我得到的pdf如下:

另一张图片

我想要的建筑是在pdf文件的中心和足够大,以便于用户使用。我怎样才能修正这个视图并使其清晰呢?
发布于 2018-12-12 01:30:42
我已经观察到了您分享的示例代码。你能分享一下你在导出PDF中遇到的问题吗?您可以分享源DWG文件与预期的输出PDF。此外,在上图中,当您在应用程序中设置Aspose.CAD的许可证时,左上角的水印将被移除。
我在Aspose担任支持开发人员/布道者。
非常感谢
发布于 2018-12-13 01:15:35
我建议你尝试使用下面的示例代码来设置渲染文件的打印区域。
var cadImage =(CadImage) Aspose.CAD.Image.Load("filePath");
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.Layouts = new string[] { "Model" };
rasterizationOptions.NoScaling = true;
// note: preserving some empty borders around part of image is the responsibility of customer
// top left point of region to draw
Point topLeft = new Point(6156, 7053);
double width = 3108;
double height = 2489;
CadVportTableObject newView = new CadVportTableObject();
newView.Name = new CadStringParameter();
newView.Name.Init("*Active");
newView.CenterPoint.X = topLeft.X + width / 2f;
newView.CenterPoint.Y = topLeft.Y - height / 2f;
newView.ViewHeight.Value = height;
newView.ViewAspectRatio.Value = width / height;
for (int i = 0; i < cadImage.ViewPorts.Count; i++)
{
CadVportTableObject currentView = (CadVportTableObject)(cadImage.ViewPorts[i]);
if (cadImage.ViewPorts.Count == 1 || string.Equals(currentView.Name.Value.ToLowerInvariant(), "*active"))
{
cadImage.ViewPorts[i] = newView;
break;
}
}
cadImage.Save("Saved.pdf", new Aspose.CAD.ImageOptions.PdfOptions() { VectorRasterizationOptions = rasterizationOptions });https://stackoverflow.com/questions/53723586
复制相似问题