• 大小: 18.76MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-13
  • 语言: C#
  • 标签: c#  office  pdf  txt  Image  

资源简介

1.文件不需下载 2.在线打开预览 3.支持多种格式

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using org.pdfbox.pdmodel;
using org.pdfbox.util;

namespace FileConvert
{
    public partial class ConvertFile : Form
    {
        public ConvertFile()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {

        }

        /// 
        /// pdf转换txt
        /// 

        /// 
        /// 
        private void BtnPdfToTxt_Click(object sender EventArgs e)
        {
            try
            {
                OpenFileDialog openfile = new OpenFileDialog();
                openfile.Multiselect = true;
                openfile.title = “文件转换“;
                openfile.Filter = “PDF文档(*.pdf)| *.pdf“;

                openfile.RestoreDirectory = false;
                if (openfile.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
                string fName = openfile.FileName;
                FileInfo fi = new FileInfo(fName);
                this.Text = (fi.Length / 1024).ToString() + “kb“;
                if ((fi.Length / 1024) > 1024)
                {
                    MessageBox.Show(“文件大小超过可转换大小“);
                    return;
                }


                PDDocument doc = PDDocument.load(fName);
                PDFTextStripper pdfStripper = new PDFTextStripper();
                string text = pdfStripper.getText(doc);
                StreamWriter swPdfChange = new StreamWriter(System.IO.Path.GetFileNameWithoutExtension(fName) + “.txt“ false Encoding.GetEncoding(“gb2312“));
                swPdfChange.Write(text);
                swPdfChange.Close();

                MessageBox.Show(System.IO.Path.GetFileNameWithoutExtension(fName.ToString()) + “ 文件转换成功“);
            }
            catch (Exception ex)
            {
                MessageBox.Show(“转换异常:“ + ex.Message);
                return;
            }

        }

        /// 
        /// 切割pdf
        /// 

        /// 
        /// 
        private void BtnSplit_Click(object sender EventArgs e)
        {
            try
            {
                //OpenFileDialog openfile = new OpenFileDialog();
                //openfile.Multiselect = true;
                //openfile.title = “选择切割的pdf文件“;
                //openfile.Filter = “PDF文档(*.pdf)| *.pdf“;

                //openfile.RestoreDirectory = false;
                //if (openfile.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                //    return;
                //string fName = openfile.FileName;
                //Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
        

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       7680  2019-04-16 15:07  ScanningFile\bin\Debug\ScanningFile.exe

     文件      19968  2019-04-16 15:07  ScanningFile\bin\Debug\ScanningFile.pdb

     文件        437  2019-04-12 15:52  ScanningFile\FileScanning.cs

     文件       1596  2019-04-12 09:00  ScanningFile\FileScanning.Designer.cs

     文件       5817  2019-04-12 09:00  ScanningFile\FileScanning.resx

     文件       6296  2019-04-16 17:16  ScanningFile\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        641  2019-04-16 15:07  ScanningFile\obj\x86\Debug\ScanningFile.csproj.FileListAbsolute.txt

     文件        982  2019-04-16 15:07  ScanningFile\obj\x86\Debug\ScanningFile.csproj.GenerateResource.Cache

     文件       9174  2019-04-16 15:07  ScanningFile\obj\x86\Debug\ScanningFile.csprojResolveAssemblyReference.cache

     文件       7680  2019-04-16 15:07  ScanningFile\obj\x86\Debug\ScanningFile.exe

     文件        180  2019-04-16 15:07  ScanningFile\obj\x86\Debug\ScanningFile.FileScanning.resources

     文件      19968  2019-04-16 15:07  ScanningFile\obj\x86\Debug\ScanningFile.pdb

     文件        180  2019-04-16 15:07  ScanningFile\obj\x86\Debug\ScanningFile.Properties.Resources.resources

     文件        500  2019-04-12 09:00  ScanningFile\Program.cs

     文件       1356  2019-04-12 08:58  ScanningFile\Properties\AssemblyInfo.cs

     文件       2876  2019-04-12 08:58  ScanningFile\Properties\Resources.Designer.cs

     文件       5612  2019-04-12 08:58  ScanningFile\Properties\Resources.resx

     文件       1099  2019-04-12 08:58  ScanningFile\Properties\Settings.Designer.cs

     文件        249  2019-04-12 08:58  ScanningFile\Properties\Settings.settings

     文件       3718  2019-04-12 09:00  ScanningFile\ScanningFile.csproj

     文件       1779  2019-04-17 09:03  OpenFile.sln

     文件    8018944  2014-11-23 14:59  FileConvert\bin\Debug\Aspose.Cells.dll

     文件   11615232  2018-12-18 14:35  FileConvert\bin\Debug\Aspose.Words.dll

     文件     151552  2006-10-12 12:20  FileConvert\bin\Debug\bcmail-jdk14-132.dll

     文件    1187840  2006-10-12 12:20  FileConvert\bin\Debug\bcprov-jdk14-132.dll

     文件      11264  2019-04-16 15:07  FileConvert\bin\Debug\FileConvert.exe

     文件      24064  2019-04-16 15:07  FileConvert\bin\Debug\FileConvert.pdb

     文件      11600  2019-04-15 14:05  FileConvert\bin\Debug\FileConvert.vshost.exe

     文件        490  2016-07-16 19:44  FileConvert\bin\Debug\FileConvert.vshost.exe.manifest

     文件      86016  2006-10-12 12:20  FileConvert\bin\Debug\FontBox-0.1.0-dev.dll

............此处省略129个文件信息

评论

共有 条评论