Desperately Seeking Help with Printing, HELP!

Desperately Seeking Help with Printing, HELP!

Post by Donald C. Ason » Thu, 28 Nov 1996 04:00:00



Environment: Visual C++ 4.0, Windows NT 3.51

Hi all,

I desperately need help with printing.  I posted my problems
here and the newsgroups, but I did not receive any response.

I am having lots of problems printing from an MDI application
with CEditView.  If the document has more than 720 lines, the
framework prints only some of the text.  It won't even display
blank pages.  If you have more than 2000 lines, it prints only
9 pages, and the rest of the document is printed as blank
pages.  However, all the text is viewable inside the view.
That is, the user can see everything.  The problem is with
printing and previewing.

I have managed to get some things working.  I have now
implemented my own printing.  Since the text that I display
contains tabs, I have to use CDC::TabbedTextOut() to get
things lined up.  I have tried using every mapping mode that I
can see.  The main problem now is that the text is coming out
larger than the font that I created.

// the following was done in OnInitialUpdate.
//m_nFontHeight is 12.
// call GetDC()
        m_fontDisplay.CreateFont(m_nFontHeight, 0, 0, 0, FW_BLACK,
        0, 0, 0,
        0,0,0,0,
        FIXED_PITCH| FF_MODERN,
        NULL);

SetFont(&m_fontDisplay);      
pDC->SelectObject(&m_fontDisplay);
pDC->SetMapMode(MM_TEXT);

// dc released
// view is filled with text.

// view is ok, and text is displayed correctly.

// I set up a tab stop array.

In my OnPrint() function I have the following:

The mapping mode is MM_LOENGLISH; I tried many many others
with the same result.  Here is my output call:

pDC->TabbedTextOut(0,
                -(nHeight * nCurLine),
                strLine, // CString Object
                m_nTabStops, // = 7
                m_arrayTabs, // array of tabstops
                m_nOrigin);
// nHeight is tm.tmHeight + tm.tmExternalLeading;
// tm being a TEXTMETRIC variable and I called
// pDC->GetTextMetrics(&tm);

I have tried the above with and without the tabstop and origin
of 0.  All efforts failed.  The major problem is not with tabs.
The text that is printed is bigger than the font I specified.
I have tried creating a font in OnBeginPrinting() and deleting
the font in OnEndPrinting().  It all failed.  The font is just
like the font I created above, fixed font of height 12.  I
even tried:

m_pfontPrinter->CreateFont(12,0,0,0,FW_BLACK, // I ALSO TRIED FW_NORMAL
                        0,0,0,
                        DEFAULT_CHARSET,
                        OUT_CHARACTER_PRECIS,
                        CLIP_CHARACTER_PRECIS,
                        DEFAULT_QUALITY,
                        FIXED_PITCH | FF_MODERN,
                        NULL); // I also tried "Courier New"

Then inside OnPrint() I called SelectObject:

CFont* pfontOld = pDC->SelectObject(m_pfontPrinter);
pDC->SetMapMode(MM_LOENGLISH);  // I tried other modes also

Called all my pDC->TabbedTextOut(...);

pDC->SelectObject(pfontOld);
// end of function.

It still did not work.  I get Output with text much larger
than point 12.  It comes out with lines being cut off.  If the
font would be the size that I want (the size that is used on
the view display), I would be done with this project.  What am
I doing wrong?  How can I get the font to be smaller.  

I am desperately seeking some help here, and I'd be greatful
to anyone who can help me with this.  Thanks in advance.

--
Donald
**************************************************
*  Cry if you wanna cry.  If it helps you see.   *
*  If it clears your eyes.  -Sound Garden        *
**************************************************

Samples  :ftp://ftp.hpc.uh.edu/pub/donald
WWW      :http://www.uh.edu/~dasonye

 
 
 

Desperately Seeking Help with Printing, HELP!

Post by Niranjan Hir » Thu, 28 Nov 1996 04:00:00



[snip-snip "more printer / font woes"]

        Why don't you try to implement the following first...it might shed
some light on what's wrong:
        1)  Get printer DC
        2)  Create font
        3)  StartDoc
        4)  StartPage
        5)  Select font into printer DC
        6)  Use TabbedTextOut, ExtTextOut, TextOut to print some text
        7)  Reselect default font into printer DC
        8)  EndPage
        9)  EndDoc
        10) Release printer DC
        11) Delete printer DC
        12) Delete font object

        If you can get this to work, then you've got everything you need.

        -- Hira
<----------------------------------------------------------------------------->
  "shpe" = "he / she"; "shpis = her / his"; "shpim = her / him"

<----------------------------------------------------------------------------->

 
 
 

Desperately Seeking Help with Printing, HELP!

Post by Donald C. Ason » Fri, 29 Nov 1996 04:00:00



: [snip-snip "more printer / font woes"]

:       Why don't you try to implement the following first...it might shed
: some light on what's wrong:
:       1)  Get printer DC
:       2)  Create font
:       3)  StartDoc
:       4)  StartPage
:       5)  Select font into printer DC
:       6)  Use TabbedTextOut, ExtTextOut, TextOut to print some text
:       7)  Reselect default font into printer DC
:       8)  EndPage
:       9)  EndDoc
:       10) Release printer DC
:       11) Delete printer DC
:       12) Delete font object
:      
:       If you can get this to work, then you've got everything you need.
Hi,

Thanks for your response.  I know about what you stated above.
I finally fixed the problem yesterday (11/27) (there seems to be a
time delay before my post gets out to other servers).  My
TabbedTextOut was printing larger fonts because of my font
width.  I was specifying a width of 0, thereby letting the
system adjust.  

Anyway, I fixed the problem.  However, the original problem
with CEditView and CRichEditView is still there as they are
bugs with MS code.

Thanks again.

:       -- Hira
: <----------------------------------------------------------------------------->
:   "shpe" = "he / she"; "shpis = her / his"; "shpim = her / him"

: <----------------------------------------------------------------------------->

--
Donald
**************************************************
*  Cry if you wanna cry.  If it helps you see.   *
*  If it clears your eyes.  -Sound Garden        *
**************************************************

Samples  :ftp://ftp.hpc.uh.edu/pub/donald
WWW      :http://www.uh.edu/~dasonye