exportToPdf style

3 posts, 0 answers
  1. Patrick
    Patrick avatar
    14 posts
    Member since:
    Feb 2011

    Posted 16 Mar 2011 Link to this post

    Hello,

    i have an issue with exporttopdf.
    even when i set the scale, fittopagewidth properties the result (pdf) looks everytime the same.
    my code:

    ExportToPDF pdf = new ExportToPDF(this._rg);
              pdf.ExportVisualSettings = true;
     
              pdf.Scale = 0.4f;
              pdf.FitToPageWidth = true;
     
              //pdf.TableBorderThickness = 0;
              pdf.RunExport(path);


    thx for help
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 17 Mar 2011 Link to this post

    Hello Patrick,

    Indeed, the scale will scale the content accordingly of the content. I have tried this in a new project and using your code, the output scales according to the scale property. The FitToPageWidth will determine of the content will spill over if required.

    I have prepared a small example for you to try. Please can you let me know how this looks to you

    Designer File
    namespace RadControlsWinFormsApp1
    {
        partial class Form1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components;
      
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
      
            #region Windows Form Designer generated code
      
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.radButton1 = new Telerik.WinControls.UI.RadButton();
                this.radGridView1 = new Telerik.WinControls.UI.RadGridView();
                ((System.ComponentModel.ISupportInitialize)(this.radButton1)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit();
                this.SuspendLayout();
                // 
                // radButton1
                // 
                this.radButton1.Location = new System.Drawing.Point(239, 347);
                this.radButton1.Name = "radButton1";
                this.radButton1.Size = new System.Drawing.Size(130, 24);
                this.radButton1.TabIndex = 0;
                this.radButton1.Text = "radButton1";
                this.radButton1.Click += new System.EventHandler(this.radButton1_Click);
                // 
                // radGridView1
                // 
                this.radGridView1.Location = new System.Drawing.Point(13, 13);
                this.radGridView1.Name = "radGridView1";
                this.radGridView1.Size = new System.Drawing.Size(356, 316);
                this.radGridView1.TabIndex = 1;
                this.radGridView1.Text = "radGridView1";
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(382, 391);
                this.Controls.Add(this.radGridView1);
                this.Controls.Add(this.radButton1);
                this.Name = "Form1";
                this.Text = "Form1";
                this.Load += new System.EventHandler(this.Form1_Load);
                ((System.ComponentModel.ISupportInitialize)(this.radButton1)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit();
                this.ResumeLayout(false);
      
            }
      
            #endregion
      
            private Telerik.WinControls.UI.RadButton radButton1;
            private Telerik.WinControls.UI.RadGridView radGridView1;
        }
    }

    Form1.cs
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
      
    using Telerik.WinControls.UI.Export;
      
    namespace RadControlsWinFormsApp1
    {
        public partial class Form1 : Form
        {
            private List<Person> people = new List<Person>();
      
            public Form1()
            {
                InitializeComponent();
            }
      
            private void Form1_Load(object sender, EventArgs e)
            {
                for (int i = 1; i <= 20; i++)
                {
                    people.Add(new Person("Name " + i.ToString(), i, "Description For Person " + i.ToString(), i.ToString() + " Telerik Road"));
                }
                this.radGridView1.DataSource = people;
            }
      
            private void radButton1_Click(object sender, EventArgs e)
            {
                ExportToPDF pdf = new ExportToPDF(this.radGridView1);
                pdf.ExportVisualSettings = true;
      
                pdf.Scale = 0.4f;
                // then try and change to 2.4
      
                pdf.FitToPageWidth = true;
                // replace with your own path
                pdf.RunExport(@"C:\Users\Richard\Documents\MyExport.pdf");
      
      
            }
        }
      
        public class Person
        {
            public Person(string name, int id, string desc, string address)
            {
                this.Name = name;
                this.Id = id;
                this.Desc = desc;
                this.Address = address;
            }
      
            public string Name
            { get; set; }
      
            public int Id
            { get; set; }
      
            public string Desc
            { get; set; }
      
            public string Address
            { get; set; }
        }
    }

    Hope that helps but let me know if you have any questions
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 21 Mar 2011 Link to this post

    Hello,

    Did this help? If so then please remember to mark as answer. If you need further help, please let me know
    Thanks
    Richard
Back to Top