ResizePageByPercentage

jdubs edited this page Oct 21, 2016 · 1 revision

Table of Contents

Overview

Performs a page width resize on all pages in a template.

Parameters

Percentage (multiple) The numeric percentage value for the page resize.

ErrorMessage (multiple | optional) The error message to return when any error occurs.

Synopsis

This method physically changes the template page size for all pages in the rendered output. The supplied value must be a valid number. Regardless of the Measurement Unit defined for the template page size the percentage is calculated horizontally and vertically. Objects on the page do not resize.

Source Code

public static void ResizePageByPercentage(object Percentage, object ErrorMessage)
{
	Break();
	try
	{
		Document doc = Application.CurrentDocument;
		string percent = Percentage.ToString().Replace("%", "").Replace(" ", "");

		object h = doc.PageHeight.GetType().GetProperty("Pt").GetValue(doc.PageHeight, null);
		decimal height = Convert.ToDecimal(h) * (Convert.ToDecimal(percent) * Convert.ToDecimal(.01));
		doc.PageHeight = String.Format("{0}pt", height.ToString());

		object w = doc.PageWidth.GetType().GetProperty("Pt").GetValue(doc.PageWidth, null);
		decimal width = Convert.ToDecimal(w) * (Convert.ToDecimal(percent) * Convert.ToDecimal(.01));
		doc.PageWidth = String.Format("{0}pt", width.ToString());
	}
	catch (Exception ex)
	{
		throw new Four51ActionsException(ex.Message, (string)ErrorMessage);
	}
}

Referenced Methods

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.