sulin
路人甲
路人甲
  • 注册日期2003-07-28
  • 发帖数158
  • QQ
  • 铜币501枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1561回复:0

打印问题

楼主#
更多 发布于:2006-03-06 13:11
<P>下面的代码用Adobe pdf 打印出错,不能打印,有那位做过打印的高手给我指点指点,</P>
<P>另外用制图控件的PrintPageLayout这个方法打印也出错(参数设置没有问题的)</P>
<P> IActiveViewPtr pActiveView=m_ctrLayout.GetActiveView();<BR> IPageLayoutPtr pPageLayout = pActiveView;<BR> if(pPageLayout == NULL) return ;<BR> <BR> IPagePtr pPage;<BR> pPageLayout->get_Page(;pPage);<BR> ASSERT(pPage != NULL);<BR> <BR> // Optionally override the current PageToPrinterMapping, options for example:<BR> // To tile the page layout over many pages if its bigger than the printer page<BR> pPage->put_PageToPrinterMapping(esriPageMappingTile); <BR> <BR> // Get ArcMaps current Printer object<BR> IPageLayout2Ptr pPageLayout2 = pPageLayout;<BR> IPrinterPtr pPrinter;<BR>    pPageLayout2->get_Printer(;pPrinter);<BR> pPrinter->putref_Paper(m_ipPaper);<BR> ASSERT(pPrinter != NULL);<BR> <BR> // Find out how many printer pages the output will cover, nPageCount is calculated by PrinterPageCount.<BR> // If nPageCount greater than 1 then we're going to tile the pagelayout onto multiple pages<BR> // This will only be the case if pPage.PageToPrinterMapping = esriPageMappingTile<BR> short nPageCount;<BR> pPage->PrinterPageCount(pPrinter, 0, ;nPageCount); <BR> <BR> for(short nCurrentPage = 0 ; nCurrentPage < nPageCount ; nCurrentPage++)<BR> {<BR>  // Get dots per inch from printer<BR>  short printerDPI;<BR>  pPrinter->get_Resolution(;printerDPI);<BR>  // Get device bounds - this is in printer device coordinates (number of dots across page to a page)<BR>  // Note there is often a margin around the edge that is unprintable<BR>  IEnvelopePtr pDeviceBounds(CLSID_Envelope);<BR>  pPage->GetDeviceBounds(pPrinter, nCurrentPage, 0, printerDPI, pDeviceBounds);<BR>  <BR>  //Get values (as doubles) out of the envelope and put them into a rectangle (as Longs)<BR>  double xMin, xMax, yMin, yMax;<BR>  pDeviceBounds->get_XMin(;xMin);<BR>  pDeviceBounds->get_YMin(;yMin);<BR>  pDeviceBounds->get_XMax(;xMax);<BR>  pDeviceBounds->get_YMax(;yMax);<BR>  RECT rectDeviceBounds;<BR>  rectDeviceBounds.left = (LONG)xMin;<BR>  rectDeviceBounds.top = (LONG)yMin;<BR>  rectDeviceBounds.right = (LONG)xMax;<BR>  rectDeviceBounds.bottom = (LONG)yMax;<BR>  <BR>  // Compute the area of the page layout to send to the printer,<BR>  // this is in page layout units (inches or cm)<BR>  IEnvelopePtr pVisBounds(CLSID_Envelope);<BR>  pPage->GetPageBounds(pPrinter, nCurrentPage, 0, pVisBounds);<BR>  <BR>  //Build envelope in device coordinates - this must be the whole paper<BR>  double paperWidthInch, paperHeightInch;<BR>  pPrinter->QueryPaperSize(;paperWidthInch, ;paperHeightInch);<BR>  <BR>  IEnvelopePtr pDeviceFrame(CLSID_Envelope);<BR>  pDeviceFrame->PutCoords(0.0, 0.0, paperWidthInch * printerDPI, paperHeightInch * printerDPI);<BR>  <BR>  OLE_HANDLE hDC;<BR>  // StartPrinting takes a device frame (whole page) and returns a handle to a device context (hDC)<BR>  pPrinter->StartPrinting(pDeviceFrame, NULL, ;hDC);<BR>  // This draws the visible bounds (pVisBounds) area of the<BR>  // active view to the printer<BR>  pActiveView->Output(hDC, long(printerDPI), ;rectDeviceBounds, pVisBounds, NULL);<BR>  pPrinter->FinishPrinting();<BR> }    </P><img src="images/post/smile/dvbbs/em30.gif" />
喜欢0 评分0
游客

返回顶部