/// <summary>
 /// Handles the ValueChanged event of PageSizeNumericUpDown object.
 /// </summary>
 private void pageSizeNumericUpDown_ValueChanged(object sender, EventArgs e)
 {
     if (pageSizeComboBox.SelectedItem.ToString() == "Custom")
     {
         // create custom page size
         PageLayoutSettings.PageSize = ImageSize.FromMillimeters(
             (int)pageWidthNumericUpDown.Value,
             (int)pageHeightNumericUpDown.Value,
             Resolution.ScreenResolution);
     }
 }
        /// <summary>
        /// Handles the LayoutSettingsRequest event of the ChartImages.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DocumentLayoutSettingsRequestEventArgs"/> instance containing the event data.</param>
        private static void ChartImages_LayoutSettingsRequest(object sender, DocumentLayoutSettingsRequestEventArgs e)
        {
            // specify that only first page must be layouted
            e.LayoutSettings.PageCount = 1;

            // specify that relative size of graphics object must be used
            e.LayoutSettings.UseGraphicObjectReleativeSize = true;

            // set the page size to 70x70mm
            e.LayoutSettings.PageLayoutSettings = new PageLayoutSettings(ImageSize.FromMillimeters(70, 70, new Resolution(96)));
        }
        /// <summary>
        /// Handles the SelectedIndexChanged event of PageSizeComboBox object.
        /// </summary>
        private void pageSizeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (PageLayoutSettings == null)
            {
                return;
            }

            if (pageSizeComboBox.SelectedItem.ToString() != "Undefined")
            {
                ImageSize size;

                // if custom page size selected
                if (pageSizeComboBox.SelectedItem.ToString() == "Custom")
                {
                    pageWidthNumericUpDown.Enabled  = true;
                    pageHeightNumericUpDown.Enabled = true;

                    // if page size already set
                    if (PageLayoutSettings.PageSize != null)
                    {
                        // create custom page size with current values
                        size = ImageSize.FromInches(
                            PageLayoutSettings.PageSize.WidthInInch,
                            PageLayoutSettings.PageSize.HeightInInch,
                            PageLayoutSettings.PageSize.Resolution);
                    }
                    else
                    {
                        // create custom page size with default values
                        size = ImageSize.FromMillimeters(100, 100, Resolution.ScreenResolution);
                    }
                }
                else
                {
                    // get page size from paper kind
                    size = ImageSize.FromPaperKind((PaperSizeKind)pageSizeComboBox.SelectedItem);
                    pageWidthNumericUpDown.Enabled  = false;
                    pageHeightNumericUpDown.Enabled = false;
                }

                PageLayoutSettings.PageSize = size;

                // update page width and height containers
                pageWidthNumericUpDown.Value  = (int)Math.Round(UnitOfMeasureConverter.ConvertToMillimeters(size.WidthInInch, UnitOfMeasure.Inches));
                pageHeightNumericUpDown.Value = (int)Math.Round(UnitOfMeasureConverter.ConvertToMillimeters(size.HeightInInch, UnitOfMeasure.Inches));
            }
            else
            {
                PageLayoutSettings.PageSize     = null;
                pageWidthNumericUpDown.Enabled  = false;
                pageHeightNumericUpDown.Enabled = false;
            }
        }