The drag and drop would require you to create some front end programming perhaps in javascript
using System;
using System.Diagnostics;
using System.IO;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
namespace HelloWorld
{
/// <summary>
/// This sample is the obligatory Hello World program.
/// </summary>
class Program
{
static void Main(string[] args)
{
// Create a new PDF document
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
// Create an empty page
PdfPage page = document.AddPage();
// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);
// Create a font
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
// Draw the text
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.Center);
// Save the document...
const string filename = "HelloWorld.pdf";
document.Save(filename);
// ...and start a viewer.
Process.Start(filename);
}
}
}
public ActionResult Convert(FormCollection collection)
{
// read parameters from the webpage
string url = collection["TxtUrl"];
string pdf_page_size = collection["DdlPageSize"];
PdfPageSize pageSize = (PdfPageSize)Enum.Parse(typeof(PdfPageSize), pdf_page_size, true);
string pdf_orientation = collection["DdlPageOrientation"];
PdfPageOrientation pdfOrientation = (PdfPageOrientation)Enum.Parse(
typeof(PdfPageOrientation), pdf_orientation, true);
int webPageWidth = 1024;
try
{
webPageWidth = System.Convert.ToInt32(collection["TxtWidth"]);
}
catch { }
int webPageHeight = 0;
try
{
webPageHeight = System.Convert.ToInt32(collection["TxtHeight"]);
}
catch { }
// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();
// set converter options
converter.Options.PdfPageSize = pageSize;
converter.Options.PdfPageOrientation = pdfOrientation;
converter.Options.WebPageWidth = webPageWidth;
converter.Options.WebPageHeight = webPageHeight;
// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl(url);
// save pdf document
byte[] pdf = doc.Save();
// close pdf document
doc.Close();
// return resulted pdf document
FileResult fileResult = new FileContentResult(pdf, "application/pdf");
fileResult.FileDownloadName = "Document.pdf";
return fileResult;
}