Running initial sample

I have downloaded the free version of GemBox and am trying to code up an initial test. I am running the HTML to PDF example.

However, when I put the same code that is in the example I get errors. I added a few more references thinking that would work but it doesn’t.

In this code:

var htmlLoadOptions = new HtmlLoadOptions();
using (var htmlStream = new MemoryStream(htmlLoadOptions.Encoding.GetBytes(html)))
    // Load input HTML text as stream.
    var document = DocumentModel.Load(htmlStream, htmlLoadOptions);
    // Save output PDF file.

There is a problem with “new MemoryStream(htmlLoadOptions.Encoding.GetBytes(html)))” The ‘Encoding’ is in red with this message when I hover over it: Reference to type ‘Encoding’ claims it is defined in ‘System.Runtime’, but it couldn’t be found

I specifically included a reference to “System.Text.Encoding” but that didn’t seem to help. What is missing?

Thanks in advance,

As a follow up, I tried the very simple example found in the articles section and doing this:

DocumentModel document = DocumentModel.Load("Input.html", LoadOptions.HtmlDefault);

Results in a “Reference to type ‘Stream’ claims it is defined in System.Runtime, but it could not be found.” error

Is the ‘Stream’ object in GemBox different than the basic ‘System.IO.Stream’ object?

Hi Paul,

There seems to be some problem with your project’s setting.
Can you please send us a small Visual Studio project that reproduces your issue so we can investigate it?


Your project is targeting 4.5.2 so you need to use GemBox.Document 3.5 for .NET Framework 3.5.
Please try again using version

Does this solve your issue?