How to use PDF file in C#

In this article, I will explain to you how to open a pdf file and how to scroll pages when a button click. 

First, you need to add COM Component  “Adobe PDF Reader” and add two command buttons and adobe reader control.


If you like this article please share and leave your comment and suggestion
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;
namespace PDFinCSharp
{
    public partial class Form1 : Form
    {
        int k = 0;
        int i = 1;
        public Form1()
        {
            InitializeComponent();
        }
        private voidbutton1_Click(object sender, EventArgs e)
        {
           
            OpenFileDialog Ofd = new OpenFileDialog();
            Ofd.ShowDialog();
            textBox1.Text = Ofd.FileName;
            axAcroPDF1.LoadFile(textBox1.Text);
            axAcroPDF1.setShowScrollbars(true);
            axAcroPDF1.setShowToolbar(true);
            axAcroPDF1.setCurrentPage(i);
        }
        private voidbutton2_Click(object sender, EventArgs e)
        {
           
            // Page Scrolling
            axAcroPDF1.setViewScroll(“FitH”, k);
            if (k >= 600) 
            {
                i += 1;
                k = 0;
                axAcroPDF1.setCurrentPage(i);
            }
            k = k + 30;
        }
    }
}

One Comment on “How to use PDF file in C#”

Leave a Reply

Your email address will not be published. Required fields are marked *