Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用c#从pdf中逐字读取和显示,在页面中的时间间隔为1秒_C# - Fatal编程技术网

使用c#从pdf中逐字读取和显示,在页面中的时间间隔为1秒

使用c#从pdf中逐字读取和显示,在页面中的时间间隔为1秒,c#,C#,我有一个pdf文件。我需要阅读的内容和显示的字从pdf,在一个1秒的时间间隔页 在这里,我可以阅读pdf内容,我需要在一个文本框或标签中逐字显示(每秒钟一个单词)(每秒钟一个单词)。在这一点上我需要帮助 谢谢。我不确定你粘在了哪个部位,但我想你的意思是一次一秒地显示这个词。我还假设您的意思是Windows窗体应用程序-web应用程序需要使用Javascript来完成(window.setInterval将替换计时器) 公共部分类表单1:表单 { 公共表格1() { 初始化组件(); } Stri

我有一个pdf文件。我需要阅读的内容和显示的字从pdf,在一个1秒的时间间隔页

在这里,我可以阅读pdf内容,我需要在一个文本框或标签中逐字显示(每秒钟一个单词)(每秒钟一个单词)。在这一点上我需要帮助


谢谢。

我不确定你粘在了哪个部位,但我想你的意思是一次一秒地显示这个词。我还假设您的意思是Windows窗体应用程序-web应用程序需要使用Javascript来完成(
window.setInterval
将替换计时器)

公共部分类表单1:表单
{
公共表格1()
{
初始化组件();
}
StringBuilder textDisplayed=新建StringBuilder();
int currentWord=0;
字符串[]个单词;
私有void Form1\u加载(对象发送方、事件参数e)
{
//虚拟内容,这来自您的PDF阅读代码
string textContent=“这是我的测试字符串,每次显示一个单词,间隔1秒。”;
//将内容拆分为单词
words=textContent.Split(“”);
//创建一个每秒滴答作响的计时器
定时器=新定时器();
计时器。间隔=1000;
timer.Tick+=新事件处理程序(timer\u Tick);
timer.Start();
}
无效计时器勾号(对象发送方,事件参数e)
{   
//检查我们是否通过了文档的结尾

if(words.Length)到目前为止,你做了什么来解决这个问题?你尝试过什么吗?如果是,效果如何?是的,你需要哪部分的帮助?从PDF中获取内容或每隔1秒显示单词?
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    StringBuilder textDisplayed = new StringBuilder();
    int currentWord = 0;
    string[] words;

    private void Form1_Load(object sender, EventArgs e)
    {
        // Dummy content, this comes from your PDF-reading code
        string textContent = "This is my test string that is appearing a word at a time, in one second intervals.";

        // Split the content into words
        words = textContent.Split(' ');

        // Create a timer that ticks every second
        Timer timer = new Timer();
        timer.Interval = 1000;
        timer.Tick += new EventHandler(timer_Tick);
        timer.Start();
    }

    void timer_Tick(object sender, EventArgs e)
    {   
        // Check whether we've passed the end of the document
        if (words.Length <= currentWord)
        {
            ((Timer)sender).Stop();
            return;
        }

        // Append the current word to the stringbuilder
        textDisplayed.Append(words[currentWord++]);
        textDisplayed.Append(" ");

        // Set the textbox content
        txtText.Text = textDisplayed.ToString();
    }
}