Click here to Skip to main content
15,889,096 members
Home / Discussions / C#
   

C#

 
AnswerRe: Ftp Linux Command in .Net Pin
blackjack215023-Apr-09 2:57
blackjack215023-Apr-09 2:57 
QuestionNeed assistance with automatic install application Pin
Robert Madsen21-Apr-09 17:13
professionalRobert Madsen21-Apr-09 17:13 
AnswerRe: Need assistance with automatic install application Pin
Perry Holman21-Apr-09 19:38
Perry Holman21-Apr-09 19:38 
GeneralRe: Need assistance with automatic install application Pin
Robert Madsen24-Apr-09 16:34
professionalRobert Madsen24-Apr-09 16:34 
AnswerRe: Need assistance with automatic install application Pin
Giorgi Dalakishvili21-Apr-09 19:40
mentorGiorgi Dalakishvili21-Apr-09 19:40 
GeneralRe: Need assistance with automatic install application Pin
Robert Madsen24-Apr-09 16:30
professionalRobert Madsen24-Apr-09 16:30 
QuestionHow to click on a website when it's minimized Pin
jeanbern21-Apr-09 17:08
jeanbern21-Apr-09 17:08 
QuestionRotate printing Pin
damichab21-Apr-09 16:31
damichab21-Apr-09 16:31 
Hi.

I am still trying to rotate output to the printer.... OMG | :OMG:

I am trying to reverse the output being sent to a label printer to match the preprinted paper that it is preloaded with.

Some of the printing is done by sending rich text to a Graphics.GetHdc(), the rest is via use of Graphics.DrawXYZ() methods.

Because the Matrix class ignores anything sent directly to a device context, I have used a bitmap to draw on. I can then rotate the graphics object using the Matrix.RotateAt() and then draw the previously drawn on bitmap on it. Problem is, by using a bitmap, the printed output is less than desirable (very pixelated to say the least). I did play with the SetWorldTransform() method, but this seems incompatable with Graphics draw methods. I have been going around in circles and going out of my mind here.

I have butchered the applicable code from the program to make an example of where I need help. Not sure if it will compile, but it should all be there (should be good enough for demonstration purposes anyway). This method would be called from the PrintDocument class.

private void OnPrintThePage(object sender, PrintPageEventArgs e)
{
    float mmTo100thInches = 1.0f / 25.4f * 100.0f;
    int width = 60 * mmTo100thInches;
    int height = 120 * mmTo100thInches; //  mm converted to 1/100th inch
    Graphics g;

    Matrix m = new Matrix();
    m.RotateAt(180f, new PointF(width / 2, height / 2));
    e.Graphics.Transform = m;

    Bitmap bitmap = new Bitmap(width, height);
    bitmap.SetResolution(300, 300);

    g = Graphics.FromImage(bitmap);
    //g.Graphics.DrawXYZ()...

    e.Graphics.DrawImage(bitmap, 0, 0);
    e.HasMorePages = false;
}


Without the line: bitmap.SetResolution(300, 300); It prints as it should, that is upside down and correctly scaled, but looking pixelated. With that line in place, the printing looks quite good and orientated correctly but at about a quarter the size it should be.

I would be most grateful it somebody could tell me where I am going wrong. I have tried to adapt an example out of Charles Petzold's "Programming Microsoft Windows with C#". He explains the need to match the resolution to the bitmap to the printer DPI. I just cannot make it work.

Regards,

David.
AnswerRe: Rotate printing Pin
Luc Pattyn21-Apr-09 16:54
sitebuilderLuc Pattyn21-Apr-09 16:54 
GeneralRe: Rotate printing Pin
damichab21-Apr-09 17:12
damichab21-Apr-09 17:12 
GeneralRe: Rotate printing Pin
Luc Pattyn21-Apr-09 17:42
sitebuilderLuc Pattyn21-Apr-09 17:42 
GeneralRe: Rotate printing Pin
damichab21-Apr-09 17:50
damichab21-Apr-09 17:50 
GeneralRe: Rotate printing Pin
Luc Pattyn21-Apr-09 18:02
sitebuilderLuc Pattyn21-Apr-09 18:02 
GeneralRe: Rotate printing Pin
damichab21-Apr-09 19:15
damichab21-Apr-09 19:15 
GeneralRe: Rotate printing Pin
damichab21-Apr-09 19:18
damichab21-Apr-09 19:18 
GeneralRe: Rotate printing Pin
Luc Pattyn22-Apr-09 0:31
sitebuilderLuc Pattyn22-Apr-09 0:31 
GeneralRe: Rotate printing Pin
damichab22-Apr-09 1:23
damichab22-Apr-09 1:23 
GeneralRe: Rotate printing Pin
Luc Pattyn22-Apr-09 2:08
sitebuilderLuc Pattyn22-Apr-09 2:08 
GeneralRe: Rotate printing Pin
damichab22-Apr-09 4:18
damichab22-Apr-09 4:18 
GeneralRe: Rotate printing Pin
Luc Pattyn22-Apr-09 5:36
sitebuilderLuc Pattyn22-Apr-09 5:36 
GeneralRe: Rotate printing Pin
damichab22-Apr-09 21:01
damichab22-Apr-09 21:01 
GeneralRe: Rotate printing Pin
Luc Pattyn23-Apr-09 1:19
sitebuilderLuc Pattyn23-Apr-09 1:19 
GeneralRe: Rotate printing Pin
damichab23-Apr-09 2:06
damichab23-Apr-09 2:06 
GeneralRe: Rotate printing Pin
Luc Pattyn23-Apr-09 2:44
sitebuilderLuc Pattyn23-Apr-09 2:44 
GeneralRe: Rotate printing Pin
damichab23-Apr-09 3:31
damichab23-Apr-09 3:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.