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.
Unfortunately, activation email could not send to your email. Please try again.

Help with Essential PDF reference issue

Thread ID:

Created:

Updated:

Platform:

Replies:

97164 Nov 2,2010 08:15 PM Nov 3,2010 07:24 AM ASP.NET Web Forms (Classic) 2
loading
Tags: PDF
Mark
Asked On November 2, 2010 08:15 PM

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



Mark
Replied On November 2, 2010 11:25 PM

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 07:24 AM

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


CONFIRMATION

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.

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.

;