获取C#的pdf文件中的当前页面 [英] Get current page in pdf file for C#

查看:278
本文介绍了获取C#的pdf文件中的当前页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用#完整打开pdf文件并获取当前页面。用户必须完全成长到PDF的结尾并执行操作后。



至少玩得开心。谢谢你。



我尝试过:



我用默认的librarry(AcroPDFLib),但我无法访问当前页面。

I need to open the pdf file in full with # and get the current page. It is necessary for the user to fully grow to the end of the PDF and after performing the actions.

Have fun at least something. Thank`s.

What I have tried:

I use default librarry (AcroPDFLib), but i don`t have access for current page.

推荐答案

using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;

namespace PdfParser
{
    public static class PdfTextExtractor
    {
        public static string pdfText(string path)
        {
            PdfReader reader = new PdfReader(path);
            string text = string.Empty;
            for(int page = 1; page <= reader.NumberOfPages; page++)
            {
                text += PdfTextExtractor.GetTextFromPage(reader,page);
            }
            reader.Close();
            return text;
        }   
    }
}


这篇关于获取C#的pdf文件中的当前页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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