Ejemplo n.º 1
0
 private void txtPage_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
         {
             if (_pdfDoc != null && e.KeyCode == Keys.Return)
             {
                 int page = -1;
                 if (int.TryParse(txtPage.Text, out page))
                 {
                     if (page > 0 && page <= _pdfDoc.PageCount)
                     {
                         _pdfDoc.CurrentPage = page;
                         UpdateText();
                         _pdfDoc.RenderPage(pageViewControl1.Handle);
                         Render();
                     }
                     else
                     {
                         page = -1;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error");
     }
 }
Ejemplo n.º 2
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (!PdfOK())
            {
                return;
            }
            try
            {
                string fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".ps";

                if (printDialog1.ShowDialog() == DialogResult.OK)
                {
                    using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusPrinting))
                    {
                        if (printDialog1.PrinterSettings.PrintToFile)
                        {
                            saveFileDialog1.Filter = "PostScript File (*.ps)|*.ps";
                            if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
                            {
                                _pdfDoc.PrintToFile(saveFileDialog1.FileName, 1, _pdfDoc.PageCount);
                            }
                        }
                        else
                        {
                            _pdfDoc.PrintToFile(fileName, 1, _pdfDoc.PageCount);
                            RawPrinterHelper.SendFileToPrinter(printDialog1.PrinterSettings.PrinterName, fileName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 3
0
 void frmPDFViewer_Resize(object sender, EventArgs e)
 {
     if (_pdfDoc != null)
     {
         using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusResizing))
         {
             FitWidth();
             Render();
         }
     }
 }
Ejemplo n.º 4
0
 private void tsbPrintAs_Click(object sender, EventArgs e)
 {
     if (!PdfOK())
     {
         return;
     }
     try
     {
         saveFileDialog1.Filter = "PostScript file (*.ps)|*.ps|Plain text (*.txt)|*.txt|HTML Markup(*.html)|*.html|Jpg Image (*.jpg)|*.jpg|SWF Movie Flash (*.swf)|*.swf";
         if (saveFileDialog1.ShowDialog() == DialogResult.OK)
         {
             using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusExporting))
             {
                 if (saveFileDialog1.FileName.EndsWith(".ps"))
                 {
                     _pdfDoc.PrintToFile(saveFileDialog1.FileName, 1, _pdfDoc.PageCount);
                 }
                 else if (saveFileDialog1.FileName.EndsWith(".jpg"))
                 {
                     _pdfDoc.ExportJpgProgress += new ExportJpgProgressHandler(_pdfDoc_ExportJpgProgress);
                     _pdfDoc.ExportJpgFinished += new ExportJpgFinishedHandler(_pdfDoc_ExportJpgFinished);
                     frmExportJpg frm = new frmExportJpg(_pdfDoc, saveFileDialog1.FileName);
                     frm.Show();
                 }
                 else if (saveFileDialog1.FileName.EndsWith(".txt"))
                 {
                     _pdfDoc.ExportText(saveFileDialog1.FileName, 1, _pdfDoc.PageCount, true, true);
                 }
                 else if (saveFileDialog1.FileName.EndsWith(".html"))
                 {
                     _pdfDoc.ExportHtml(saveFileDialog1.FileName, 1, _pdfDoc.PageCount, new ExportHtmlParams()
                     {
                         ImageExtension = "png", JpegQuality = 60
                     });
                 }
                 else if (saveFileDialog1.FileName.EndsWith(".eps"))
                 {
                     //_pdfDoc.ExportEPS(saveFileDialog1.FileName, 1, _pdfDoc.PageCount);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _pdfDoc.ExportJpgProgress -= new ExportJpgProgressHandler(_pdfDoc_ExportJpgProgress);
         _pdfDoc.ExportJpgFinished -= new ExportJpgFinishedHandler(_pdfDoc_ExportJpgFinished);
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 5
0
 private void tsbPrev_Click(object sender, EventArgs e)
 {
     if (!PdfOK())
     {
         return;
     }
     using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
     {
         if (_pdfDoc != null && !IsDisposed)
         {
             _pdfDoc.PreviousPage();
             UpdateText();
             _pdfDoc.RenderPage(pageViewControl1.Handle);
             Render();
         }
     }
 }
Ejemplo n.º 6
0
 private void tsbZoomOut_Click(object sender, EventArgs e)
 {
     try
     {
         using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
         {
             if (_pdfDoc != null)
             {
                 _pdfDoc.ZoomOut();
                 _pdfDoc.RenderFinished -= new RenderFinishedHandler(_pdfDoc_RenderFinished);
                 _pdfDoc.RenderFinished += new RenderFinishedHandler(_pdfDoc_RenderFinished);
                 _pdfDoc.RenderPageThread(pageViewControl1.Handle, false);
                 Render();
             }
         }
     }
     catch (Exception) { }
 }
Ejemplo n.º 7
0
 private void tsbVectorAntialias_Click(object sender, EventArgs e)
 {
     PDFLibNet.xPDFParams.VectorAntialias = !PDFLibNet.xPDFParams.VectorAntialias;
     tsbVectorAntialias.Checked           = PDFLibNet.xPDFParams.VectorAntialias;
     if (!PdfOK())
     {
         return;
     }
     using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
     {
         if (_pdfDoc != null)
         {
             _pdfDoc.RenderPage(pageViewControl1.Handle, true);
             Render();
             pageViewControl1.Invalidate();
         }
     }
 }
Ejemplo n.º 8
0
        void tvwOutline_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusSearchingBookmark))
            {
                OutlineItem ol = (OutlineItem)e.Node.Tag;
                if (ol != null)
                {
                    ol.DoAction();
                    Console.WriteLine(ol.Destination.Page);
                    switch (ol.GetKind())
                    {
                    case LinkActionKind.actionGoTo:
                    case LinkActionKind.actionGoToR:
                        //Transform the coordinates
                        PointF loc = _pdfDoc.PointUserToDev(new PointF((float)ol.Destination.Left, (float)ol.Destination.Top));
                        if (ol.Destination.ChangeTop)
                        {
                            ScrolltoTop((int)loc.Y);
                        }
                        else
                        {
                            ScrolltoTop(0);
                        }
                        break;

                    case LinkActionKind.actionLaunch:
                        break;

                    case LinkActionKind.actionMovie:
                        break;

                    case LinkActionKind.actionURI:
                        break;
                    }
                    _pdfDoc.RenderPage(pageViewControl1.Handle);
                    Render();
                }
            }
        }
Ejemplo n.º 9
0
        private bool doubleBufferControl1_PreviousPage(object sender)
        {
            // try
            {
                using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
                {
                    if (_pdfDoc.CurrentPage > 1)
                    {
                        _pdfDoc.PreviousPage();
                        UpdateText();
                        _pdfDoc.RenderPage(pageViewControl1.Handle);
                        Render();
                        return(true);
                    }
                }
            }

            /* catch (Exception ex)
             * {
             *   MessageBox.Show(ex.ToString());
             * }*/
            return(false);
        }
Ejemplo n.º 10
0
 void tvwOutline_BeforeExpand(object sender, TreeViewCancelEventArgs e)
 {
     using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusSearchingBookmark))
     {
         OutlineItem ol = (OutlineItem)e.Node.Tag;
         if (ol != null)
         {
             if (e.Node.Nodes.Count > 0 && e.Node.Nodes[0].Text == "dummy")
             {
                 e.Node.Nodes.Clear();
                 foreach (OutlineItem col in ol.Childrens)
                 {
                     TreeNode tn = new TreeNode(col.Title);
                     tn.Tag = col;
                     if (col.KidsCount > 0)
                     {
                         tn.Nodes.Add(new TreeNode("dummy"));
                     }
                     e.Node.Nodes.Add(tn);
                 }
             }
         }
     }
 }
Ejemplo n.º 11
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (!PdfOK())
                return;
            try
            {
                string fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".ps";

                if (printDialog1.ShowDialog() == DialogResult.OK)
                {
                    using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusPrinting))
                    {
                        if (printDialog1.PrinterSettings.PrintToFile)
                        {
                            saveFileDialog1.Filter = "PostScript File (*.ps)|*.ps";
                            if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
                                _pdfDoc.PrintToFile(saveFileDialog1.FileName, 1, _pdfDoc.PageCount);

                        }
                        else
                        {
                            _pdfDoc.PrintToFile(fileName, 1, _pdfDoc.PageCount);
                            RawPrinterHelper.SendFileToPrinter(printDialog1.PrinterSettings.PrinterName, fileName);
                        }
                    }
                }
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
        }
Ejemplo n.º 12
0
        private void tsbOpen_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "Portable Document Format (*.pdf)|*.pdf";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    if (_pdfDoc != null)
                    {
                        _pdfDoc.Dispose();
                        _pdfDoc = null;
                    }
                    //if (_pdfDoc == null)
                    //{
                    _pdfDoc = new PDFWrapper();
                    _pdfDoc.RenderNotifyFinished += new RenderNotifyFinishedHandler(_pdfDoc_RenderNotifyFinished);
                    _pdfDoc.PDFLoadCompeted += new PDFLoadCompletedHandler(_pdfDoc_PDFLoadCompeted);
                    _pdfDoc.PDFLoadBegin += new PDFLoadBeginHandler(_pdfDoc_PDFLoadBegin);
                    _pdfDoc.UseMuPDF = tsbUseMuPDF.Checked;
                    //}
                    //xPDFParams.ErrorQuiet =true;
                    //xPDFParams.ErrorFile = "C:\\stderr.log";
                    //}
                    int ts = Environment.TickCount;
                    using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingFile))
                    {
                        if (LoadFile(dlg.FileName, _pdfDoc))
                        {
                            Text = string.Format(Resources.UIStrings.StatusFormCaption, _pdfDoc.Author, _pdfDoc.Title);
                            FillTree();
                            _pdfDoc.CurrentPage = 1;
                            UpdateText();

                            _pdfDoc.FitToWidth(pageViewControl1.Handle);
                            _pdfDoc.RenderPage(pageViewControl1.Handle);

                            Render();

                            PDFPage pg = _pdfDoc.Pages[1];
                            listView2.TileSize = new Size(134, (int)(128 * pg.Height / pg.Width) + 10);
                            listView2.BeginUpdate();
                            listView2.Clear();
                            for (int i = 0; i < _pdfDoc.PageCount; ++i)
                                listView2.Items.Add((i + 1).ToString());
                            listView2.EndUpdate();

                            //pg.LoadThumbnail(128, (int)(128 * pg.Height / pg.Width));
                        }
                    }
                }
            }
            catch (System.IO.IOException ex)
            {
                MessageBox.Show(ex.Message, "IOException");
            }
            catch (System.Security.SecurityException ex)
            {
                MessageBox.Show(ex.Message, "SecurityException");
            }
            catch (System.IO.InvalidDataException ex)
            {
                MessageBox.Show(ex.Message, "InvalidDataException");
            }
        }
Ejemplo n.º 13
0
 private void tsbPrev_Click(object sender, EventArgs e)
 {
     if (!PdfOK())
         return;
     using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
     {
         if (_pdfDoc != null && !IsDisposed)
         {
             _pdfDoc.PreviousPage();
             UpdateText();
             _pdfDoc.RenderPage(pageViewControl1.Handle);
             Render();
         }
     }
 }
Ejemplo n.º 14
0
 private void txtPage_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
         {
             if (_pdfDoc != null && e.KeyCode == Keys.Return)
             {
                 int page = -1;
                 if (int.TryParse(txtPage.Text, out page))
                 {
                     if (page > 0 && page <= _pdfDoc.PageCount)
                     {
                         _pdfDoc.CurrentPage = page;
                         UpdateText();
                         _pdfDoc.RenderPage(pageViewControl1.Handle);
                         Render();
                     }
                     else
                         page = -1;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error");
     }
 }
Ejemplo n.º 15
0
        void tvwOutline_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusSearchingBookmark))
            {

                OutlineItem ol = (OutlineItem)e.Node.Tag;
                if (ol != null)
                {
                    if (e.Node.Nodes.Count > 0 && e.Node.Nodes[0].Text == "dummy")
                    {
                        e.Node.Nodes.Clear();
                        foreach (OutlineItem col in ol.Childrens)
                        {
                            TreeNode tn = new TreeNode(col.Title);
                            tn.Tag = col;
                            if (col.KidsCount > 0)
                                tn.Nodes.Add(new TreeNode("dummy"));
                            e.Node.Nodes.Add(tn);
                        }
                    }
                }
            }
         }
Ejemplo n.º 16
0
 void tvwOutline_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusSearchingBookmark))
     {
         OutlineItem ol = (OutlineItem)e.Node.Tag;
         if (ol != null)
         {
             ol.DoAction();
             Console.WriteLine(ol.Destination.Page);
             switch (ol.GetKind())
             {
                 case LinkActionKind.actionGoTo:
                 case LinkActionKind.actionGoToR:
                     //Transform the coordinates
                     PointF loc = _pdfDoc.PointUserToDev(new PointF((float)ol.Destination.Left, (float)ol.Destination.Top));
                     if (ol.Destination.ChangeTop)
                         ScrolltoTop((int)loc.Y);
                     else
                         ScrolltoTop(0);
                     break;
                 case LinkActionKind.actionLaunch:
                     break;
                 case LinkActionKind.actionMovie:
                     break;
                 case LinkActionKind.actionURI:
                     break;
             }
             _pdfDoc.RenderPage(pageViewControl1.Handle);
             Render();
         }
     }
 }
Ejemplo n.º 17
0
 void frmPDFViewer_Resize(object sender, EventArgs e)
 {
     if (_pdfDoc != null)
     {
         using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusResizing))
         {
             FitWidth();
             Render();
         }
     }
 }
Ejemplo n.º 18
0
        private void tsbVectorAntialias_Click(object sender, EventArgs e)
        {
            PDFLibNet.xPDFParams.VectorAntialias = !PDFLibNet.xPDFParams.VectorAntialias;
            tsbVectorAntialias.Checked = PDFLibNet.xPDFParams.VectorAntialias;
            if (!PdfOK())
                return;
            using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
            {
                if (_pdfDoc != null)
                {

                    _pdfDoc.RenderPage(pageViewControl1.Handle, true);
                    Render();
                    pageViewControl1.Invalidate();
                }
            }
        }
Ejemplo n.º 19
0
 private bool doubleBufferControl1_PreviousPage(object sender)
 {
    // try
     {
         using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
         {
             if (_pdfDoc.CurrentPage > 1)
             {
                 _pdfDoc.PreviousPage();
                 UpdateText();
                 _pdfDoc.RenderPage(pageViewControl1.Handle);
                 Render();
                 return true;
             }
         }
     }
    /* catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }*/
     return false;
 }
Ejemplo n.º 20
0
 private void tsbZoomOut_Click(object sender, EventArgs e)
 {
     try
     {
         using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingPage))
         {
             if (_pdfDoc != null)
             {
                 _pdfDoc.ZoomOut();
                 _pdfDoc.RenderFinished -= new RenderFinishedHandler(_pdfDoc_RenderFinished);
                 _pdfDoc.RenderFinished += new RenderFinishedHandler(_pdfDoc_RenderFinished);
                 _pdfDoc.RenderPageThread(pageViewControl1.Handle, false);
                 Render();
             }
         }
     }
     catch (Exception) { }
 }
Ejemplo n.º 21
0
        private void tsbOpen_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "Portable Document Format (*.pdf)|*.pdf";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    if (_pdfDoc != null)
                    {
                        _pdfDoc.Dispose();
                        _pdfDoc = null;
                    }
                    //if (_pdfDoc == null)
                    //{
                    _pdfDoc = new PDFWrapper();
                    _pdfDoc.RenderNotifyFinished += new RenderNotifyFinishedHandler(_pdfDoc_RenderNotifyFinished);
                    _pdfDoc.PDFLoadCompeted      += new PDFLoadCompletedHandler(_pdfDoc_PDFLoadCompeted);
                    _pdfDoc.PDFLoadBegin         += new PDFLoadBeginHandler(_pdfDoc_PDFLoadBegin);
                    //}
                    //xPDFParams.ErrorQuiet =true;
                    //xPDFParams.ErrorFile = "C:\\stderr.log";
                    //}
                    int ts = Environment.TickCount;
                    using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusLoadingFile))
                    {
                        if (LoadFile(dlg.FileName, _pdfDoc))
                        {
                            Text = string.Format(Resources.UIStrings.StatusFormCaption, _pdfDoc.Author, _pdfDoc.Title);
                            FillTree();
                            _pdfDoc.CurrentPage = 1;
                            UpdateText();

                            _pdfDoc.FitToWidth(pageViewControl1.Handle);
                            _pdfDoc.RenderPage(pageViewControl1.Handle);

                            Render();

                            PDFPage pg = _pdfDoc.Pages[1];
                            listView2.TileSize = new Size(134, (int)(128 * pg.Height / pg.Width) + 10);
                            listView2.BeginUpdate();
                            listView2.Clear();
                            for (int i = 0; i < _pdfDoc.PageCount; ++i)
                            {
                                listView2.Items.Add((i + 1).ToString());
                            }
                            listView2.EndUpdate();

                            //pg.LoadThumbnail(128, (int)(128 * pg.Height / pg.Width));
                        }
                    }
                }
            }
            catch (System.IO.IOException ex)
            {
                MessageBox.Show(ex.Message, "IOException");
            }
            catch (System.Security.SecurityException ex)
            {
                MessageBox.Show(ex.Message, "SecurityException");
            }
            catch (System.IO.InvalidDataException ex)
            {
                MessageBox.Show(ex.Message, "InvalidDataException");
            }
        }
Ejemplo n.º 22
0
        private void tsbPrintAs_Click(object sender, EventArgs e)
        {
            if (!PdfOK())
                return;
            try
            {

                saveFileDialog1.Filter = "PostScript file (*.ps)|*.ps|Plain text (*.txt)|*.txt|HTML Markup(*.html)|*.html|Jpg Image (*.jpg)|*.jpg|SWF Movie Flash (*.swf)|*.swf";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusExporting))
                    {
                        if (saveFileDialog1.FileName.EndsWith(".ps"))
                        {
                            _pdfDoc.PrintToFile(saveFileDialog1.FileName, 1, _pdfDoc.PageCount);
                        }
                        else if (saveFileDialog1.FileName.EndsWith(".jpg"))
                        {
                            _pdfDoc.ExportJpgProgress += new ExportJpgProgressHandler(_pdfDoc_ExportJpgProgress);
                            _pdfDoc.ExportJpgFinished += new ExportJpgFinishedHandler(_pdfDoc_ExportJpgFinished);
                            frmExportJpg frm = new frmExportJpg(_pdfDoc, saveFileDialog1.FileName);
                            frm.Show();
                        }
                        else if (saveFileDialog1.FileName.EndsWith(".txt"))
                        {
                            _pdfDoc.ExportText(saveFileDialog1.FileName, 1, _pdfDoc.PageCount, true, true);
                        }
                        else if (saveFileDialog1.FileName.EndsWith(".html"))
                        {
                            _pdfDoc.ExportHtml(saveFileDialog1.FileName, 1, _pdfDoc.PageCount, new ExportHtmlParams() { ImageExtension = "png", JpegQuality = 60 });
                        }
                        else if (saveFileDialog1.FileName.EndsWith(".eps"))
                        {
                            //_pdfDoc.ExportEPS(saveFileDialog1.FileName, 1, _pdfDoc.PageCount);
                        }
                        else if (saveFileDialog1.FileName.EndsWith(".swf"))
                        {

                            /*
                                settings.Loader = @"C:\Users\Antonio\Documents\Visual Studio 2008\Projects\xpdfWin\swftools-0.9.1\swfs\swft_loader.swf";
                                settings.Viewer = @"C:\Users\Antonio\Documents\Visual Studio 2008\Projects\xpdfWin\swftools-0.9.1\swfs\keyboard_viewer.swf";
                            
                                 * 2: Please use -o to specify an output file\n"
                                3: <error> only one %% allowed in filename
                                4: <error> -b/-l/-B/-L not supported together with %% in filename
                                5: "<error> Couldn't open %s", filename
                                6:  "No pages in range %s", pagerange
                                7: Error on save
                                101: <fatal> Can't combine --cat and --frame
                                102: <error> Can't combine --cat and --merge
                                103: <error> Can't combine --cat and --stack
                                104: <error> Can't combine -l and -t
                                105: <error> Can't combine -c and -t
                                106: <fatal> Failed to open MasterFile
                                107: <fatal> Failed to read MasterFile
                                108: <error> --dummy (-d) implies there are zero slave objects. You supplied num slaves
                                109: <fatal> Failed to open %s\n", slave_filename[t]
                                110: "<fatal> Failed to read from %s\n", slave_filename[t]
                                111: <fatal> Couldn't allocate %d bytes of memory", 65536

                                 */
                            frmExportSWF frm = new frmExportSWF(_pdfDoc, saveFileDialog1.FileName);
                            frm.ShowDialog();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _pdfDoc.ExportJpgProgress -= new ExportJpgProgressHandler(_pdfDoc_ExportJpgProgress);
                _pdfDoc.ExportJpgFinished -= new ExportJpgFinishedHandler(_pdfDoc_ExportJpgFinished);
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 23
0
        private void tsbPrintAs_Click(object sender, EventArgs e)
        {
            if (!PdfOK())
                return;
            try
            {

                saveFileDialog1.Filter = "PostScript file (*.ps)|*.ps|Plain text (*.txt)|*.txt|HTML Markup(*.html)|*.html|Jpg Image (*.jpg)|*.jpg|SWF Movie Flash (*.swf)|*.swf";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusExporting))
                    {
                        if (saveFileDialog1.FileName.EndsWith(".ps"))
                        {
                            _pdfDoc.PrintToFile(saveFileDialog1.FileName, 1, _pdfDoc.PageCount);
                        }
                        else if (saveFileDialog1.FileName.EndsWith(".jpg"))
                        {
                            _pdfDoc.ExportJpgProgress += new ExportJpgProgressHandler(_pdfDoc_ExportJpgProgress);
                            _pdfDoc.ExportJpgFinished += new ExportJpgFinishedHandler(_pdfDoc_ExportJpgFinished);
                            frmExportJpg frm = new frmExportJpg(_pdfDoc, saveFileDialog1.FileName);
                            frm.Show();
                        }
                        else if (saveFileDialog1.FileName.EndsWith(".txt"))
                        {
                            _pdfDoc.ExportText(saveFileDialog1.FileName, 1, _pdfDoc.PageCount, true, true);
                        }
                        else if (saveFileDialog1.FileName.EndsWith(".html"))
                        {
                            _pdfDoc.ExportHtml(saveFileDialog1.FileName, 1, _pdfDoc.PageCount, new ExportHtmlParams() { ImageExtension = "png", JpegQuality = 60 });
                        }
                        else if (saveFileDialog1.FileName.EndsWith(".eps"))
                        {
                            //_pdfDoc.ExportEPS(saveFileDialog1.FileName, 1, _pdfDoc.PageCount);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _pdfDoc.ExportJpgProgress -= new ExportJpgProgressHandler(_pdfDoc_ExportJpgProgress);
                _pdfDoc.ExportJpgFinished -= new ExportJpgFinishedHandler(_pdfDoc_ExportJpgFinished);
                MessageBox.Show(ex.ToString());
            }
        }