This is a migrated thread and some comments may be shown as answers.

exportToPdf style

2 Answers 43 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 16 Mar 2011, 01:10 PM
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 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 17 Mar 2011, 11:18 AM
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
0
Richard Slade
Top achievements
Rank 2
answered on 21 Mar 2011, 10:11 AM
Hello,

Did this help? If so then please remember to mark as answer. If you need further help, please let me know
Thanks
Richard
Tags
GridView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Share this question
or