예제 #1
0
void CDoubleSidedPrintPrePrint1::OnClickedPrint()
{
	CPmwApp* pApp = GET_PMWAPP();

	// Create a newsletter project.
	pApp->last_new_info.type = PROJECT_TYPE_Newsletter;
	pApp->last_new_info.subtype = 0;
	pApp->last_new_info.orientation = PORTRAIT;

	// Paper info is printer info.
	*(pApp->last_new_info.m_pPaperInfo) = *(pApp->GetPaperInfo(pApp->last_new_info.orientation));

	WORD wFlags = CPmwDoc::m_wGlobalDocumentFlags;
	CPmwDoc::m_wGlobalDocumentFlags |= CPmwDoc::FLAG_TestPrintDocument;
	CPmwDoc* pDoc = (CPmwDoc*)(pApp->m_pScratchTemplate->OpenDocumentFile(NULL, FALSE));
	CPmwDoc::m_wGlobalDocumentFlags = wFlags;

	if (pDoc != NULL)
	{
#ifndef WIN32
		pDoc->DoNewDocument(-1, FALSE);
#endif

		CPmwView* pView = pDoc->GetCurrentView();
		// We have one page so far. Add the key text to it.

		// Create the key frame with text saying "FACE UP".
		WORD wDoubleSidedType = DBLPRN_Valid;
		pView->CreateKeyFrame(wDoubleSidedType);
		pView->CreateKeyArrow(wDoubleSidedType);
		CreateLeftFrame(pView, "A");

		ASSERT(pDoc->NumberOfPages() == 1);

		// Create the second page.
		pDoc->AddPage(1);
		pDoc->GotoPage(1);

		pView->CreateKeyFrame(wDoubleSidedType);
		pView->CreateKeyArrow(wDoubleSidedType);
		CreateLeftFrame(pView, "B");

		// Set the title for the print-out.
		CString csTitle;
		TRY
			csTitle.LoadString(IDS_PrintTest1);
		END_TRY
		pDoc->SetTitle(csTitle);

		// Do the print-out.
		pView->PrintNoDialog();

		pDoc->OnCloseDocument();
	}
}
예제 #2
0
int CLabelView::PrintLabelsBackward(PrintContext &pc, int nSide)
{
	CPmwDoc* pDoc = GetDocument();

	CLabelPrintDialog* pDialog = (CLabelPrintDialog*)pc.m_pPD;
	int nTotalPages = pDialog->m_nTotalPages;

	// Set the side.
	DWORD dwCurrentPage = pDoc->CurrentPageIndex();
	if (nSide != (int)dwCurrentPage)
	{
		pDoc->GotoPage((DWORD)nSide, FALSE);
	}

	// Start at requested first label for first page.
	int nError = 0;

	// Run through all the pages.
	for (int nPage = nTotalPages; nPage-- > 0;)
	{
		pc.m_nStartingLabel = (nPage == 0) ? pDialog->m_nStartingLabel : 0;
		SetLabelVariables(pc, nPage);
		if ((nError = OnPrintLabels(pc, nPage, nTotalPages)) != 0)
		{
			// Aack! We got an error. Leave now.
			break;
		}
	}

	// Reset the page.
	if (dwCurrentPage != pDoc->CurrentPageIndex())
	{
		pDoc->GotoPage(dwCurrentPage, FALSE);
	}

	return nError;
}