C
Craig Scheets
I have writting an application that prints fine, but I have to do a
TranslateTransform on the graphics in the OnPagePrint event to get place
output at exact X,Y (the application prints checks and must be placed
accurately).
However, when I do a print preview if I do the same translateTransform part
of the graphics is often just off the edge of the preview. Is there a way
to determine inside the OnPagePrint event if it's just a preview or the real
print function? I want to supress the TranslateTransform() if it's only a
preview.
I know I could rig something up with a global bool and set it when I do the
printPreviewDialog but I print in a seperate thread so it could be ugly and
less than perfect. This also wouldn't take into account if they clicked the
print button from within the preview window. Is there a more elegant way?
The relevant code is as follows:
private void docCheck_PrintPage(object sender, PrintPageEventArgs e)
{
//Shift the final graphics based on the printer offsets
//each "mark" from calibration sheet entered in numX & numY are equal to
3/100"
float xInchOffset = (float) xOffset *3 /100;
float yInchOffset = (float) yOffset *3 /100;
//HERE IS WHERE I WANT TO DO THE "if (!PrintPreview)" CODE TO SKIP THE NEXT
LINE
e.Graphics.TranslateTransform((float)xOffset *3,(float)yOffset *3);
Thanks,
Craig
TranslateTransform on the graphics in the OnPagePrint event to get place
output at exact X,Y (the application prints checks and must be placed
accurately).
However, when I do a print preview if I do the same translateTransform part
of the graphics is often just off the edge of the preview. Is there a way
to determine inside the OnPagePrint event if it's just a preview or the real
print function? I want to supress the TranslateTransform() if it's only a
preview.
I know I could rig something up with a global bool and set it when I do the
printPreviewDialog but I print in a seperate thread so it could be ugly and
less than perfect. This also wouldn't take into account if they clicked the
print button from within the preview window. Is there a more elegant way?
The relevant code is as follows:
private void docCheck_PrintPage(object sender, PrintPageEventArgs e)
{
//Shift the final graphics based on the printer offsets
//each "mark" from calibration sheet entered in numX & numY are equal to
3/100"
float xInchOffset = (float) xOffset *3 /100;
float yInchOffset = (float) yOffset *3 /100;
//HERE IS WHERE I WANT TO DO THE "if (!PrintPreview)" CODE TO SKIP THE NEXT
LINE
e.Graphics.TranslateTransform((float)xOffset *3,(float)yOffset *3);
Thanks,
Craig