0

I am trying to code a program that would synchronize the scrolling of two PDFs between two computers. I have no experience in C# programming but I have fooled around with Visual C++ alot. Anyway, my problem is that whenever I run my still very basic code I get the following error message: "Object reference not set to an instance of an object." with a break or continue option.

Here's my code for now:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DocSync
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            webBrowser1.Navigate("C:\\Users\\Anas\\Desktop\\someDocument.pdf");

        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {


            label1.Text= webBrowser1.Document.Body.ScrollRectangle.Height.ToString();
        }
    }
}

Thanks in advance for any response. Also, I would appreciate any suggestions to how to proceed with what I want to achieve.

Winneris1
  • 11
  • 3
  • When you navigate to a PDF file using the WebBrowserControl, webBrowser1.Document is null and that is causing the exception. As an example, change the filename to "www.google.com" and your code will not throw an exception. – Steve Wong Jan 13 '16 at 19:37
  • oh.. Then how do you suggest I go around this. I tried using acrobats library but after endless hours of trying I just gave up on it. – Winneris1 Jan 13 '16 at 20:28

0 Answers0