地图排版打印 |
1. 注意:系统预定义纸张,它的宽和高是定值,所以不用给Printer的宽和高赋值,否则会报错;
2. 如何判断当前要打的布局是用户自定义还是系统预定义的:
3. 系统预定义模板打印代码示例:
// 预定义模板不用给 Printer 赋值宽和高两个参数,因为预定义模板的宽,高是定值 // 第一句将Paper.Size赋值给Printer.PaperSize,就包含着赋值了宽和高 MapLayout.Printer.PaperSize = MapLayout.Paper.Size; MapLayout.Printer.Orientation = MapLayout.Paper.Orientation; MapLayout.Printer.Margin = MapLayout.Paper.Margin; MapLayout.Printer.IsVectorPrint = false; MapLayout.PrintPreview = true; |
4. 用户自定义模板打印代码示例:
MapLayout.Printer.PaperSize = MapLayout.Paper.Size; MapLayout.Printer.Orientation = MapLayout.Paper.Orientation; MapLayout.Printer.PaperWidth = MapLayout.Paper.Width; MapLayout.Printer.PaperHeight = MapLayout.Paper.Height; MapLayout.Printer.Margin = MapLayout.Paper.Margin; MapLayout.Printer.IsVectorPrint = false; MapLayout.PrintPreview = true; |
1. 如何设置是否分页打印:
是否分页打印是通过给 Printer 赋值不同的PaperSize来区分的
2. 分页打印代码示例:
将宽 1.7米,高1米的用户自定义布局,用A4分页打印出来
代码如下:
MapLayout.Printer.PaperSize = PaperSize.A4; MapLayout.Printer.Orientation = MapLayout.Paper.Orientation; MapLayout.Printer.Margin = MapLayout.Paper.Margin; MapLayout.Printer.IsVectorPrint = false; MapLayout.PrintPreview = true; |
注意事项:
代码如下:
MapLayout.Printer.PaperSize = PaperSize.A4; MapLayout.Printer.Orientation = (按照自己想要的横纵向设置一个值); MapLayout.Printer.Margin = (按照自己想要的页边距设置一个值); |
代码如下:
MapLayout.Printer.PaperSize = PaperSize.A4; MapLayout.Printer.Orientation = MapLayout.Paper.Orientation;(使用原布局的横纵向) MapLayout.Printer.Margin = MapLayout.Paper.Margin;(使用原布局的页边距) |
打印分成的第1张小页,代码如下:
MapLayout.Printer.PaperSize = PaperSize.A4; MapLayout.Printer.FromPage = 1; MapLayout.Printer.ToPage = 1; MapLayout.Printer.Orientation = MapLayout.Paper.Orientation; MapLayout.Printer.Margin = MapLayout.Paper.Margin; |
打印分成的第3张小页到第12张小页,代码如下:
MapLayout.Printer.PaperSize = PaperSize.A4; MapLayout.Printer.FromPage = 3; MapLayout.Printer.ToPage = 12; MapLayout.Printer.Orientation = MapLayout.Paper.Orientation; MapLayout.Printer.Margin = MapLayout.Paper.Margin; |
3. 按布局原大小打印代码示例:
将宽 1.7米,高1米的用户自定义布局,按原布局打印,代码如下:
MapLayout.Printer.PaperSize = MapLayout.Paper.Size; MapLayout.Printer.Orientation = MapLayout.Paper.Orientation; MapLayout.Printer.PaperWidth = MapLayout.Paper.Width; MapLayout.Printer.PaperHeight = MapLayout.Paper.Height; MapLayout.Printer.Margin = MapLayout.Paper.Margin; MapLayout.Printer.IsVectorPrint = false; MapLayout.PrintPreview = true; |