コード例 #1
0
ファイル: frmPDFViewer.cs プロジェクト: w1146869587/XPdfNet
 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());
     }
 }
コード例 #2
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());
            }
        }
コード例 #3
0
ファイル: frmPDFViewer.cs プロジェクト: pvginkel/XPdfNet
        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());
            }
        }