GNOME Bugzilla – Bug 85831
Printing (and export to WMF) clip diagram incorrectly
Last modified: 2014-05-04 20:55:14 UTC
When printing (and export to .wmf), the diagram is scaled incorrectly. The image is too big for the page (or image), and is clipped on the right and bottom. In other words, the blue page break lines are incorrect. You can get the diagram to fit ok by using a scale value of around 60 to 70 and ignoring the page break lines, but this varies. (Tried on Win98 and WinNT4 with 0.88, 0.90RC1 and 0.90)
*** Bug 84868 has been marked as a duplicate of this bug. ***
*** Bug 92553 has been marked as a duplicate of this bug. ***
*** Bug 90817 has been marked as a duplicate of this bug. ***
The problem still exists in the current CVS version. Steffen
Still exists with 0.92 and it probably will for 0.93 and later versions as well. There is some code to magically scale the output but it doesn't work that well. IIRC there also are some bits missing from the specification which (WMF placeable header). But as always : reasonable patches accepted ;-)
cced myself just to let me get notice those reasonable patches ...
*** Bug 130907 has been marked as a duplicate of this bug. ***
*** Bug 126769 has been marked as a duplicate of this bug. ***
*** Bug 134377 has been marked as a duplicate of this bug. ***
*** Bug 151491 has been marked as a duplicate of this bug. ***
The reason the WMF files are clipped is that the bounding rect passed to CreateEnhMetaFile is not calculated correctly. The SDK documentation is not very instructive, but the following page gives some info on how to calculate it: http://support.microsoft.com/kb/145999/EN-US/ To convert device units to 0.01 mm units, multiply the size in device units by 100.0 * GetDeviceCaps(refDC, HORZSIZE) / GetDeviceCaps(refDC, HORZRES) and 100.0 * GetDeviceCaps(refDC, VERTSIZE) / GetDeviceCaps(refDC, VERTRES) where refDC is the DC passed to CreateEnhMetaFile. The existing code sort of uses the factor 25.4 instead, but that is not correct. On my system the above expression evaluates to 31.25 I have tested this on a few drawings on which it seems to work fine, the image fits exactly inside the boundary. I use Windows XP and have checked the WMF files using Powerpoint 2002 (XP) and the built-in image viewer in Win XP. I'll attach a patch. There is one think I don't like about it, and that is that I had to divide scale by 2 (exact value not important I think), otherwise a small strip at the right and bottom of the image was missing even though the bounding rectangle was correct, possibly due to some smallint overflow. If one does not want to pass values larger than what will fit in a smallint to CreateEnhMetaFile then it would be possible to divide scale by MAX(100.0 * GetDeviceCaps(refDC, HORZSIZE) / GetDeviceCaps(refDC, HORZRES), 100.0 * GetDeviceCaps(refDC, VERTSIZE) / GetDeviceCaps(refDC, VERTRES)) instead. What do you think?
Created attachment 32893 [details] [review] A hopefully reasonably patch for WMF export plugin
Beside some small namespace glitch reasonable enough to apply it! (Robert: are there any more patches of you I should look at ;-) 2004-10-31 Hans Breuer <hans@breuer.org> * plug-ins/wmf/wmf_gdi.cpp plug-ins/wmf/wmf_gdi.h : added GetDeviceCaps() dummy implementation to make 'wmf' compile on Linux, too. 2004-10-31 Hans Breuer <hans@breuer.org> * plug-ins/wmf/wmf.cpp : patch from Robert Ögren <gtk@roboros.com> to finally fix the long lasting clipping issue, bug #85831 Also fixed the line style issue for printing on XP and don't miss to ReleaseDC() * plug-ins/wmf/wmf_gdi.[hc] : added ReleaseDC()
Hans: yes, you might want to look at my patch for bug #137551 in GTK+, which affects Dia as well on win32.
*** Bug 160891 has been marked as a duplicate of this bug. ***
*** Bug 165978 has been marked as a duplicate of this bug. ***
*** Bug 166300 has been marked as a duplicate of this bug. ***
*** Bug 323012 has been marked as a duplicate of this bug. ***
This bug is back / still present in 0.97.2 on Windows. It affects export to EMF, WMF and Copy Drawing. Please can we fix again?