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);
}
==================== 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);
}
====================
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);
}
====================
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);
}
====================
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); } ====================
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); } ==================== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: defcon8 |
last post by:
How can I print html documents in Python on Windows?
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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...
|
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...
| |