using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.UI;
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf;
using Telerik.Windows.Documents.Fixed.Model;
using Telerik.Windows.Documents.Fixed.Model.Editing;
using Telerik.Windows.Documents.Fixed.Model.Fonts;

namespace _1472769
{
    public partial class RadForm1 : Telerik.WinControls.UI.RadForm
    {
        public RadForm1()
        {
            InitializeComponent();
            radPdfViewer.DocumentLoaded += radPdfViewer_DocumentLoaded;
            this.SizeChanged += RadForm1_SizeChanged;
        }

        private void RadForm1_SizeChanged(object sender, EventArgs e)
        {
            this.radLabel1.Text = "Zoom: " + radPdfViewer.PdfViewerElement.ScaleFactor;
        }

        private void radButton1_Click(object sender, EventArgs e)
        {

            OpenFileDialog dlg = new OpenFileDialog();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                radPdfViewer.LoadDocument(dlg.FileName);
            }
        }
 

        private void radPdfViewer_DocumentLoaded(object sender, EventArgs e)
        {
            Application.DoEvents();
            radPdfViewer.FitToWidth = true;
            radPdfViewer.PrintScalePageToPaperSize = true;
            this.radLabel1.Text = "Zoom: " + radPdfViewer.PdfViewerElement.ScaleFactor;

        }

        private void radButton2_Click(object sender, EventArgs e)
        {
            RadPrintDocument document = new RadPrintDocument();
            document.Landscape = false;

            document.PrinterSettings.PrinterName = "ZebraPAX";

            document.DefaultPageSettings.PrinterSettings.Copies = 1;
            document.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);

            //set paper
            IEnumerable<PaperSize> paperSizes = document.PrinterSettings.PaperSizes.Cast<PaperSize>();
            PaperSize paper = paperSizes.First((size) => size.Kind == PaperKind.C6Envelope);
            document.PaperSize = paper;


            document.HeaderHeight = 0;
            document.FooterHeight = 0;
             
            radPdfViewer.Print(true, document);

        }
    }
}
