文档彩票走势图>>VectorDraw Developer Framework使用教程>>VDF常见问题整理(三十三):如何在特殊情况下将图形居中放置在纸上?
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 Units Box 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 scale double 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 margins double 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);
对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。
关注慧聚IT微信公众号 ???,了解产品的最新动态及最新资讯。