DrawString with opacity option not print properly
-
its not null its come from here
private void PrintDocument1_PrintPage(object sender, PrintPageEventArgs pe)
Thanks - I assumed it would, but when it's explicitly shown as a new declaration it needs to be confirmed.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
its not null its come from here
private void PrintDocument1_PrintPage(object sender, PrintPageEventArgs pe)
When you say "the text not fully visible" what exactly do you mean?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
Thanks - I assumed it would, but when it's explicitly shown as a new declaration it needs to be confirmed.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
When you say "the text not fully visible" what exactly do you mean?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
is there any option to show the image how can i upload my drawing image to describe u better
No, because we get some idiots here who would post ... ummm ... objectional material X| You wouldn't believe what tries to get through moderation ATM, and we can't moderate every post, there aren't enough of us volunteers to do that. And you don't have sufficient rep yet to store images here. You could put it up on Dropbox / Google and provide a link?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
No, because we get some idiots here who would post ... ummm ... objectional material X| You wouldn't believe what tries to get through moderation ATM, and we can't moderate every post, there aren't enough of us volunteers to do that. And you don't have sufficient rep yet to store images here. You could put it up on Dropbox / Google and provide a link?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
actual design like this Actual_Label.png - Google Drive[^] and printed like this Label_print.png - Google Drive[^] but when i draw string horizontally its print like original one more thing when i check its print preview its looks perfect,so why its not print ok thats why i cant understand where is the problem
-
actual design like this Actual_Label.png - Google Drive[^] and printed like this Label_print.png - Google Drive[^] but when i draw string horizontally its print like original one more thing when i check its print preview its looks perfect,so why its not print ok thats why i cant understand where is the problem
OK - I'm trying to duplicate exactly what you have, but ... your code won't compile without errors and I don't want to fix them in case I "fix them wrong". For example:
RectangleF dr_rect = new RectangleF(new Point(X, Y, new Size(image_draw_wd, ((int)sz.Height) + extra_margin));
Missing a close bracket (at a guess, after the "Point(X, Y" is where it goes). PrintPageEventArgs doesn't contain methods MeasureString, TranslateTransform, and RotateTransform: PrintPageEventAgrs.Graphics does. If that is copy'n'pasted from your app, then it's possible you are testing an older version of your source - in which case the display fault may no longer exist if you fix that code.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
actual design like this Actual_Label.png - Google Drive[^] and printed like this Label_print.png - Google Drive[^] but when i draw string horizontally its print like original one more thing when i check its print preview its looks perfect,so why its not print ok thats why i cant understand where is the problem
If I bodge up your code (fix the errors, use substitutes for external bits I don't have) it works ok in preview for me:
private void FrmMain\_Shown(object sender, EventArgs e) { PrintDocument pd = new PrintDocument(); pd.PrintPage += Pd\_PrintPage; PrintPreviewDialog pdi = new PrintPreviewDialog { Document = pd }; pdi.ShowDialog(); } private void Pd\_PrintPage(object sender, PrintPageEventArgs pe) { int X = 0; int Y = 0; RectangleF rect2 = panel2.ClientRectangle; float image\_draw\_wd = panel2.Width; float image\_draw\_ht = panel2.Height; Brush myBrush = new SolidBrush(Color.FromArgb(128, Color.Blue)); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.FormatFlags = StringFormatFlags.LineLimit; stringFormat.Trimming = StringTrimming.Word; SizeF sz = pe.Graphics.MeasureString("A line of text to display", Font, (int)image\_draw\_wd, stringFormat); double angle = 0; double angleRadians = Math.Atan2(image\_draw\_ht, image\_draw\_wd); angle = angleRadians \* 180.0 / Math.PI; pe.Graphics.TranslateTransform((rect2.Location.X + rect2.Width / 2), (rect2.Location.Y + rect2.Height / 2)); pe.Graphics.RotateTransform((float)angle);// + flip180Image); pe.Graphics.TranslateTransform(-(rect2.Location.X + rect2.Width / 2), -(rect2.Location.Y + rect2.Height / 2)); X = 10;// (int)(panel2.Width - sz.Width) / 2; Y = 10; // (int)(panel2.Height - sz.Height) / 2; RectangleF dr\_rect = new RectangleF(new Point(X, Y), new Size((int) image\_draw\_wd, ((int)sz.Height) + 10)); pe.Graphics.DrawString("A line of text to display", Font, myBrush, dr\_rect, stringFormat); }
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
If I bodge up your code (fix the errors, use substitutes for external bits I don't have) it works ok in preview for me:
private void FrmMain\_Shown(object sender, EventArgs e) { PrintDocument pd = new PrintDocument(); pd.PrintPage += Pd\_PrintPage; PrintPreviewDialog pdi = new PrintPreviewDialog { Document = pd }; pdi.ShowDialog(); } private void Pd\_PrintPage(object sender, PrintPageEventArgs pe) { int X = 0; int Y = 0; RectangleF rect2 = panel2.ClientRectangle; float image\_draw\_wd = panel2.Width; float image\_draw\_ht = panel2.Height; Brush myBrush = new SolidBrush(Color.FromArgb(128, Color.Blue)); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.FormatFlags = StringFormatFlags.LineLimit; stringFormat.Trimming = StringTrimming.Word; SizeF sz = pe.Graphics.MeasureString("A line of text to display", Font, (int)image\_draw\_wd, stringFormat); double angle = 0; double angleRadians = Math.Atan2(image\_draw\_ht, image\_draw\_wd); angle = angleRadians \* 180.0 / Math.PI; pe.Graphics.TranslateTransform((rect2.Location.X + rect2.Width / 2), (rect2.Location.Y + rect2.Height / 2)); pe.Graphics.RotateTransform((float)angle);// + flip180Image); pe.Graphics.TranslateTransform(-(rect2.Location.X + rect2.Width / 2), -(rect2.Location.Y + rect2.Height / 2)); X = 10;// (int)(panel2.Width - sz.Width) / 2; Y = 10; // (int)(panel2.Height - sz.Height) / 2; RectangleF dr\_rect = new RectangleF(new Point(X, Y), new Size((int) image\_draw\_wd, ((int)sz.Height) + 10)); pe.Graphics.DrawString("A line of text to display", Font, myBrush, dr\_rect, stringFormat); }
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
Yes, but your code doesn't compile, so that has to be taken with a pinch of salt! :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
And if I change my code:
private void FrmMain\_Shown(object sender, EventArgs e) { PrintDocument pd = new PrintDocument(); pd.PrintPage += Pd\_PrintPage; PrintDialog pdi = new PrintDialog { Document = pd }; pdi.ShowDialog(); pd.Print();
It prints fine to PDF, XPS, OneNote, ... So the code seems OK as far as I can see. So ... what happens if you fix the compiler errors, and print to - say - OneNote?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
And if I change my code:
private void FrmMain\_Shown(object sender, EventArgs e) { PrintDocument pd = new PrintDocument(); pd.PrintPage += Pd\_PrintPage; PrintDialog pdi = new PrintDialog { Document = pd }; pdi.ShowDialog(); pd.Print();
It prints fine to PDF, XPS, OneNote, ... So the code seems OK as far as I can see. So ... what happens if you fix the compiler errors, and print to - say - OneNote?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
private void Pd_PrintPage(object sender, PrintPageEventArgs pe)
{string watermarkText = "Your Name © 2015, All Rights Reserved"; Font watermarkFont = new Font("Microsoft Sans Serif", 18, FontStyle.Bold); int X = 0; int Y = 0; RectangleF rect2 = panel2.ClientRectangle; float image\_draw\_wd = panel2.Width; float image\_draw\_ht = panel2.Height; Brush myBrush = new SolidBrush(Color.FromArgb(128, Color.Blue)); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.FormatFlags = StringFormatFlags.LineLimit; stringFormat.Trimming = StringTrimming.Word; SizeF sz = pe.Graphics.MeasureString(watermarkText, watermarkFont, (int)image\_draw\_wd, stringFormat); double angle = 0; double angleRadians = Math.Atan2(image\_draw\_ht, image\_draw\_wd); angle = angleRadians \* 180.0 / Math.PI; pe.Graphics.TranslateTransform((rect2.Location.X + rect2.Width / 2), (rect2.Location.Y + rect2.Height / 2)); pe.Graphics.RotateTransform((float)angle);// + flip180Image); pe.Graphics.TranslateTransform(-(rect2.Location.X + rect2.Width / 2), -(rect2.Location.Y + rect2.Height / 2)); X = 10; X = (int)(panel2.Width - sz.Width) / 2; Y = 10; Y = (int)(panel2.Height - sz.Height) / 2; RectangleF dr\_rect = new RectangleF(new Point(X, Y), new Size((int)image\_draw\_wd, ((int)sz.Height) + 10)); pe.Graphics.DrawString(watermarkText, watermarkFont, myBrush, dr\_rect, stringFormat); }
preview , pdf n all looks same n fine why its not print on actual printer my model is HP deskjet gt 5811
-
private void Pd_PrintPage(object sender, PrintPageEventArgs pe)
{string watermarkText = "Your Name © 2015, All Rights Reserved"; Font watermarkFont = new Font("Microsoft Sans Serif", 18, FontStyle.Bold); int X = 0; int Y = 0; RectangleF rect2 = panel2.ClientRectangle; float image\_draw\_wd = panel2.Width; float image\_draw\_ht = panel2.Height; Brush myBrush = new SolidBrush(Color.FromArgb(128, Color.Blue)); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.FormatFlags = StringFormatFlags.LineLimit; stringFormat.Trimming = StringTrimming.Word; SizeF sz = pe.Graphics.MeasureString(watermarkText, watermarkFont, (int)image\_draw\_wd, stringFormat); double angle = 0; double angleRadians = Math.Atan2(image\_draw\_ht, image\_draw\_wd); angle = angleRadians \* 180.0 / Math.PI; pe.Graphics.TranslateTransform((rect2.Location.X + rect2.Width / 2), (rect2.Location.Y + rect2.Height / 2)); pe.Graphics.RotateTransform((float)angle);// + flip180Image); pe.Graphics.TranslateTransform(-(rect2.Location.X + rect2.Width / 2), -(rect2.Location.Y + rect2.Height / 2)); X = 10; X = (int)(panel2.Width - sz.Width) / 2; Y = 10; Y = (int)(panel2.Height - sz.Height) / 2; RectangleF dr\_rect = new RectangleF(new Point(X, Y), new Size((int)image\_draw\_wd, ((int)sz.Height) + 10)); pe.Graphics.DrawString(watermarkText, watermarkFont, myBrush, dr\_rect, stringFormat); }
preview , pdf n all looks same n fine why its not print on actual printer my model is HP deskjet gt 5811
At a guess, driver problems. I can't test that - I have a Samsung colour laser as I got fed up with inkjets never working when I needed them ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
At a guess, driver problems. I can't test that - I have a Samsung colour laser as I got fed up with inkjets never working when I needed them ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
No problem - sorry I can't do more!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!