Excel has this ability - to say how many pages wide by how many pages high you would like to print. It would be useful for my end users who have huge complex diagrams with lots (and lots) of connections. They tape pages together, but don't want too many.
The approach I'm taking is calculate the scale factors necessary to print the document on the page, scale it, print it and then remove the scaling, looks like the Routable connectors widths and fonts are not scaled, so I'll have to do something goofy there, like play with the style sheets.
Is there a better solution someone has found?
Thanks in advance for your help!
- ted
Here's my first attempt:
public void FitToPrint(NevronDrawingContext context) {
var printManager = new NPrintManager(context.Document);
PaperSize defaultPageSize = FindLedgerPageSize(printManager);
// configure the printer
PageSettings pageSettings = printManager.PageSettings;
pageSettings.Margins = new Margins(10, 10, 10, 10);
pageSettings.PaperSize = defaultPageSize;
pageSettings.Landscape = true;
printManager.PrintOnSinglePage = false;
// ask what the document should fit to
var pageDimensions = new PrintPageDimensionsDialog();
pageDimensions.ShowDialog();
// calculate a scaling factor
int paperWidth = 1700 - 100;
int paperHeight = 1100 - 100;
float scaleXFactor = pageDimensions.Wide*paperWidth/context.Document.Width;
float scaleYFactor = pageDimensions.High*paperHeight/context.Document.Height;
float scaleFactor = Math.Min(scaleXFactor, scaleYFactor);
context.Document.DrawingScaleMode = DrawingScaleMode.CustomScale;
context.Document.CustomScale = scaleFactor;
// goto the print dialog
printManager.ShowPrintPreview();
// cleanup
ResetScale(context);
}