Profile Picture

Printing Custom Page Widths

Posted By Ted O'Grady 14 Years Ago
Author
Message
Ted O'Grady
whistling Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 12, Visits: 1

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);
}



Ivo Milanov
Posted 14 Years Ago
View Quick Profile
Forum Member

Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)

Group: Forum Members
Last Active: 2 Months Ago
Posts: 35, Visits: 15
Hi,

The solution that you are using is inaccurate, since the drawing scale will apply scaling to the sizes, which are considered to be scene metrics (shape coordinates, document bounds etc.), but will leave unchanged font sizes, stroke width, arrowheads sizes etc. (all measurements that are considered to be presentation metrics).

The functionality that you request is actually implemented by the printing logic - in fact the Single Page Layout is just a local case of a custom virtual page size. So can include this request as a built in feature of Nevron Diagram for the next service pack.

Taking a look at Excel and Visio they both have an option to scale/zoom the printed content for either a custom zoom factor, or the factor needed to display the content fitted in user specified page rows/cols (wide/tall). This is however limiting in two ways:

1. There is no ability to specify alignment - both Excel and Visio use Top-Left alignment - where we think that user may need to apply center alignment, if for example he/she wants to scale to small zoom factor (create a small Excel Sheet and set the print scaling to 10%).

2. There is no ability to specify stretching. There are two types of stretching - one that preserves the aspect (Stretch to Width or Height) and general (Stretch) that applies irregular X and Y scaling to completely fill the available area.

Here are the options we thought for the Layout controls group of the print preview (similar settings will be of course implemented in the print manager):

Scale Mode:

- Zoom To - the user specifies a custom zoom factor. Vertical and Horizontal Alignment options are shown.
Aspect is preserved. The pages grid is automatically determined.

- Fit To Pages - aspect is preserved. User selects Row Pages Count and Col Pages Count. Vertical and Horizontal Alignment options are shown.

- Stretch To Pages Width - user selects Col Pages Count. The number of pages in height is automatically determined. Alignment of pages along height can be specified by Vertical Alignment (Top, Center, Bottom). Aspect is preserved.

- Stretch To Pages Height - user selects Row Pages Count. The number of pages in width is automatically determined. Alignment of pages along width is specified by Horizontal Alignment (Left, Center, Right). Aspect is preserved.

- Stretch To Pages - aspect is broken. User selects Row Pages Count and Col Pages Count. Vertical and Horizontal Alignment options are not shown.

Of course we can also implement Fit To, Stretch To XXX and Stretch to a virtual page size, but we do not know whether this will really be used, although that would give the ultimate flexibility to perform print zooming in all possible cases.

Let me know what you think about this - the implementation will start next week.

Best regards,
Ivo

Ted O'Grady
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 12, Visits: 1
Hi Ivo,

Thanks for your feedback!

Here's the priority list for *my* customers. Our experimentation has led to new learnings.

Motivation: In general their goal is to make the diagram fit on a wall - which they can estimate in terms of page counts. They still need to be able to read certain labels - even if the image has been shrunk. The diagram is used for reasoning about the flow of products between various facilities. There can be 1000's of facilities.

* Must have: *
MH1. -> Fit To Pages - aspect is preserved. User selects Row Pages Count and Col Pages Count. They know how many pages can fit on their wall

MH2. -> Ability to adjust certain elements size (namely certain labels/text) before printing (this will be done in the code). When they resize, it is important for them to be able to still read certain elements. (e.g. a hook into the zooming process would be nice)


* Nice to Have*
NTH1. -> Vertical and Horizontal Alignment options are shown.


At this point, the stretch options are not what *my* customer require, it is too hard for them to estimate the size of their wall and how much they should zoom the picture. Also, distortion of the image is not desired.

FYI: Next up for us, is plotter printing - our biggest customers have plotters.

Again thanks for your attention! It is much appreciated!

- ted



Similar Topics


Reading This Topic