Пример #1
0
void CComPrint::PrintBmp(UINT nBmpId)
{
	char szPrinter[200] = "";
	char *pszDevice = NULL;
	char *pszDriver = NULL;
	char *pszOutput = NULL;

	HDC hdcPrint = NULL; // 定义一个设备环境句柄

	static DOCINFO di={sizeof(DOCINFO),"printer",NULL};

	// 得到设备字符串存入数组szPrinter中
	GetProfileString("windows","device",",,,",szPrinter,80); 

	// 将设备字符串分解
	if( (NULL != (pszDevice = strtok(szPrinter,","))) && 
		(NULL != (pszDriver = strtok(NULL,","))) &&
		(NULL != (pszOutput = strtok(NULL,","))))
	{
		// 创建一个打印机设备句柄
		if((hdcPrint = CreateDC(pszDriver,pszDevice, pszOutput, NULL)) != 0)
		{ 
			if (StartDoc(hdcPrint, &di) > 0)	//开始执行一个打印作业 
			{ 
				StartPage(hdcPrint);			//打印机走纸,开始打印 
				SaveDC(hdcPrint);				//保存打印机设备句柄

				#pragma warning(disable:4312)

				// 输出图片
				HBITMAP hBitmap=::LoadBitmap(AfxGetInstanceHandle(),(LPCTSTR)nBmpId);
				BITMAP bitmap;
				::GetObject(hBitmap,sizeof(BITMAP),&bitmap);

				#pragma warning(default:4312)

				HDC dcMem;
				dcMem=::CreateCompatibleDC(hdcPrint);
				HBITMAP hOldBmp=(HBITMAP)::SelectObject(dcMem,hBitmap);

				int nVertCenterPos = ::GetDeviceCaps(hdcPrint, VERTRES) / 2;
				::StretchBlt(hdcPrint,1,50,400,bitmap.bmHeight,dcMem,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);

				::SelectObject(dcMem,hOldBmp);
				::DeleteDC(dcMem);
				::DeleteObject(hBitmap);

				RestoreDC(hdcPrint,-1); //恢复打印机设备句柄 
				EndPage(hdcPrint); //打印机停纸,停止打印 
				EndDoc(hdcPrint); //结束一个打印作业 
			} 

			// 用API函数DeleteDC销毁一个打印机设备句柄 
			DeleteDC(hdcPrint);
		}
	}
}
Пример #2
0
int finishPage(const int pdcID) {
    HDC pdc = printerDCs[pdcID];
    if (pdc != NULL) {
        if (EndPage(pdc) > 0) {
            return JNI_TRUE;
        }
    }
    return JNI_FALSE;
}
Пример #3
0
Bool
apc_prn_new_page( Handle self)
{
   apcErrClear;
   objCheck false;
   if ( EndPage( sys ps) < 0) apiPrnErr;
   if ( StartPage( sys ps) < 0) apiPrnErr;
   return apcError == errOk;
}
Пример #4
0
/* 
%F cdFlush para Printer.
Termina uma pagina e inicia outra.
*/
static void cdflush(cdCtxCanvas* ctxcanvas)
{
  delete ctxcanvas->graphics;
  EndPage(ctxcanvas->hDC);

  StartPage(ctxcanvas->hDC);
  ctxcanvas->graphics = new Graphics(ctxcanvas->hDC, ctxcanvas->printerHandle);

  cdwpUpdateCanvas(ctxcanvas);
}
Пример #5
0
/*
 * Clean up the GDI data structures without attempting any more printing.
 */
static void
gdi_abort(void)
{
    if (pstate.out_row) {
	(void) EndPage(pstate.dlg.hDC);
	pstate.out_row = 0;
    }
    (void) EndDoc(pstate.dlg.hDC);

    cleanup_fonts();
}
Пример #6
0
void SimplePrint(int nPages)
{
	TCHAR temp[MAX_PATH];

	DWORD size = MAX_PATH;
	GetDefaultPrinter(temp, & size); // default printer name

	HDC hDC = CreateDC(NULL, temp, NULL, NULL); // DC with default setting
	
	if ( hDC )
	{
		nCall_AbortProc = 0;
		SetAbortProc(hDC, SimpleAbortProc);

		DOCINFO docinfo;
		docinfo.cbSize       = sizeof(docinfo);
		docinfo.lpszDocName  = _T("SimplePrint");
		docinfo.lpszOutput   = NULL; 
		docinfo.lpszDatatype = _T("EMF");
		docinfo.fwType		 = 0; 

		if ( StartDoc(hDC, & docinfo) > 0 )
		{
			for (int p=0; p<nPages; p++) // one page at a time
				if ( StartPage(hDC) <= 0 )
					break;
				else
				{
					int width  = GetDeviceCaps(hDC, HORZRES);
					int height = GetDeviceCaps(hDC, VERTRES);
					int dpix   = GetDeviceCaps(hDC, LOGPIXELSX);
					int dpiy   = GetDeviceCaps(hDC, LOGPIXELSY);
			
					wsprintf(temp, _T("Page %d of %d"), p+1, nPages);
					SetTextAlign(hDC, TA_TOP | TA_RIGHT );
					TextOut(hDC, width, 0, temp, _tcslen(temp));

					Rectangle(hDC, 0, 0, dpix, dpiy);
					Rectangle(hDC, width, height, width-dpix, height-dpiy);
				
					if ( EndPage(hDC)<0 )
						break;
				}
			
			EndDoc(hDC);
		}

		DeleteDC(hDC);
	}

	wsprintf(temp, "AbortProc called %d times", nCall_AbortProc);
	MessageBox(NULL, temp, "SimlePrint", MB_OK);	
}
Пример #7
0
void Editor::print(){

	static const int MARG=720;	//1440=1 inch

	CPrintDialog dlg(false);
	int e=dlg.DoModal();if( e==IDCANCEL ) return;

	HDC hdc=dlg.GetPrinterDC();
	if( !hdc ){
		MessageBox( "Error printing" );
		return;
	}

	int hr=GetDeviceCaps(hdc,HORZRES),vr=GetDeviceCaps(hdc,VERTRES);
	int px=GetDeviceCaps(hdc,LOGPIXELSX),py=GetDeviceCaps(hdc,LOGPIXELSY);

	SetMapMode(hdc,MM_TEXT);

	FORMATRANGE fr={0};
	fr.hdc=fr.hdcTarget=hdc;
	fr.rcPage.left=fr.rcPage.top=0;
	fr.rcPage.right=(hr/px)*1440;
	fr.rcPage.bottom=(vr/py)*1440;

	//margins
	fr.rc.left=fr.rcPage.left+MARG;
	fr.rc.top=fr.rcPage.top+MARG;
	fr.rc.right=fr.rcPage.right-MARG;
	fr.rc.bottom=fr.rcPage.bottom-MARG;

	char buff[MAX_PATH];
	strcpy( buff,name.c_str() );

	DOCINFO di={sizeof(di)};
	di.lpszDocName=buff;

	getSel();
	int start=selStart,end=selEnd;
	if( start==end ){ start=0;end=editCtrl.GetTextLength(); }

	StartDoc(hdc,&di);
	while( start<end ){
		StartPage(hdc);
		fr.chrg.cpMin=start;
		fr.chrg.cpMax=end;
		start=editCtrl.FormatRange(&fr,true);
		EndPage(hdc);
	}
	EndDoc(hdc);

	editCtrl.FormatRange(0,false);
	DeleteDC(hdc);
}
Пример #8
0
/* 
%F cdKillCanvas para Printer.
Termina a pagina e termina o documento, enviando-o para a impressora.
*/
static void cdkillcanvas (cdCtxCanvas *ctxcanvas)
{
  EndPage(ctxcanvas->hDC);
  EndDoc(ctxcanvas->hDC);
  
  cdwKillCanvas(ctxcanvas);
  
  DeleteDC(ctxcanvas->hDC);
  
  memset(ctxcanvas, 0, sizeof(cdCtxCanvas));
  free(ctxcanvas);
}
Пример #9
0
/* 
%F cdKillCanvas para Printer.
Termina a pagina e termina o documento, enviando-o para a impressora.
*/
static void cdkillcanvas (cdCtxCanvas* ctxcanvas)
{
  cdwpKillCanvas(ctxcanvas);
  
  EndPage(ctxcanvas->hDC);
  EndDoc(ctxcanvas->hDC);

  ClosePrinter(ctxcanvas->printerHandle);
  DeleteDC(ctxcanvas->hDC);
  
  delete ctxcanvas;
}
Пример #10
0
BOOL
NewPage(
    IN HANDLE PrinterDC
    )

/*++

Routine Description:

    NewPage - Do printer EndPage and StartPage. Reset NumLines.

Arguments:

    PrinterDC - HDC of the printer

Return Value:

    BOOL - TRUE if we got a valid Printer DC, FALSE otherwise.

--*/

{

    int nError;

    nError = EndPage( PrinterDC );

    if (nError <= 0) {

        // PrinterError( hWnd, PrinterDC, (LPTSTR) GetString( IDS_END_PAGE ) );

        return FALSE;
    }
    nError = StartPage( PrinterDC );

    if (nError <= 0) {

        // PrinterError( hWnd, PrinterDC, (LPTSTR) GetString( IDS_START_PAGE ) );

        return FALSE;
    }

    //
    // Set the current line number to the top of the page.
    //

    LineNumber = 1;

    return TRUE;
}
Пример #11
0
static bool print(ITile *pDraw)
{
	PRINTDLG pd = {0};
	pd.lStructSize = sizeof pd;

	/* 
	 * get rid of PD_RETURNDEFAULT on the line below if you'd like to
	 * see the "Printer Settings" dialog!
	 *
	 */
	pd.Flags = PD_RETURNDEFAULT | PD_RETURNDC;

	// try to retrieve the printer DC
	if( !PrintDlg(&pd) )
	{
		return false;
	}

	DOCINFO di = {0};
	HDC hPrinter = pd.hDC;

	// initialization of the printing!

	// start the first and only page

	Printer canvas(hPrinter);

	RECT rect = {0};
	canvas.GetClipBox(&rect);
	Tiles::rect_t wrect;
	wrect.x = rect.left;
	wrect.y = rect.top;
	wrect.wide = rect.right - rect.left;
	wrect.high = rect.bottom - rect.top;
	pDraw->setRect(wrect);

	pDraw->Draw(&canvas, false);

	// uncomment the following line to print in colour! :)
	// SetTextColor( hPrinter, 0x0000FF );

	// finish the first page
	EndPage( hPrinter );

	// end this document and release the printer's DC
	EndDoc( hPrinter );
	//DeleteDC( hPrinter );
	return true;
}
Пример #12
0
/*****************************************************************************
 End document
 Done on PRINT CLOSE
*****************************************************************************/
static void EndDocument(void)
{
   DeleteObject( SelectObject( pd.hDC, hOldFont ) );
   if (defaultprinter)
   {
     EndPage( pd.hDC );
     EndDoc( pd.hDC );
   }
   else
   {
     EndPagePrinter( hPrinter );
     EndDocPrinter( hPrinter );
   }
   documentON = FALSE;
}
Пример #13
0
int GPdestroywidget (Gwidget_t *widget) {
    HENHMETAFILE mfile;

    if (WPU->mode == 1) {
        mfile = CloseEnhMetaFile (GC);
        OpenClipboard (NULL);
        EmptyClipboard ();
        SetClipboardData (CF_ENHMETAFILE, mfile);
        CloseClipboard ();
        DeleteMetaFile (mfile);
    } else {
        EndPage (GC);
        EndDoc (GC);
    }
    return 0;
}
Пример #14
0
void MacPrinterCanvas::finish() {
	if (!hdc) {return;}
	endPaint();
	//if (!Escape(hdc, NEWFRAME, 0, NULL, NULL)) {
		//DebugMessage("NEWFRAME failed\n");
	//	abort();
	//}
	//if (!Escape(hdc, ENDDOC, 0, NULL, NULL)) {
		//DebugMessage("ENDDOC failed\n");
	//	abort();
	//}
	EndPage(hdc);
	EndDoc(hdc);
	DeleteDC(hdc);
	hdc = 0;
}
Пример #15
0
Bool
apc_prn_end_doc( Handle self)
{
   apcErrClear;

   objCheck false;
   if ( EndPage( sys ps) < 0) apiPrnErr;
   if ( EndDoc ( sys ps) < 0) apiPrnErr;

   hwnd_leave_paint( self);
   if ( sys pal) DeleteObject( sys pal);
   DeleteDC( sys ps);
   sys pal = nil;
   sys ps = nil;
   return apcError == errOk;
}
Пример #16
0
static void Kill(Engine *engine)
{
  PSEngine *psEngine= (PSEngine *)engine;
  long fonts= psEngine->fonts;
  int i, xll, yll, xur, yur;
  int bad= 0;

  if (psEngine->e.marked) bad= EndPage(psEngine);

  if (psEngine->file) {
    if (!bad) bad= PutLine(psEngine);
    if (!bad) bad= Append(psEngine, "%%Trailer");
    if (!bad) bad= PutLine(psEngine);

    sprintf(line, "%%%%Pages: %d", psEngine->currentPage-1);
    if (!bad) bad= Append(psEngine, line);
    if (!bad) bad= PutLine(psEngine);

    xll= psEngine->docBB.xll;
    xur= psEngine->docBB.xur;
    if (xll < xur) {
      yll= psEngine->docBB.yll;
      yur= psEngine->docBB.yur;
    } else {
      xll= yll= 0;
      xur= 612;
      yur= 792;
    }
    sprintf(line, "%%%%BoundingBox: %d %d %d %d", xll, yll, xur, yur);
    if (!bad) bad= Append(psEngine, line);
    if (!bad) bad= PutLine(psEngine);

    strcpy(line, "%%DocumentFonts: ");
    for (i=0 ; i<N_PSFONTS ; i++) {
      if ((1<<i) & fonts) {
        strcat(line, psFontNames[i]);
        if (!bad) bad= Append(psEngine, line);
        if (!bad) bad= PutLine(psEngine);
        strcpy(line, "%%+ ");
      }
    }

    if (psEngine->file!=pf_stdout) p_fclose(psEngine->file);
  }
  GpDelEngine(engine);
}
Пример #17
0
/*****************************************************************************
 * Go to next page
*****************************************************************************/
static void NextPage( void )
{
   DeleteObject( SelectObject( pd.hDC, hOldFont ) );
   if (defaultprinter)
   {
     EndPage( pd.hDC );
     StartPage( pd.hDC );
   }
   else
   {
     EndPagePrinter( hPrinter );
     StartPagePrinter( hPrinter );
   }
   hOldFont = SetFont( );
   PrepareDC( );
   column = row = 0;
   page++;
   PageHeader( page+1 );
}
Пример #18
0
void CComPrint::WinPrint(CString csText)
{
	char szPrinter[200] = "";
	char *pszDevice = NULL;
	char *pszDriver = NULL;
	char *pszOutput = NULL;

	HDC hdcPrint = NULL; // 定义一个设备环境句柄

	static DOCINFO di={sizeof(DOCINFO),"printer",NULL};

	// 得到设备字符串存入数组szPrinter中
	GetProfileString("windows","device",",,,",szPrinter,80); 

	// 将设备字符串分解
	if( (NULL != (pszDevice = strtok(szPrinter,","))) && 
		(NULL != (pszDriver = strtok(NULL,","))) &&
		(NULL != (pszOutput = strtok(NULL,","))))
	{
		// 创建一个打印机设备句柄
		if((hdcPrint = CreateDC(pszDriver,pszDevice, pszOutput, NULL)) != 0)
		{ 
			if (StartDoc(hdcPrint, &di) > 0)	//开始执行一个打印作业 
			{ 
				StartPage(hdcPrint);			//打印机走纸,开始打印 
				SaveDC(hdcPrint);				//保存打印机设备句柄

				// 输出文字
				CRect rcText(0,0,0,0);
				::DrawText(hdcPrint, csText, csText.GetLength(), &rcText, DT_CALCRECT);	// 计算大小
				::DrawText(hdcPrint, csText, csText.GetLength(), &rcText, DT_WORDBREAK);

				RestoreDC(hdcPrint,-1);			//恢复打印机设备句柄 
				EndPage(hdcPrint);				//打印机停纸,停止打印 
				EndDoc(hdcPrint);				//结束一个打印作业 
			} 

			// 用API函数DeleteDC销毁一个打印机设备句柄 
			DeleteDC(hdcPrint);
		}
	}
}
Пример #19
0
void EndPrinting ( void )
{
	if ( pd.hDC )
	{
		int nError = EndPage(pd.hDC); 
		if (nError <= 0)
		{
			DeleteDC ( pd.hDC ); 
			pd.hDC = NULL;
			return;
		}

		// end printing
		EndDoc(pd.hDC);

		// Delete DC when done.
		DeleteDC ( pd.hDC ); 
		pd.hDC = NULL;
	}
}
Пример #20
0
void Fl_Gdi::page(double pw, double ph, int orientation)
{
    if(nPages)
        EndPage(gc_);
    nPages++;
    pw_=pw;
    ph_=ph;
    orientation_ = orientation;
    DEVMODE * mode = (DEVMODE *)GlobalLock(mode_);
    if(orientation)
        mode->dmOrientation = DMORIENT_PORTRAIT;
    else
        mode->dmOrientation = DMORIENT_LANDSCAPE;
    mode->dmPaperWidth = (int) (pw*254/72);
    mode->dmPaperLength = (int) (ph*254/72);
    mode->dmFields |= DM_PAPERLENGTH | DM_PAPERWIDTH;
    mode->dmFields &= ~DM_PAPERSIZE;
    GlobalUnlock(mode_);
    set_page(1);
};
Пример #21
0
/*
 * Finish the GDI print-out and clean up the data structures.
 */
static int
gdi_done(const char **fail)
{
    int rc = 0;

    if (pstate.out_row) {
	if (EndPage(pstate.dlg.hDC) <= 0) {
	    *fail = "EndPage failed";
	    rc = -1;
	}
	pstate.out_row = 0;
    }
    if (EndDoc(pstate.dlg.hDC) <= 0) {
	*fail = "EndDoc failed";
	rc = -1;
    }

    cleanup_fonts();

    return rc;
}
Пример #22
0
int fb_PrinterClose( DEV_LPT_INFO *devInfo )
{
		W32_PRINTER_INFO *pInfo = (W32_PRINTER_INFO*) devInfo->driver_opaque;

    if( pInfo->hDc!=NULL ) {
        if( pInfo->Emu.iPageStarted )
            EndPage( pInfo->hDc );
        EndDoc( pInfo->hDc );
        DeleteDC( pInfo->hDc );
    } else {
        EndDocPrinter( pInfo->hPrinter );
        ClosePrinter( pInfo->hPrinter );
    }

		if( devInfo->driver_opaque )
	    free(devInfo->driver_opaque);

		devInfo->driver_opaque = NULL;

    return fb_ErrorSetNum( FB_RTERROR_OK );
}
Пример #23
0
int TessDllAPI::BeginPageUpright(uinT32 xsize,uinT32 ysize,unsigned char *buf, uinT8 bpp) {


    EndPage();

//It looks like Adaptive thresholding is disabled so this must be a 1 bpp image
  if (page_image.create (xsize+800, ysize+800, 1)==-1)
    return 0L;  //make the image bigger to enclose in whitespace

  //copy the passed buffer into the center of the image
  IMAGE tmp;

  tmp.capture(buf, xsize, ysize, bpp);


  copy_sub_image(&tmp, 0, 0, 0, 0, &page_image, 400, 400, true);



  return ProcessPagePass1();
}
Пример #24
0
static void EmuPrint_RAW( W32_PRINTER_INFO *pInfo,
                          const void *pText,
                          size_t uiLength,
                          int isunicode )
{
    while( uiLength-- ) {
				if( !isunicode )
				{
					char ch = *(char *)pText;
					pText += sizeof(char);

					EmuPageStart( pInfo );
          TextOut( pInfo->hDc,
                 pInfo->Emu.dwCurrentX, pInfo->Emu.dwCurrentY,
                 &ch, 1 );
				} else {
					FB_WCHAR ch = *(FB_WCHAR *)pText;
					pText += sizeof(FB_WCHAR);


					EmuPageStart( pInfo );
          TextOutW( pInfo->hDc,
                 pInfo->Emu.dwCurrentX, pInfo->Emu.dwCurrentY,
                 &ch, 1 );
				}

        pInfo->Emu.dwCurrentX += pInfo->Emu.dwFontSizeX;

        if( pInfo->Emu.dwCurrentX>=pInfo->Emu.dwSizeX ) {
            pInfo->Emu.dwCurrentX = 0;
            pInfo->Emu.dwCurrentY += pInfo->Emu.dwFontSizeY;
            if( pInfo->Emu.dwCurrentY>=pInfo->Emu.dwSizeY ) {
                pInfo->Emu.dwCurrentY = 0;
                EndPage( pInfo->hDc );
                pInfo->Emu.iPageStarted = FALSE;
            }
        }
    }
}
Пример #25
0
void print_mswin(const char *file_name)
{
    HDC     hDC;
    DOCINFO di;
    short int width, height;

    HWND hWndParent = HWND_DESKTOP; /* would be better to be a real window */

    /* Need a printer DC to print to. */
    hDC = get_printer_dc(&width, &height);

    /* Did you get a good DC?, Cancel will return NULL also, so what to do? */
    if (!hDC) {
        return;
    }

    /* You always have to use an AbortProc(). */
    if (SetAbortProc(hDC, abort_proc) == SP_ERROR) {
        MessageBox(NULL, "Error setting up AbortProc",
                   "Error", MB_APPLMODAL | MB_OK);
        return;
    }

    /* Init the DOCINFO and start the document. */
    init_doc_struct(&di, "MyDoc");
    StartDoc(hDC, &di);

    /* Print one page. */
    StartPage(hDC);
    print_file(file_name, hDC, width, height);
    EndPage(hDC);

    /* Indicate end of document. */
    EndDoc(hDC);

    /* Clean up */
    DeleteDC(hDC);
}
Пример #26
0
/*+/csubr/TOC----------------------------------------------------------------
* PlPrtNewPage - finish a page and start a new one
*
* Purpose:
*		Creates a page break, finishing the current page and starting
*		a new one.
*
* Return Value:
*		PL_OK, or
*		other codes for other errors
*
*-Date     Author		Revision
* -------- ------------	--------
* 01-25-96 R. Cole		created
*--------------------------------------------------------------------------*/
int PASCAL
PlPrtNewPage(
PL_CTX	*pPlot)			// IO pointer to plot context struct for printing
{
	int		retStat=PL_OK;
	int		stat;

	if (pPlot->bPrintCancel) { retStat = PL_PRT_CANCEL; goto done; }

	if (pPlot->hDC == 0) goto done;
	stat = EndPage(pPlot->hDC);
	if (stat < 0)
	    goto gdi_error;
	stat = StartPage(pPlot->hDC);
	if (stat <= 0)
	    goto gdi_error;

done:
	return retStat;
gdi_error:
	retStat = PL_GDI_FAIL;
	goto done;
}
Пример #27
0
void Printer::Print(Window *Obj)
{
	if (PrintDialog(Obj,PD_RETURNDC))
	{
		RECT Client;
		GetClientRect(Obj->hWnd,&Client);

		SetMapMode(pd.hDC, MM_ANISOTROPIC);
		SetWindowExtEx(pd.hDC, Client.right, Client.bottom,NULL);
		SetViewportExtEx(pd.hDC, GetDeviceCaps(pd.hDC,HORZRES),GetDeviceCaps(pd.hDC,VERTRES),NULL);

		DOCINFO dInfo={sizeof(DOCINFO),"Test-Doc",NULL};
		StartDoc(pd.hDC,&dInfo);
		StartPage(pd.hDC);

		Obj->Paint(pd.hDC,FALSE,Client);

		EndPage(pd.hDC);
		EndDoc(pd.hDC);

		DeleteDC(pd.hDC);
	}
}
Пример #28
0
VOID vPageOut(HDC hdc,int page,int doc, PSZ pszMode)
{
    int x,y;
    CHAR ach[120];

    StartPage(hdc);
    x = GetDeviceCaps(hdc,HORZRES) - 1;
    y = GetDeviceCaps(hdc,VERTRES) - 1;

    sprintf(ach,"Page %ld, Doc %ld, (%ld x %ld), in %s",page,doc,x,y,pszMode);

    TextOut(hdc,500,50,ach,strlen(ach));

    MoveToEx(hdc,0,0,NULL);
    LineTo(hdc,x,0);
    LineTo(hdc,x,y);
    LineTo(hdc,0,y);
    LineTo(hdc,0,0);

    vPage1F(NULL,hdc,NULL);

    EndPage(hdc);
}
Пример #29
0
static int
close_emf(cairo_surface_t *surface)
{
  HDC hdc;
  HENHMETAFILE emf;
  int r;

  hdc = cairo_win32_surface_get_dc(surface);
  cairo_surface_flush(surface);
  cairo_surface_copy_page(surface);
  cairo_surface_finish(surface);

  r = 1;

  EndPage(hdc);
  emf = CloseEnhMetaFile(hdc);
  if (emf == NULL) {
    return 1;
  }
  DeleteEnhMetaFile(emf);
  /* DeleteDC() is called in the cairo library */
  return r;
}
Пример #30
0
BOOL PrintMyPage (HWND hwnd)
{
     static DOCINFO di = { sizeof (DOCINFO), TEXT ("Print2: Printing") } ;
     BOOL           bSuccess = TRUE ;
     HDC            hdcPrn ;
     short          xPage, yPage ;
     
     if (NULL == (hdcPrn = GetPrinterDC ()))
          return FALSE ;
     
     xPage = GetDeviceCaps (hdcPrn, HORZRES) ;
     yPage = GetDeviceCaps (hdcPrn, VERTRES) ;
     
     EnableWindow (hwnd, FALSE) ;
     
     SetAbortProc (hdcPrn, AbortProc) ;
     
     if (StartDoc (hdcPrn, &di) > 0)
     {
          if (StartPage (hdcPrn) > 0)
          {
               PageGDICalls (hdcPrn, xPage, yPage) ;
               
               if (EndPage (hdcPrn) > 0)
                    EndDoc (hdcPrn) ;
               else
                    bSuccess = FALSE ;
          }
     }
     else
          bSuccess = FALSE ;
     
     EnableWindow (hwnd, TRUE) ;
     DeleteDC (hdcPrn) ;
     return bSuccess ;
}