Ejemplo n.º 1
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            if(this.pdfDocumentViewer1.PageCount>0)
            {
                SaveFileDialog dialog=new SaveFileDialog ();
                dialog.Filter="JPG Format(*.jpg)|*.jpg|BMP Format(*.bmp)|*.bmp|PNG Format(*.png)|*.png|GIF Format(*.gif)|*.gif";
                DialogResult result=dialog.ShowDialog();
                string fileName=dialog.FileName;
                if (result==DialogResult.OK)
                {
              
                    int currentPage=this.pdfDocumentViewer1.CurrentPageNumber;
                    Bitmap image=this.pdfDocumentViewer1.SaveAsImage(currentPage-1);
                    image.Save(fileName);
                    MessageBox.Show("You have exported current page to an image:\n"+fileName,"Spire.PdfViewer Demo",MessageBoxButtons.OK,MessageBoxIcon.Information);

           
                    Dictionary<string, Image> dictionaryImages = new Dictionary<string, Image>();
                    dictionaryImages.Add(fileName, image);
              
                    this._formImages = new FormImages();
                    this._formImages.DictionaryImages = dictionaryImages;
                    this._formImages.Show();



             


                }
            }

        }
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (this.pdfDocumentViewer1.PageCount > 0)
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter = "JPG Format(*.jpg)|*.jpg|BMP Format(*.bmp)|*.bmp|PNG Format(*.png)|*.png|GIF Format(*.gif)|*.gif";
                DialogResult result   = dialog.ShowDialog();
                string       fileName = dialog.FileName;
                if (result == DialogResult.OK)
                {
                    int    currentPage = this.pdfDocumentViewer1.CurrentPageNumber;
                    Bitmap image       = this.pdfDocumentViewer1.SaveAsImage(currentPage - 1);
                    image.Save(fileName);
                    MessageBox.Show("You have exported current page to an image:\n" + fileName, "Spire.PdfViewer Demo", MessageBoxButtons.OK, MessageBoxIcon.Information);


                    Dictionary <string, Image> dictionaryImages = new Dictionary <string, Image>();
                    dictionaryImages.Add(fileName, image);

                    this._formImages = new FormImages();
                    this._formImages.DictionaryImages = dictionaryImages;
                    this._formImages.Show();
                }
            }
        }
        private void btnMultiExport_Click(object sender, EventArgs e)
        {
            if (this.pdfDocumentViewer1.PageCount <= 0)
            {
                return;
            }

            int fromPage = this.comBoxFrom.SelectedIndex;
            int toPage   = this.comboxTo.SelectedIndex;

            if (fromPage > toPage)
            {
                MessageBox.Show("End page number must be not less than started page number!", "Spire.PdfViewer Demo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                FolderBrowserDialog dialog = new FolderBrowserDialog();


                DialogResult result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    string   path   = dialog.SelectedPath;
                    Bitmap[] images = this.pdfDocumentViewer1.SaveAsImage(fromPage, toPage);
                    Dictionary <String, Image> dictionaryImages = new Dictionary <string, Image>();
                    for (int i = 0; i < images.Length; i++)
                    {
                        string name     = "image" + (i + 1 + fromPage).ToString() + ".bmp";
                        string fileName = path + "\\" + name;
                        images[i].Save(fileName);
                        dictionaryImages.Add(fileName, images[i]);
                    }
                    string message = "You have exported " + (fromPage + 1).ToString() + "-" + (toPage + 1).ToString() + " pages as images to:\n"
                                     + path;
                    MessageBox.Show(message, "Spire.PdfViewer Demo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this._formImages = new FormImages();
                    this._formImages.DictionaryImages = dictionaryImages;
                    this._formImages.Show();
                }
            }
        }
Ejemplo n.º 4
0
        private void btnMultiExport_Click(object sender, EventArgs e)
        {


            if (this.pdfDocumentViewer1.PageCount <= 0)
            {
                return;
            }

            int fromPage = this.comBoxFrom.SelectedIndex;
            int toPage = this.comboxTo.SelectedIndex;
            if (fromPage > toPage)
            {
                MessageBox.Show("End page number must be not less than started page number!", "Spire.PdfViewer Demo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                FolderBrowserDialog dialog = new FolderBrowserDialog();
                
            
                DialogResult result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                
                    string path = dialog.SelectedPath;
                    Bitmap[] images = this.pdfDocumentViewer1.SaveAsImage(fromPage, toPage);
                    Dictionary<String, Image> dictionaryImages = new Dictionary<string, Image>();
                    for (int i = 0; i < images.Length; i++)
                    {
                        string name = "image" + (i + 1 + fromPage).ToString() + ".bmp";
                        string fileName = path + "\\" + name;
                        images[i].Save(fileName);
                        dictionaryImages.Add(fileName, images[i]);
                     
                    }
                    string message = "You have exported " + (fromPage+1).ToString() + "-" + (toPage+1).ToString() +" pages as images to:\n"
                       + path;
                    MessageBox.Show(message,"Spire.PdfViewer Demo",MessageBoxButtons.OK,MessageBoxIcon.Information);
                  
                    this._formImages = new FormImages();
                    this._formImages.DictionaryImages = dictionaryImages;
                    this._formImages.Show();



                   
                }
            }

        }