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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Help with Essential PDF reference issue

Thread ID:





97164 Nov 3,2010 12:15 AM UTC Nov 3,2010 11:24 AM UTC ASP.NET Web Forms (Classic) 2
Tags: PDF
Asked On November 3, 2010 12:15 AM UTC


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=, 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.

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

Hello world.

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);

Replied On 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.

Priyadharshini J [Syncfusion]
Replied On 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.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon