[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

WYSIWYG printing

Posted on 1997-11-28
12
Medium Priority
?
273 Views
Last Modified: 2013-12-03
I have a function for rendering text on a device context. It works fine with DISPLAY but when I try to use a printer DC, sometimes words at the end of a line get clipped. It seems to be GDI's problem because when I set the viewport extent larger than the real size of the page (results in different scaling) the words still get clipped but somewhere else. BTW, I think it's irrelevant but it's a program for 16bit Windows.
0
Comment
Question by:wiregin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1408944
The problem is that printer has much better resolution that dispaly so you must perform neccessary scaling.

Suppose pdc CDC class associated with printer DC,
 
       int ixp=pdc->GetDeviceCaps(LOGPIXELSX);
        int iyp=pdc->GetDeviceCaps(LOGPIXELSY);

        // get the current window's resolution
        CDC* pddc = GetDC();
        int ixd=pddc->GetDeviceCaps(LOGPIXELSX);
        int iyd=pddc->GetDeviceCaps(LOGPIXELSY);

now you must multiply all you graphics by the factor (ixp/ixd) at horizontal direction and by the factor (iyp/iyd) at vertical direction  


0
 

Author Comment

by:wiregin
ID: 1408945
Well isn't GDI supposed to do that? First I set the window and viewport extents and then GDI should do the conversion from logical coordinates to device coordinates. What I do is I set the logical coord. extent to the size of the page on the screen in pixels (it's 800 pixels wide in my case) and then I set the device coord. extent to the size of the physical page in pixels. That is supposed to work isn't it? Part of my code looks like this:

          if(PrintDlg(pd)!=0)
          {
            hs=GetDeviceCaps(pd->hDC,HORZRES);
            vs=GetDeviceCaps(pd->hDC,VERTRES);

             StartDoc(pd->hDC,&di);
             do
             {
               SetMapMode(pd->hDC,MM_ISOTROPIC);
               SetWindowExt(pd->hDC,PAGEWIDTH,PAGEWIDTH);
               SetViewportExt(pd->hDC,hs,hs);

                StartPage(pd->hDC);

               // Perform all the drawing

                EndPage(pd->hDC);
              EndDoc(pd->hDC);
            }

0
 
LVL 7

Expert Comment

by:galkin
ID: 1408946
I don't see how you do scaling. Anyway I suggest you using my code, I got it from my project and it works. Besides, it looks very simple.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 2

Expert Comment

by:JensUniweb
ID: 1408947
I see one error in your code. You use hs as both width and height in SetViewportExt(). But I'm not sure that is the problem. Does scaling seem to be OK?? Not all GDI function work with logical units. How do you write the text??
0
 

Author Comment

by:wiregin
ID: 1408948
Well since I'm using the MM_ISOTROPIC mapping mode, it doesn't matter that I use the same number for both axes. Yes, the scaling is totally fine but as I said, sometimes a word at an end of a line gets clipped on the printer, not on the screen. I use ExtTextOut function to write the text to a DC.
0
 
LVL 1

Expert Comment

by:pking
ID: 1408949
Is the word at the end of a line or the edge of the page?
0
 

Author Comment

by:wiregin
ID: 1408950
It's at the end of a line. Also, it can be in the middle of a page if there are more than one columns.
0
 
LVL 1

Expert Comment

by:pking
ID: 1408951
Are you printing lots of text in one SDK call?  For example, are you printing perhaps 4k more or less?  
0
 

Author Comment

by:wiregin
ID: 1408952
Yes, there's text and graphics.
0
 
LVL 1

Accepted Solution

by:
pking earned 40 total points
ID: 1408953
Specifically, do you send more than 4k worth of text to the ExtTextOut function?  If you are than that is probably your problem.  I recall this issue years ago when doing some printing work on 16-bit Windows.  I found that this problem became a non- issue when I kept the amount of text I sent to the API call at a little less than 4k.  There is a big difference between Win16 and Win32 in this case.
0
 

Author Comment

by:wiregin
ID: 1408954
I'm sorry I misunderstood your question. No I don't send more than 4k in a single ExtTextOut call. What my rendering function does is that it outputs formated text (multiple fonts, alignment, etc.) So there are always only a few words being printed at a time.
0
 
LVL 1

Expert Comment

by:pking
ID: 1408955
Sorry,  If that is the case, then my answer is incorrect.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question