Hello everyone,
new to the forum and new to pdfsharp. I'm trying to create a C# winform program that will open a PDF from a file location, then redact(*) a portion of the PDF, and finally save the PDF in the same location with a random password encryption.
I have found many bits and pieces of code here on the forum and by using google, but the one thing that I still can't figure is how to actually open a PDF using winforms and C#. The issue seems to be that I'm not referencing the correct dll's. I have, for example, this simple code snippet that is supposed to open a file dialog and let me open a file:
Code:
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;
using PdfSharp;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
using (OpenFileDialog dlg = new OpenFileDialog())
{
dlg.Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*";
dlg.ShowDialog();
this.acroViewer.LoadFile(dlg.FileName);
}
//this.acroViewer.ShowToolbar = false;
}
}
}
But I get an error from VS2010 saying that there is no definition for acroviewer. I loaded the nuget package for PdfSharp and it shows in the references. So what else am I missing?
Thanks for the help!
Chris
(*) I know I'm not really redacting, merely covering things up, but the password protection is sort of a workaround to make it look like it's redacted.
![Wink :wink:](./images/smilies/icon_wink.gif)