Profile Picture

printing is slow

Posted By Tal Harari 14 Years Ago
Author
Message
Tal Harari
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 19, Visits: 2
Hi,
I'm using the NPrintManager to print my charts.
It seems to take a long time for the printing to be is done.
I'm just initializing a Print Manager using my NChartControl and call its Print method, and it takes it over 30 seconds to start printing (in the meantime there is a nevron message telling me its printing).
I can't figure out why because when i print a chart from the examples (the printing example) it does'nt take that much time.
Is there a way to cut down the printing time?
Maybe it's related to the fact that i have multiple charts in my Chart Control?

I'd appreciate some help.

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Tal,

Priniting can be computationally expensive if the chart graphics is operating in 3D or uses image filter effects. This is because the typical printer resolution these days is 600dpi which is six times the resolution of the screen. Consequently when the chart rasterizers it will require a 6x6 = 36 times more memory/CPU power if it renders a raster for such resolution. The component tries to reduce this complexity in the case of image filter effects by reducing the image filters kernel sizes and other techniques, but simply put rendering with good print quality is expensive. Plain 2D is much faster as in this case the control renders vector images that are in turn rasterized by the printer. If you use custom printing you can export images with 300dpi which will make things much faster and still retain good print quality. Can you post the code for the problematic chart configuration?



Best Regards,
Nevron Support Team



Tal Harari
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)Junior Member (19 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 19, Visits: 2
Sorry, I cant post my code here..

Although I understood why my printing is slow, I still don't know what to do about it..
You're telling me I need to use custom printing? How can I do that?


Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Tal,

You can take a look at the All Examples\Printing\Custom Printing example. It shows how to create a print document and output contents in it. You have to slightly modify the example:

private NRectangleF ConvertRectInPixels(NRectangleF rect, NResolution resolution)

{

// obtain the canvas and window bounds in pixels

NMeasurementUnit inch = NGraphicsUnit.Inch;

NMeasurementUnit pixel = NGraphicsUnit.Pixel;

NMeasurementUnitConverter converter = new NMeasurementUnitConverter(resolution);

rect = converter.ConvertRect(inch, pixel, rect);

// multiply by 0.01 (arguments are measured in hundreds of an inch)

rect.Scale(0.01f, 0.01f);

return rect;

}

private void OnPrintPage(object sender, PrintPageEventArgs ev)

{

RectangleF marginBounds = new RectangleF(ev.MarginBounds.Left, ev.MarginBounds.Top, ev.MarginBounds.Width, ev.MarginBounds.Height);

// create header and footer

string header = "Custom Header";

string footer = "Custom Footer";

Font font = new Font("Arial", 15);

Brush brush = new SolidBrush(Color.Black);

// measure them

SizeF headerSize = ev.Graphics.MeasureString(header, font);

SizeF footerSize = ev.Graphics.MeasureString(footer, font);

// draw header

RectangleF headerBounds = new RectangleF(marginBounds.Left, marginBounds.Top, marginBounds.Width, headerSize.Height);

ev.Graphics.DrawString(header, font, brush, headerBounds);

// draw chart

NRectangleF drawBounds = new NRectangleF(marginBounds.Left, headerBounds.Bottom, marginBounds.Width, marginBounds.Height - headerSize.Height - footerSize.Height);

NRectangleF rect = ConvertRectInPixels(drawBounds, new NResolution(96, 96));

using (Bitmap chartBitmap = new Bitmap((int)rect.Width, (int)rect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))

{

nChartControl1.ImageExporter.RenderToBitmap(chartBitmap, false);

ev.Graphics.DrawImage(chartBitmap, drawBounds.X, drawBounds.Y, drawBounds.Width, drawBounds.Height );

}

// draw footer

RectangleF footerBounds = new RectangleF(marginBounds.Left, marginBounds.Bottom - footerSize.Height, marginBounds.Width, footerSize.Height);

ev.Graphics.DrawString(footer, font, brush, footerBounds);

// dispose objects

font.Dispose();

brush.Dispose();

}

The code above prints with 96 dpi output and rescales the generated image - it will be substentially faster than using native printing resolution, especially in 3D at the cost of reduced quality.

 



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic