VDF常见问题整理(三十三):如何在特殊情况下将图形居中放置在纸上?

本系列教程整理了VectorDraw Developer Framework(VDF)最常见问题,教程整理的很齐全,非常适合新手学习。本文将会介绍如何在不损失软件边距的情况下将绘图集中在纸张上。

    VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。   

VectorDraw Developer Framework试用版下载


问:

    如何在不损失软件边距的情况下将绘图集中在纸张上。CenterDrawingToPaper方法将所有软件边距设置为0并重新计算,这个原因导致我无法使用它。

答:

    您需要像以前一样设置边距,然后排列PrintWindow和/或PrintScale。

具体的请参见以下代码:

doc.New();vdLayout layout = doc.LayOuts.Add("test");doc.ActiveLayOut = layout;layout.Entities.AddItem(new vdRect(doc, new gPoint(-100, 0), 150, 150, 0)); layout.Printer.margins = new MARGINS(50, 50, 50, 50);layout.Printer.paperSize = new Rectangle(0, 0, 827, 1169);layout.Printer.PrintScale = new PrinterScale(1, 1);layout.Printer.PrinterName = "c:\test.pdf";layout.Printer.PrintWindow = new Box(new gPoint(-100, 0), new gPoint(-100 + 150, 150)); doc.ZoomAll();doc.Redraw(true);doc.Prompt("press any key to continue");doc.ActionUtility.getUserString();doc.Prompt(null);// just to create something on screen //get a clone of selected printer window in Drawing UnitsBox printwindowDU =new Box( layout.Printer.PrintWindow);gPoint mid = printwindowDU.MidPoint; //calculate the printable paper area in drawing Units relative to the Layout// convert printer hinches to drawing units depend of printer scaledouble PrinterHInch2DUScale = (Globals.INCH_MM / 100.0f) * (layout.Printer.PrintScale.Denumerator / layout.Printer.PrintScale.Numerator);//Get the rectanle in Drawing Units of Current View for the selected printer paper without the hard Margins.Box printableAreaDU = layout.Printer.PrintablePaperDU();//Subtract from the paper the the selected soft marginsdouble printableAreaDU_Width = printableAreaDU.Width - (layout.Printer.margins.Left + layout.Printer.margins.Right) * PrinterHInch2DUScale;double printableAreaDU_Height = printableAreaDU.Height - (layout.Printer.margins.Top + layout.Printer.margins.Bottom) * PrinterHInch2DUScale; //Center the printWindow to the paper.//Calculate the new printer PrintWindow to be center to paper area by keeping its center and change the width and height to be equal to printable area.Box newPrintWindow = new Box(mid + new gPoint(-printableAreaDU_Width*0.5,-printableAreaDU_Height*0.5),mid + new gPoint(printableAreaDU_Width*0.5,printableAreaDU_Height*0.5));layout.Printer.PrintWindow = newPrintWindow;layout.Printer.Update();doc.Redraw(true);

    对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。

热门文章推荐:

  • 如何排除GroundSurface对象的三角形区域/strong>

  • 复杂自定义对象的入门指南


    如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。

    关注慧聚IT微信公众号 了解产品的最新动态及最新资讯。

标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年10月2日
下一篇 2019年10月2日

相关推荐

发表回复

登录后才能评论