javascript/examples/grapheditor/www/js/Editor.js
function preview(print)
	{
		var autoOrigin = onePageCheckBox.checked || pageCountCheckBox.checked;
		var printScale = parseInt(pageScaleInput.value) / 100;
		
		if (isNaN(printScale))
		{
			printScale = 1;
			pageScaleInput.value = '100%';
		}
		
		// Workaround to match available paper size in actual print output
		printScale *= 0.75;

		var pf = graph.pageFormat || mxConstants.PAGE_FORMAT_A4_PORTRAIT;
		var scale = 1 / graph.pageScale;
		
		if (autoOrigin)
		{
    		var pageCount = (onePageCheckBox.checked) ? 1 : parseInt(pageCountInput.value);
			
			if (!isNaN(pageCount))
			{
				scale = mxUtils.getScaleForPageCount(pageCount, graph, pf);
			}
		}

		// Negative coordinates are cropped or shifted if page visible
		var gb = graph.getGraphBounds();
		var border = 0;
		var x0 = 0;
		var y0 = 0;

		// Applies print scale
		pf = mxRectangle.fromRectangle(pf);
		pf.width = Math.ceil(pf.width * printScale);
		pf.height = Math.ceil(pf.height * printScale);
		scale *= printScale;
		
		// Starts at first visible page
		if (!autoOrigin && graph.pageVisible)
		{
			var layout = graph.getPageLayout();
			x0 -= layout.x * pf.width;
			y0 -= layout.y * pf.height;
		}
		else
		{
			autoOrigin = true;
		}
		
		var preview = PrintDialog.createPrintPreview(graph, scale, pf, border, x0, y0, autoOrigin);
		preview.open();
	
		if (print)
		{
			PrintDialog.printPreview(preview);
		}
	}
function preview(print)
	{
		var autoOrigin = onePageCheckBox.checked || pageCountCheckBox.checked;
		var printScale = parseInt(pageScaleInput.value) / 100;
		
		if (isNaN(printScale))
		{
			printScale = 1;
			pageScaleInput.value = '100%';
		}
		
		// Workaround to match available paper size in actual print output
		printScale *= 0.75;

		var pf = graph.pageFormat || mxConstants.PAGE_FORMAT_A4_PORTRAIT;
		var scale = 1 / graph.pageScale;
		
		if (autoOrigin)
		{
    		var pageCount = (onePageCheckBox.checked) ? 1 : parseInt(pageCountInput.value);
			
			if (!isNaN(pageCount))
			{
				scale = mxUtils.getScaleForPageCount(pageCount, graph, pf);
			}
		}

		// Negative coordinates are cropped or shifted if page visible
		var gb = graph.getGraphBounds();
		var border = 0;
		var x0 = 0;
		var y0 = 0;

		// Applies print scale
		pf = mxRectangle.fromRectangle(pf);
		pf.width = Math.ceil(pf.width * printScale);
		pf.height = Math.ceil(pf.height * printScale);
		scale *= printScale;
		
		// Starts at first visible page
		if (!autoOrigin && graph.pageVisible)
		{
			var layout = graph.getPageLayout();
			x0 -= layout.x * pf.width;
			y0 -= layout.y * pf.height;
		}
		else
		{
			autoOrigin = true;
		}
		
		var preview = PrintDialog.createPrintPreview(graph, scale, pf, border, x0, y0, autoOrigin);
		preview.open();
	
		if (print)
		{
			PrintDialog.printPreview(preview);
		}
	}
function preview ( print ) { var autoOrigin = onePageCheckBox . checked || pageCountCheckBox . checked ; var printScale = parseInt ( pageScaleInput . value ) / 100 ; if ( isNaN ( printScale ) ) { printScale = 1 ; pageScaleInput . value = '100%' ; } // Workaround to match available paper size in actual print output printScale *= 0.75 ; var pf = graph . pageFormat || mxConstants . PAGE_FORMAT_A4_PORTRAIT ; var scale = 1 / graph . pageScale ; if ( autoOrigin ) { var pageCount = ( onePageCheckBox . checked ) ? 1 : parseInt ( pageCountInput . value ) ; if ( ! isNaN ( pageCount ) ) { scale = mxUtils . getScaleForPageCount ( pageCount , graph , pf ) ; } } // Negative coordinates are cropped or shifted if page visible var gb = graph . getGraphBounds ( ) ; var border = 0 ; var x0 = 0 ; var y0 = 0 ; // Applies print scale pf = mxRectangle . fromRectangle ( pf ) ; pf . width = Math . ceil ( pf . width * printScale ) ; pf . height = Math . ceil ( pf . height * printScale ) ; scale *= printScale ; // Starts at first visible page if ( ! autoOrigin && graph . pageVisible ) { var layout = graph . getPageLayout ( ) ; x0 -= layout . x * pf . width ; y0 -= layout . y * pf . height ; } else { autoOrigin = true ; } var preview = PrintDialog . createPrintPreview ( graph , scale , pf , border , x0 , y0 , autoOrigin ) ; preview . open ( ) ; if ( print ) { PrintDialog . printPreview ( preview ) ; } }
Overall scale for print-out to account for print borders in dialogs etc
Overall scale for print - out to account for print borders in dialogs etc