is there any way to avoid Chart Canvas to be resized when it's been exported for printing?
Example:
Code: Select all
private void testdummyprint()
{
var prtDlg = new PrintDialog();
FlowDocument doc = new FlowDocument();
doc.Name = "Test";
doc.PageHeight = (96 / 2.54)*29.7;
doc.PageWidth = (96 / 2.54) * 21;
doc.ColumnWidth = doc.PageWidth;
doc.ColumnGap = 0;
var tb = new Table();
var tr = new TableRow();
var s1 = new MemoryStream();
var s2 = new MemoryStream();
var s3 = new MemoryStream();
var image1 = new BitmapImage();
var image2 = new BitmapImage();
var image3 = new BitmapImage();
t1.Export.Image.Bitmap.Save(s1, t1.Bitmap(doc.PageWidth / 3, doc.PageHeight), doc.PageWidth / 3, doc.PageHeight);
t2.Export.Image.Bitmap.Save(s2, t2.Bitmap(doc.PageWidth / 3, doc.PageHeight), doc.PageWidth / 3, doc.PageHeight);
t3.Export.Image.Bitmap.Save(s3, t3.Bitmap(doc.PageWidth / 3, doc.PageHeight), doc.PageWidth / 3, doc.PageHeight);
image1.BeginInit();
image1.CacheOption = BitmapCacheOption.OnLoad;
s1.Position = 0;
image1.StreamSource = s1;
image1.EndInit();
image2.BeginInit();
s2.Position = 0;
image2.CacheOption = BitmapCacheOption.OnLoad;
image2.StreamSource = s2;
image2.EndInit();
image3.BeginInit();
s3.Position = 0;
image3.CacheOption = BitmapCacheOption.OnLoad;
image3.StreamSource = s3;
image3.EndInit();
var block1 = new BlockUIContainer(new System.Windows.Controls.Image() { Source = image1 });
var block2 = new BlockUIContainer(new System.Windows.Controls.Image() { Source = image2 });
var block3 = new BlockUIContainer(new System.Windows.Controls.Image() { Source = image3 });
tr.Cells.Add(new TableCell(block1));
tr.Cells.Add(new TableCell(block2));
tr.Cells.Add(new TableCell(block3));
var tgr = new TableRowGroup();
tgr.Rows.Add(tr);
tb.RowGroups.Add(tgr);
doc.Blocks.Add(tb);
IDocumentPaginatorSource idpSource = doc;
prtDlg.PrintDocument(idpSource.DocumentPaginator, "Hello WPF Printing.");
}
i want to print all charts in one page, but with function linked all canvas chart are resized to new size.
there's any way to avoid this effect?
Thanks
Best Regards,
Geomisure