We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Help with Essential PDF reference issue

Hello,

I am trying to evaluate the Essential PDF component. I have a strange error at the line:

HtmlConverter html = new HtmlConverter();

When I attempt to build I get the following error:

The type 'System.Windows.Forms.UserControl' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

I have read http://www.syncfusion.com/support/forums/pdf-aspnet/45439 and have still not resolved the matter. I have added ALL of the Syncfusion DLLs to the application's bin directory and the error persists.

Thanks in advance for any help in the matter.

ASPX:
-----
<%@ Page AspCompat="true" Language="C#" AutoEventWireup="true" CodeFile="IndexPDF.aspx.cs" Inherits="Pages_Dashboard_IndexPDF" %>




Hello world.




CODE BEHIND:
------------
using System;
using System.Drawing.Imaging;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.HtmlToPdf;

public partial class Pages_Dashboard_IndexPDF : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
btnPdf.Click += new EventHandler(btnPdf_Click);
}

protected void btnPdf_Click(object sender, EventArgs e)
{
// Create a new document.
PdfDocument doc = new PdfDocument();

// Add a page
PdfPage page = doc.Pages.Add();

PdfUnitConvertor convertor = new PdfUnitConvertor();
float width = convertor.ConvertToPixels(page.GetClientSize().Width, PdfGraphicsUnit.Point);

HtmlConverter html = new HtmlConverter();

// setting Javascript
html.EnableJavaScript = true;
// Setting Pagebreak
html.AutoDetectPageBreak = true;
// set hyperlink
html.EnableHyperlinks = true;

HtmlToPdfResult result = html.Convert("index.aspx", ImageType.Metafile, (int)width, -1, AspectRatio.KeepWidth);

if (result != null)
{
PdfMetafile mf = new PdfMetafile(result.RenderedImage as Metafile);
mf.Quality = 100;

PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Break = PdfLayoutBreakType.FitPage;
format.Layout = PdfLayoutType.Paginate;
doc.PageSettings.Height = result.RenderedImage.Size.Height;
format.SplitTextLines = true;
format.SplitImages = true;
result.Render(page, format);
}
}
}



2 Replies

MA Mark November 3, 2010 03:25 AM UTC

Resolved: went to Website/Add Reference... and selected System.Windows.Forms.

This strikes me as bizarre given that this is a website application. Is this *really* required? This strikes me as strange.



PJ Priyadharshini J Syncfusion Team November 3, 2010 11:24 AM UTC

Hi Mark,

Thank you for your interest in syncfusion products.

Our HTMLConverter class internally makes use of the web browser control which is part of System.Windows.Forms assembly.

So, while using the Html COnverter we have to add the System.Windows.Forms assembly reference.

Please let me know if you have any queries.

Regards,
Priyadharshini


Loader.
Live Chat Icon For mobile
Up arrow icon