473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Printing advice

I'm trying to print some of my document.
The problem is, the rendering of the document is not done through GDI+ at all but through plain old GDI, and I need it like that as I am using Uniscribe to layout text.

Anyway, when printing the text is completely out of place, I wonder if it's due to incorrrect Dpi settings? (or something else?)
I will investigate that.....

Anyway if any of you had similar experience and could shed some light?
Here is how I initialize my HDC (Managed C++):
====================
struct HDCInfo
{
HDC hdc;
// to be restored
HGDIOBJ font0;
HGDIOBJ brush0;
HGDIOBJ pen0;
XFORM transform0;
};
void NText::ScriptAnalysis::GetHDC(Graphics^ g, struct HDCInfo& info)
{
array<float>^ matrix = g->Transform->Elements;
pin_ptr<float> p_transform = &matrix[0];

info.hdc = (HDC)(void*)g->GetHdc(true);
info.font0 = ::GetCurrentObject(info.hdc, OBJ_FONT);
info.brush0 = ::GetCurrentObject(info.hdc, OBJ_BRUSH);
info.pen0 = ::GetCurrentObject(info.hdc, OBJ_PEN);
::GetWorldTransform(info.hdc, &info.transform0);

::SetGraphicsMode(info.hdc, GM_ADVANCED);
::SetBkMode(info.hdc, TRANSPARENT);
::SetWorldTransform(info.hdc, (XFORM*) p_transform);
}
====================
Nov 17 '05 #1
5 1411
All my text output looks like shrink.
I mean all the characters are correctly positioned compare to each other, but it just occupies the top left quadrant.

"Lloyd Dupont" <net.galador@ld> wrote in message news:uD**************@TK2MSFTNGP15.phx.gbl...
I'm trying to print some of my document.
The problem is, the rendering of the document is not done through GDI+ at all but through plain old GDI, and I need it like that as I am using Uniscribe to layout text.

Anyway, when printing the text is completely out of place, I wonder if it's due to incorrrect Dpi settings? (or something else?)
I will investigate that.....

Anyway if any of you had similar experience and could shed some light?
Here is how I initialize my HDC (Managed C++):
====================
struct HDCInfo
{
HDC hdc;
// to be restored
HGDIOBJ font0;
HGDIOBJ brush0;
HGDIOBJ pen0;
XFORM transform0;
};
void NText::ScriptAnalysis::GetHDC(Graphics^ g, struct HDCInfo& info)
{
array<float>^ matrix = g->Transform->Elements;
pin_ptr<float> p_transform = &matrix[0];

info.hdc = (HDC)(void*)g->GetHdc(true);
info.font0 = ::GetCurrentObject(info.hdc, OBJ_FONT);
info.brush0 = ::GetCurrentObject(info.hdc, OBJ_BRUSH);
info.pen0 = ::GetCurrentObject(info.hdc, OBJ_PEN);
::GetWorldTransform(info.hdc, &info.transform0);

::SetGraphicsMode(info.hdc, GM_ADVANCED);
::SetBkMode(info.hdc, TRANSPARENT);
::SetWorldTransform(info.hdc, (XFORM*) p_transform);
}
====================
Nov 17 '05 #2
The Preview doesn't display text all :-(
And the printing just shrinking it ?!?.....
"Lloyd Dupont" <net.galador@ld> wrote in message news:uD**************@TK2MSFTNGP15.phx.gbl...
I'm trying to print some of my document.
The problem is, the rendering of the document is not done through GDI+ at all but through plain old GDI, and I need it like that as I am using Uniscribe to layout text.

Anyway, when printing the text is completely out of place, I wonder if it's due to incorrrect Dpi settings? (or something else?)
I will investigate that.....

Anyway if any of you had similar experience and could shed some light?
Here is how I initialize my HDC (Managed C++):
====================
struct HDCInfo
{
HDC hdc;
// to be restored
HGDIOBJ font0;
HGDIOBJ brush0;
HGDIOBJ pen0;
XFORM transform0;
};
void NText::ScriptAnalysis::GetHDC(Graphics^ g, struct HDCInfo& info)
{
array<float>^ matrix = g->Transform->Elements;
pin_ptr<float> p_transform = &matrix[0];

info.hdc = (HDC)(void*)g->GetHdc(true);
info.font0 = ::GetCurrentObject(info.hdc, OBJ_FONT);
info.brush0 = ::GetCurrentObject(info.hdc, OBJ_BRUSH);
info.pen0 = ::GetCurrentObject(info.hdc, OBJ_PEN);
::GetWorldTransform(info.hdc, &info.transform0);

::SetGraphicsMode(info.hdc, GM_ADVANCED);
::SetBkMode(info.hdc, TRANSPARENT);
::SetWorldTransform(info.hdc, (XFORM*) p_transform);
}
====================
Nov 17 '05 #3
I tried to multiply my world transform matrix by thes factor:
static int TextPrintScale(HDC& hdc)
{
HDC screenDc = GetDC(NULL);
int screenDpi = GetDeviceCaps(screenDc, LOGPIXELSX);
ReleaseDC(NULL, screenDc);
int devDpi = GetDeviceCaps(hdc, LOGPIXELSX);
return devDpi / screenDpi;
}

the weird thing is, it work well if I use this integer division of devDpi / screenDpi.
But first I tryed to used a float factor by returning:
return ((float) devDpi) / screenDpi;

And this was clearly wrong, (the page was clearly scaled too much as if 3 was right but 300.0 / 96.0 was not).
I'm kind of confused about that, I would have expect the float division to be right.
Any thoughts?

Also whatever I do the System.Windows.Forms.PrintPreviewDialog still display no text at all.... :-/

"Lloyd Dupont" <net.galador@ld> wrote in message news:uD**************@TK2MSFTNGP15.phx.gbl...
I'm trying to print some of my document.
The problem is, the rendering of the document is not done through GDI+ at all but through plain old GDI, and I need it like that as I am using Uniscribe to layout text.

Anyway, when printing the text is completely out of place, I wonder if it's due to incorrrect Dpi settings? (or something else?)
I will investigate that.....

Anyway if any of you had similar experience and could shed some light?
Here is how I initialize my HDC (Managed C++):
====================
struct HDCInfo
{
HDC hdc;
// to be restored
HGDIOBJ font0;
HGDIOBJ brush0;
HGDIOBJ pen0;
XFORM transform0;
};
void NText::ScriptAnalysis::GetHDC(Graphics^ g, struct HDCInfo& info)
{
array<float>^ matrix = g->Transform->Elements;
pin_ptr<float> p_transform = &matrix[0];

info.hdc = (HDC)(void*)g->GetHdc(true);
info.font0 = ::GetCurrentObject(info.hdc, OBJ_FONT);
info.brush0 = ::GetCurrentObject(info.hdc, OBJ_BRUSH);
info.pen0 = ::GetCurrentObject(info.hdc, OBJ_PEN);
::GetWorldTransform(info.hdc, &info.transform0);

::SetGraphicsMode(info.hdc, GM_ADVANCED);
::SetBkMode(info.hdc, TRANSPARENT);
::SetWorldTransform(info.hdc, (XFORM*) p_transform);
}
====================
Nov 17 '05 #4
Lloyd,

You might try cc'ing the folks in
microsoft.public.dotnet.framework.drawing. They may be able to help you.

Jason

Lloyd Dupont wrote:
I tried to multiply my world transform matrix by thes factor:
static int TextPrintScale(HDC& hdc)
{
HDC screenDc = GetDC(NULL);
int screenDpi = GetDeviceCaps(screenDc, LOGPIXELSX);
ReleaseDC(NULL, screenDc);
int devDpi = GetDeviceCaps(hdc, LOGPIXELSX);
return devDpi / screenDpi;
}

the weird thing is, it work well if I use this integer division of
devDpi / screenDpi.
But first I tryed to used a float factor by returning:
return ((float) devDpi) / screenDpi;

And this was clearly wrong, (the page was clearly scaled too much as if
3 was right but 300.0 / 96.0 was not).
I'm kind of confused about that, I would have expect the float division
to be right.
Any thoughts?

Also whatever I do the System.Windows.Forms.PrintPreviewDialog still
display no text at all.... :-/
"Lloyd Dupont" <net.galador@ld <mailto:net.galador@ld>> wrote in
message news:uD**************@TK2MSFTNGP15.phx.gbl...
I'm trying to print some of my document.
The problem is, the rendering of the document is not done through
GDI+ at all but through plain old GDI, and I need it like that as I
am using Uniscribe to layout text.

Anyway, when printing the text is completely out of place, I wonder
if it's due to incorrrect Dpi settings? (or something /else/?)
I will investigate that.....

Anyway if any of you had similar experience and could shed some light?
Here is how I initialize my HDC (Managed C++):
====================
struct HDCInfo
{
HDC hdc;
// to be restored
HGDIOBJ font0;
HGDIOBJ brush0;
HGDIOBJ pen0;
XFORM transform0;
};
void NText::ScriptAnalysis::GetHDC(Graphics^ g, struct HDCInfo& info)
{
array<float>^ matrix = g->Transform->Elements;
pin_ptr<float> p_transform = &matrix[0];

info.hdc = (HDC)(void*)g->GetHdc(true);
info.font0 = ::GetCurrentObject(info.hdc, OBJ_FONT);
info.brush0 = ::GetCurrentObject(info.hdc, OBJ_BRUSH);
info.pen0 = ::GetCurrentObject(info.hdc, OBJ_PEN);
::GetWorldTransform(info.hdc, &info.transform0);

::SetGraphicsMode(info.hdc, GM_ADVANCED);
::SetBkMode(info.hdc, TRANSPARENT);
::SetWorldTransform(info.hdc, (XFORM*) p_transform);
}
====================

Nov 17 '05 #5
good idea Jason, thanks! ;-)

"Jason Newell" <no****@nospam.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Lloyd,

You might try cc'ing the folks in
microsoft.public.dotnet.framework.drawing. They may be able to help you.

Jason

Lloyd Dupont wrote:
I tried to multiply my world transform matrix by thes factor:
static int TextPrintScale(HDC& hdc)
{
HDC screenDc = GetDC(NULL);
int screenDpi = GetDeviceCaps(screenDc, LOGPIXELSX);
ReleaseDC(NULL, screenDc);
int devDpi = GetDeviceCaps(hdc, LOGPIXELSX);
return devDpi / screenDpi;
}

the weird thing is, it work well if I use this integer division of devDpi
/ screenDpi.
But first I tryed to used a float factor by returning:
return ((float) devDpi) / screenDpi;
And this was clearly wrong, (the page was clearly scaled too much as if
3 was right but 300.0 / 96.0 was not).
I'm kind of confused about that, I would have expect the float division
to be right.
Any thoughts?
Also whatever I do the System.Windows.Forms.PrintPreviewDialog still
display no text at all.... :-/
"Lloyd Dupont" <net.galador@ld <mailto:net.galador@ld>> wrote in
message news:uD**************@TK2MSFTNGP15.phx.gbl...
I'm trying to print some of my document.
The problem is, the rendering of the document is not done through
GDI+ at all but through plain old GDI, and I need it like that as I
am using Uniscribe to layout text.
Anyway, when printing the text is completely out of place, I wonder
if it's due to incorrrect Dpi settings? (or something /else/?)
I will investigate that.....
Anyway if any of you had similar experience and could shed some
light?
Here is how I initialize my HDC (Managed C++):
====================
struct HDCInfo
{
HDC hdc;
// to be restored HGDIOBJ font0;
HGDIOBJ brush0;
HGDIOBJ pen0;
XFORM transform0;
};
void NText::ScriptAnalysis::GetHDC(Graphics^ g, struct HDCInfo& info)
{
array<float>^ matrix = g->Transform->Elements;
pin_ptr<float> p_transform = &matrix[0];

info.hdc = (HDC)(void*)g->GetHdc(true);
info.font0 = ::GetCurrentObject(info.hdc, OBJ_FONT);
info.brush0 = ::GetCurrentObject(info.hdc, OBJ_BRUSH);
info.pen0 = ::GetCurrentObject(info.hdc, OBJ_PEN);
::GetWorldTransform(info.hdc, &info.transform0);

::SetGraphicsMode(info.hdc, GM_ADVANCED);
::SetBkMode(info.hdc, TRANSPARENT);
::SetWorldTransform(info.hdc, (XFORM*) p_transform);
}
====================

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Chris | last post by:
Hello all, I wish to automate printing of PDF documents in a C# application. Is there an Adobe .net object? I tried to create a reference to the COM Object Adobe Type Library, but I get error...
1
by: slothboy | last post by:
Hey guys, I'm having a little trouble printing subforms. I've attached the snippet of code that prints my form which contains various subforms. It prints bounded controls on the subform just...
0
by: Karthik | last post by:
Well I am coding an application using C# for my company which requires multiple printing of Crystal Report Docs & Word Docs, at a specific Printer of the installed Printers in the network, at a...
3
by: Tim | last post by:
Hi, I am creating my own method for printing. I am using PrintDocument and cycling through the data and creating new pages as neccessary. My question is, how can I know that total number of...
1
by: appearinggalaxy | last post by:
Hi, I am trying to churn out some statistical data from database and print it out by using printdocument and printdialog, but I realised that the alignment of the data is gone, for instance, I...
6
by: J Ames | last post by:
I have an ASP.NET (VB) form that has two drop downs, a horizontal rule and a button. The button invokes a stored procedure and several tables are created on the page with data populated. I want...
3
by: defcon8 | last post by:
How can I print html documents in Python on Windows?
7
by: Burhan | last post by:
Hello Group: I am in the planning stages of an application that will be accessed over the web, and one of the ideas is to print a barcode that is generated when the user creates a record. The...
8
by: Frank Rizzo | last post by:
I am trying to print huge images (much bigger than target paper). I try and use e.PageSettings.HardMarginX and e.PageSettings.HardMarginY in the PrintDocument's PrintPage event to try and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.