xPageLayoutControl1打印预览代码
来源:互联网 发布:用c语言实现socket 编辑:程序博客网 时间:2024/05/18 01:16
short m_CurrentPrintPage = 0;
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//this code will be called when the PrintPreviewDialog.Show method is called
//set the PageToPrinterMapping property of the Page. This specifies how the page
//is mapped onto the printer page. By default the page will be tiled
//get the selected mapping option
string sPageToPrinterMapping = (string)this.cboPageToPrinterMapping.SelectedItem;
if (sPageToPrinterMapping == null)
//if no selection has been made the default is tiling
this.axPageLayoutControl1.Page.PageToPrinterMapping = esriPageToPrinterMapping.esriPageMappingTile;
else if (sPageToPrinterMapping.Equals("2: Tile"))
this.axPageLayoutControl1.Page.PageToPrinterMapping = esriPageToPrinterMapping.esriPageMappingTile;
else if (sPageToPrinterMapping.Equals("0: Crop"))
this.axPageLayoutControl1.Page.PageToPrinterMapping = esriPageToPrinterMapping.esriPageMappingCrop;
else if (sPageToPrinterMapping.Equals("1: Scale"))
this.axPageLayoutControl1.Page.PageToPrinterMapping = esriPageToPrinterMapping.esriPageMappingScale;
else
this.axPageLayoutControl1.Page.PageToPrinterMapping = esriPageToPrinterMapping.esriPageMappingTile;
//get the resolution of the graphics device used by the print preview (including the graphics device)
short dpi = (short)e.Graphics.DpiX;
MessageBox.Show(dpi.ToString());
//envelope for the device boundaries
IEnvelope devBounds = new EnvelopeClass();
//get page
IPage page = this.axPageLayoutControl1.Page;
//the number of printer pages the page will be printed on
short printPageCount;
printPageCount = this.axPageLayoutControl1.get_PrinterPageCount(0);
m_CurrentPrintPage++;
//the currently selected printer
IPrinter printer = this.axPageLayoutControl1.Printer;
//get the device bounds of the currently selected printer
page.GetDeviceBounds(printer, m_CurrentPrintPage, 0, dpi, devBounds);
//structure for the device boundaries
tagRECT deviceRect;
//Returns the coordinates of lower, left and upper, right corners
double xmin, ymin, xmax, ymax;
devBounds.QueryCoords(out xmin, out ymin, out xmax, out ymax);
//initialize the structure for the device boundaries
deviceRect.bottom = (int)ymax;
deviceRect.left = (int)xmin;
deviceRect.top = (int)ymin;
deviceRect.right = (int)xmax;
//determine the visible bounds of the currently printed page
IEnvelope visBounds = new EnvelopeClass();
page.GetPageBounds(printer, m_CurrentPrintPage, 0, visBounds);
//get a handle to the graphics device that the print preview will be drawn to
IntPtr hdc = e.Graphics.GetHdc();
//print the page to the graphics device using the specified boundaries
ITrackCancel m_TrackCancel = new CancelTrackerClass();
this.axPageLayoutControl1.ActiveView.Output(hdc.ToInt32(), dpi, ref deviceRect, visBounds, m_TrackCancel);
//release the graphics device handle
e.Graphics.ReleaseHdc(hdc);
//check if further pages have to be printed
if (m_CurrentPrintPage < printPageCount)
e.HasMorePages = true; //document_PrintPage event will be called again
else
e.HasMorePages = false;
}
- xPageLayoutControl1打印预览代码
- javascript打印-打印页面设置-打印预览代码
- JavaScript 打印-打印页面设置-打印预览代码
- JS 打印功能代码(包括打印预览、打印设置等)
- 打印/预览/设置的客户端代码
- 打印预览
- 打印预览
- 打印预览
- 打印预览
- javascript打印-打印页面设置-打印预览代码,特定内容的部分打印技术
- js 打印,打印预览
- 打印预览&打印 样式
- MFC打印 打印预览
- MFC打印 打印预览
- c#打印和打印预览
- 页面设置、打印预览、打印
- javascript打印及打印预览
- 打印和打印预览机制
- 如何在picture library 显示添加到ECB中的feature。
- [转] 費茲定律Fitts’ Law與使用者介面設計
- wiper
- 怎样煲汤的方法
- 药材煲汤学问多,你真的会吗
- xPageLayoutControl1打印预览代码
- java Swing中的绘制相关
- [双语阅读]研究:避孕药使女性更爱阴柔男
- js 复制到剪贴板 ,兼容支持火狐firefox 和 ie
- 高精度计算篇1
- C#调用系统API
- 搞怪的2009另类诺贝尔奖获奖名单
- 恐怖片 fright flick
- Trash talk 说别人坏话