使用C#使用pdfbox库加载pdf. [英] Load a pdf with pdfbox library using C#.

查看:828
本文介绍了使用C#使用pdfbox库加载pdf.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

加载pdf文件时出现问题...

I have a problem when load a pdf file...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using org.pdfbox.pdmodel;
using org.pdfbox.pdmodel.edit;
using org.pdfbox.util;

namespace DemoChooseArea
{
    class Program
    {
        protected static void Load()
        {
            PDDocument doc = PDDocument.load("Sample");
            PDFTextStripper pdfStripper = new PDFTextStripper();
            Console.Write(pdfStripper.getText(doc));

            

        }
        
        static void Main(string[] args)
        {
            Load();
        }
    }
}


请帮助我!


Please help me!

推荐答案

尝试一下,
Try this,
string pdfFile = "C:\\Temp\\test.pdf";            
PDDocument doc = PDDocument.load(pdfFile);
PDFTextStripper pdfStripper = new PDFTextStripper();
Console.Write(pdfStripper.getText(doc));


我希望您已经完成了所有写在文章中的内容
您必须下载PDFBox软件包.在此软件包中,您会找到一个bin目录.要阅读PDF文件,您需要以下文件:
I hope you have done all this, written in the article
you’ll have to download the PDFBox package. In this package you’ll find a bin directory. To read your PDF file, you’ll need the following files:
IKVM.GNU.Classpath.dll
PDFBox-0.7.3.dll
FontBox-0.1.0-dev.dll
IKVM.Runtime.dll


您必须在项目中添加对前两个参考.您还必须将最后两个复制到项目的bin目录中.

也请参考此链接
http://www.c-sharpcorner.com/UploadFile/mgold/CreatingandOpeningMicrosoftDocumentfrom. / [ ^ ]


You’ll have to add a reference to the first two in your project. You’ll also have to copy the last two on your project’s bin directory.

Refer this link too
http://www.c-sharpcorner.com/UploadFile/mgold/CreatingandOpeningMicrosoftDocumentfrom./[^]


我加载了...嗯...谢谢大家,但我想选择标题和pdf文件的内容.我该怎么办?
请帮助我
I loaded...uhm...thanks everyone,but I want to choose a title and a content of a pdf file.How can I do ???
Please help me


这篇关于使用C#使用pdfbox库加载pdf.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆