Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / C#

Show thumbnails of XPS documents

Rate me:
Please Sign up or sign in to vote.
5.00/5 (8 votes)
26 Jan 2010CPOL1 min read 42.8K   1.9K   40  
How to show thumbnails of XPS documents.
namespace XPS2Image
{
    partial class XPSThumbnail
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <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.components = new System.ComponentModel.Container();
            this.panel1 = new System.Windows.Forms.Panel();
            this.label3 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.groupBoxForm = new System.Windows.Forms.GroupBox();
            this.groupBoxImageQuality = new System.Windows.Forms.GroupBox();
            this.radioButtonQualitySuper = new System.Windows.Forms.RadioButton();
            this.radioButtonQualityGood = new System.Windows.Forms.RadioButton();
            this.radioButtonQualityNormal = new System.Windows.Forms.RadioButton();
            this.radioButtonQualityLow = new System.Windows.Forms.RadioButton();
            this.groupBoxImageFormat = new System.Windows.Forms.GroupBox();
            this.radioButtonJpeg = new System.Windows.Forms.RadioButton();
            this.radioButtonGif = new System.Windows.Forms.RadioButton();
            this.radioButtonPng = new System.Windows.Forms.RadioButton();
            this.label4 = new System.Windows.Forms.Label();
            this.buttonShowThumbnail = new System.Windows.Forms.Button();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.pictureboxContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.label2 = new System.Windows.Forms.Label();
            this.buttonBrowse = new System.Windows.Forms.Button();
            this.textBoxSelectedFile = new System.Windows.Forms.TextBox();
            this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
            this.saveThumbnail = new System.Windows.Forms.SaveFileDialog();
            this.panel1.SuspendLayout();
            this.groupBoxForm.SuspendLayout();
            this.groupBoxImageQuality.SuspendLayout();
            this.groupBoxImageFormat.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.pictureboxContextMenu.SuspendLayout();
            this.SuspendLayout();
            // 
            // panel1
            // 
            this.panel1.BackColor = System.Drawing.SystemColors.ControlLightLight;
            this.panel1.Controls.Add(this.label3);
            this.panel1.Controls.Add(this.label1);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(411, 67);
            this.panel1.TabIndex = 2;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(14, 39);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(292, 13);
            this.label3.TabIndex = 1;
            this.label3.Text = "Proof of concept for displaying thumbnails of XPS document.";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.Location = new System.Drawing.Point(12, 14);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(160, 25);
            this.label1.TabIndex = 0;
            this.label1.Text = "XPS Thumbnail";
            // 
            // groupBoxForm
            // 
            this.groupBoxForm.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.groupBoxForm.Controls.Add(this.groupBoxImageQuality);
            this.groupBoxForm.Controls.Add(this.groupBoxImageFormat);
            this.groupBoxForm.Controls.Add(this.label4);
            this.groupBoxForm.Controls.Add(this.buttonShowThumbnail);
            this.groupBoxForm.Controls.Add(this.pictureBox1);
            this.groupBoxForm.Controls.Add(this.label2);
            this.groupBoxForm.Controls.Add(this.buttonBrowse);
            this.groupBoxForm.Controls.Add(this.textBoxSelectedFile);
            this.groupBoxForm.Location = new System.Drawing.Point(13, 86);
            this.groupBoxForm.Name = "groupBoxForm";
            this.groupBoxForm.Size = new System.Drawing.Size(386, 610);
            this.groupBoxForm.TabIndex = 3;
            this.groupBoxForm.TabStop = false;
            this.groupBoxForm.Text = "Convert XPS to Image";
            // 
            // groupBoxImageQuality
            // 
            this.groupBoxImageQuality.Controls.Add(this.radioButtonQualitySuper);
            this.groupBoxImageQuality.Controls.Add(this.radioButtonQualityGood);
            this.groupBoxImageQuality.Controls.Add(this.radioButtonQualityNormal);
            this.groupBoxImageQuality.Controls.Add(this.radioButtonQualityLow);
            this.groupBoxImageQuality.Location = new System.Drawing.Point(10, 113);
            this.groupBoxImageQuality.Name = "groupBoxImageQuality";
            this.groupBoxImageQuality.Size = new System.Drawing.Size(368, 51);
            this.groupBoxImageQuality.TabIndex = 15;
            this.groupBoxImageQuality.TabStop = false;
            this.groupBoxImageQuality.Text = "Image Quality";
            // 
            // radioButtonQualitySuper
            // 
            this.radioButtonQualitySuper.AutoSize = true;
            this.radioButtonQualitySuper.Location = new System.Drawing.Point(191, 20);
            this.radioButtonQualitySuper.Name = "radioButtonQualitySuper";
            this.radioButtonQualitySuper.Size = new System.Drawing.Size(70, 17);
            this.radioButtonQualitySuper.TabIndex = 3;
            this.radioButtonQualitySuper.Text = "Superfine";
            this.radioButtonQualitySuper.UseVisualStyleBackColor = true;
            // 
            // radioButtonQualityGood
            // 
            this.radioButtonQualityGood.AutoSize = true;
            this.radioButtonQualityGood.Location = new System.Drawing.Point(134, 20);
            this.radioButtonQualityGood.Name = "radioButtonQualityGood";
            this.radioButtonQualityGood.Size = new System.Drawing.Size(51, 17);
            this.radioButtonQualityGood.TabIndex = 2;
            this.radioButtonQualityGood.Text = "Good";
            this.radioButtonQualityGood.UseVisualStyleBackColor = true;
            // 
            // radioButtonQualityNormal
            // 
            this.radioButtonQualityNormal.AutoSize = true;
            this.radioButtonQualityNormal.Location = new System.Drawing.Point(70, 20);
            this.radioButtonQualityNormal.Name = "radioButtonQualityNormal";
            this.radioButtonQualityNormal.Size = new System.Drawing.Size(58, 17);
            this.radioButtonQualityNormal.TabIndex = 1;
            this.radioButtonQualityNormal.Text = "Normal";
            this.radioButtonQualityNormal.UseVisualStyleBackColor = true;
            // 
            // radioButtonQualityLow
            // 
            this.radioButtonQualityLow.AutoSize = true;
            this.radioButtonQualityLow.Checked = true;
            this.radioButtonQualityLow.Location = new System.Drawing.Point(19, 20);
            this.radioButtonQualityLow.Name = "radioButtonQualityLow";
            this.radioButtonQualityLow.Size = new System.Drawing.Size(45, 17);
            this.radioButtonQualityLow.TabIndex = 0;
            this.radioButtonQualityLow.TabStop = true;
            this.radioButtonQualityLow.Text = "Low";
            this.radioButtonQualityLow.UseVisualStyleBackColor = true;
            // 
            // groupBoxImageFormat
            // 
            this.groupBoxImageFormat.Controls.Add(this.radioButtonJpeg);
            this.groupBoxImageFormat.Controls.Add(this.radioButtonGif);
            this.groupBoxImageFormat.Controls.Add(this.radioButtonPng);
            this.groupBoxImageFormat.Location = new System.Drawing.Point(10, 57);
            this.groupBoxImageFormat.Name = "groupBoxImageFormat";
            this.groupBoxImageFormat.Size = new System.Drawing.Size(368, 50);
            this.groupBoxImageFormat.TabIndex = 14;
            this.groupBoxImageFormat.TabStop = false;
            this.groupBoxImageFormat.Text = "Image Format";
            // 
            // radioButtonJpeg
            // 
            this.radioButtonJpeg.AutoSize = true;
            this.radioButtonJpeg.Checked = true;
            this.radioButtonJpeg.Location = new System.Drawing.Point(19, 19);
            this.radioButtonJpeg.Name = "radioButtonJpeg";
            this.radioButtonJpeg.Size = new System.Drawing.Size(52, 17);
            this.radioButtonJpeg.TabIndex = 10;
            this.radioButtonJpeg.TabStop = true;
            this.radioButtonJpeg.Text = "JPEG";
            this.radioButtonJpeg.UseVisualStyleBackColor = true;
            // 
            // radioButtonGif
            // 
            this.radioButtonGif.AutoSize = true;
            this.radioButtonGif.Location = new System.Drawing.Point(131, 19);
            this.radioButtonGif.Name = "radioButtonGif";
            this.radioButtonGif.Size = new System.Drawing.Size(42, 17);
            this.radioButtonGif.TabIndex = 12;
            this.radioButtonGif.Text = "GIF";
            this.radioButtonGif.UseVisualStyleBackColor = true;
            // 
            // radioButtonPng
            // 
            this.radioButtonPng.AutoSize = true;
            this.radioButtonPng.Location = new System.Drawing.Point(77, 19);
            this.radioButtonPng.Name = "radioButtonPng";
            this.radioButtonPng.Size = new System.Drawing.Size(48, 17);
            this.radioButtonPng.TabIndex = 11;
            this.radioButtonPng.Text = "PNG";
            this.radioButtonPng.UseVisualStyleBackColor = true;
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(7, 207);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(109, 13);
            this.label4.TabIndex = 9;
            this.label4.Text = "Generated Thumbnail";
            // 
            // buttonShowThumbnail
            // 
            this.buttonShowThumbnail.Location = new System.Drawing.Point(253, 170);
            this.buttonShowThumbnail.Name = "buttonShowThumbnail";
            this.buttonShowThumbnail.Size = new System.Drawing.Size(125, 23);
            this.buttonShowThumbnail.TabIndex = 8;
            this.buttonShowThumbnail.Text = "Show Thumbnail";
            this.buttonShowThumbnail.UseVisualStyleBackColor = true;
            this.buttonShowThumbnail.Click += new System.EventHandler(this.buttonShowThumbnail_Click);
            // 
            // pictureBox1
            // 
            this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.pictureBox1.ContextMenuStrip = this.pictureboxContextMenu;
            this.pictureBox1.Location = new System.Drawing.Point(7, 226);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(371, 378);
            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
            this.pictureBox1.TabIndex = 7;
            this.pictureBox1.TabStop = false;
            // 
            // pictureboxContextMenu
            // 
            this.pictureboxContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.saveImageToolStripMenuItem});
            this.pictureboxContextMenu.Name = "contextMenuStrip1";
            this.pictureboxContextMenu.Size = new System.Drawing.Size(135, 26);
            // 
            // saveImageToolStripMenuItem
            // 
            this.saveImageToolStripMenuItem.Name = "saveImageToolStripMenuItem";
            this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
            this.saveImageToolStripMenuItem.Text = "Save Image";
            this.saveImageToolStripMenuItem.Click += new System.EventHandler(this.saveImageToolStripMenuItem_Click);
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(7, 31);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(77, 13);
            this.label2.TabIndex = 6;
            this.label2.Text = "Select XPS file";
            // 
            // buttonBrowse
            // 
            this.buttonBrowse.Location = new System.Drawing.Point(346, 26);
            this.buttonBrowse.Name = "buttonBrowse";
            this.buttonBrowse.Size = new System.Drawing.Size(32, 23);
            this.buttonBrowse.TabIndex = 1;
            this.buttonBrowse.Text = "...";
            this.buttonBrowse.UseVisualStyleBackColor = true;
            this.buttonBrowse.Click += new System.EventHandler(this.buttonBrowse_Click);
            // 
            // textBoxSelectedFile
            // 
            this.textBoxSelectedFile.Location = new System.Drawing.Point(90, 28);
            this.textBoxSelectedFile.Name = "textBoxSelectedFile";
            this.textBoxSelectedFile.ReadOnly = true;
            this.textBoxSelectedFile.Size = new System.Drawing.Size(248, 20);
            this.textBoxSelectedFile.TabIndex = 0;
            // 
            // openFileDialog
            // 
            this.openFileDialog.Filter = "XPS Document (*.xps)|*.xps";
            this.openFileDialog.Title = "Select XPS Document";
            // 
            // saveThumbnail
            // 
            this.saveThumbnail.Title = "Save Thumbnail As";
            this.saveThumbnail.FileOk += new System.ComponentModel.CancelEventHandler(this.saveThumbnail_FileOk);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(411, 708);
            this.Controls.Add(this.groupBoxForm);
            this.Controls.Add(this.panel1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "Form1";
            this.Text = "XPS Thumbnail";
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.groupBoxForm.ResumeLayout(false);
            this.groupBoxForm.PerformLayout();
            this.groupBoxImageQuality.ResumeLayout(false);
            this.groupBoxImageQuality.PerformLayout();
            this.groupBoxImageFormat.ResumeLayout(false);
            this.groupBoxImageFormat.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.pictureboxContextMenu.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.GroupBox groupBoxForm;
        private System.Windows.Forms.Button buttonBrowse;
        private System.Windows.Forms.TextBox textBoxSelectedFile;
        private System.Windows.Forms.OpenFileDialog openFileDialog;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Button buttonShowThumbnail;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.ContextMenuStrip pictureboxContextMenu;
        private System.Windows.Forms.ToolStripMenuItem saveImageToolStripMenuItem;
        private System.Windows.Forms.GroupBox groupBoxImageFormat;
        private System.Windows.Forms.RadioButton radioButtonJpeg;
        private System.Windows.Forms.RadioButton radioButtonGif;
        private System.Windows.Forms.RadioButton radioButtonPng;
        private System.Windows.Forms.GroupBox groupBoxImageQuality;
        private System.Windows.Forms.RadioButton radioButtonQualityGood;
        private System.Windows.Forms.RadioButton radioButtonQualityNormal;
        private System.Windows.Forms.RadioButton radioButtonQualityLow;
        private System.Windows.Forms.RadioButton radioButtonQualitySuper;
        private System.Windows.Forms.SaveFileDialog saveThumbnail;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
My name is Pravesh Soni and I’m software professional. I got involved with computers since last two decades starting with playing games developed in BASIC. I am a tech enthusiast and I love writing code, blogging, science fiction, cartoons, music, robotics and I am a big Microsoft fan too.

I started programming in classic asp but later switch to .net and now at present I have almost 15 years of development experience in Microsoft technologies. I got involved in customized software development in my career of programming, now contributing to some open source community development.

Comments and Discussions