Frequently Asked Questions

 

A: "The URL is not accessible" message is normally followed by a more detailed message which should clearly indicate the root of the problem. Below is a general description of the possible reasons of this error.

If the application works correctly on your development machine but it's not working on the server then it's very likely to be an issue related to security, permissions or authentication on the server.

First make sure the web page you are converting is accessible for converter. If the page requires server authentication (like IIS authentication - Integrated Windows Authentication) you can provide the correct Username and Password using the AuthenticationOptions property of the PdfConverter.

If your application is using ASP.NET level authentication like Forms Authentication the converter will not be able to authenticate because it doesn't send back to the web server the authentication cookie created during the authentication process between the browser and IIS. If using the forms authentication is a requirement for your application you might try to configure your application to use the cookieless mode for the forms authentication.

Other access restrictions can be introduced by proxy servers or firewalls. When you access the web page from Internet Explorer for example it might work because the proxy server settings are set in the Internet Options of the currently logged user and browser will use those settings to authenticate to the proxy. When you try to convert the same page from an ASP.NET application, the converter, which runs under the ASP.NET user account, is not using the Internet Settings for the currently loged in user and therefore it won't be able to authenticate to the proxy. Firewall servers can be a similar source of access restrictions that you'll have to check.

If you are converting a https URL from your network you can try the same url with http:// instead of https://. Running secured pages require a valid (not a self signed) SSL certificate. 

It is also possible, when converting a web page hosted on the server where you are performing the conversion, that the server cannot resolve the site name to an IP address. To eliminate this possibility try to use an IP address instead of a domain name.

The development servers have a more relaxed internet security configuration then the production servers. For example the Windows 2003 Server defaults to an internet security configuration which may not allow you to access the URL. You may have to relax or disable the enhanced security configuration to allow access to the pages you want to render. If removing the internet enhanced security configuration component is an option, you can do so from the "Add/Remove Windows Components" section of the "Add or Remove Programs" control panel. The internet enhanced security configuration component should be listed as "Internet Explorer Enhanced Security Configuration".

If you don't see any obvious reason for the web page to be inaccessible for the converter try to convert a HTML file from the server disk instead of an URL. You can simply pass to the converter the full path of the HTML file instead of the URL. If it works with a local HTML file then you can further try with an url like http://www.google.com which is likely to be available and accessible from your server. If this URL works then the URL you are trying to convert might not be accessible indeed for the converter and you should keep searching for the possible reasons. If it's not working it means the converter is not allowed to access Internet under the ASP.NET user account and you should further check proxy servers, firewalls, etc.

In general, because we don't know the exact network configuration of your server or of your intranet, we cannot tell exactly which of the possible access problems described above applies to your situation. You should carefully check the possible situations described above and also check with your network administrator about other possible access restrictions before going further.

If your are pretty sure there should be no access problem then make sure the web page you are trying to convert can be correctly loaded in the Internet Explorer browser running on your server while you are logged in as Administrator.  Make sure IE does not block the URL or throws any warnings when loading that page. and you'll have to find the reason with your server administrator.

If none of the recommendations above helped then try to find a permissions issue. The converter runs with the permissions granted to the ASP.NET user which are normally much lower than the permissions under which the IE web browser application runs. You can find out the ASP.NET user under which the converter is running by adding the <%= Environment.UserName %> line in the .ASPX from where the converter is called. The user name should be displayed when the .ASPX page is loaded in browser. 

To make sure it's a permissions issue try to convert the same HTML page using the Free HTML to PDF Converter Windows Forms Application that we provide as a separate download or the one that you have built from the samples folder. This Windows Forms application will run as the currently logged in user, preferable an Administrator. If this application works then it might be a permissions issue. You can temporary add the ASP.NET user (determined as above) to Administrators group on the server or you can use ASP.NET impersonation by adding the following line in the web.config of your application under the <system.web> section : <identity impersonate="true" userName="WindowsDomain\YourUserName" password="YourPassword"/>. If the conversion works you can start looking into what exactly permissions the converter needs from your server and grant those permissions to the ASP.NET user.

A useful tool for finding permissions issues is the Process Monitor. You can download this tool from Microsoft web site. The ProcessMonitor will monitor every file and registry access on your machine in real time. You have to start the tool and then make the issue to occur. You should look for suspicious FAILURE and ACCESS DENIED messages. You can try to filter the messages by ASP.NET worker process ID to substantially reduce the number of displayed messages. You might find for example that the ASP.NET user cannot create files into the Internet Temporary Folder where the images and CSS files are temporary downloaded or the ASP.NET user has not enough rights to read the Internet Settings from Windows Registry.

If you have followed all the steps above and you could not find the reason of the problem please contact us with the result of all these steps. We'll try to work with you to localize the problem.

A: When you convert a HTML string referencing external CSS files and images by relative URLs, the converter cannot determine the full URLs just looking at the string.

In order to solve this you have to set the baseURL parameter of the HTML string convert function with the full URL of the page from where you have retrieved the HTML string. This requires from the HTML string to have a valid HEAD tag. When the relative paths of your images are textually prefixed with the baseURL parameter the full URL of the images should be produce in order to start getting images in PDF.

As an alternative you can manually insert a BASE tag in the HEAD tag of the HTML page as in the example below or use full URLs in the HTML string:

              <HEAD> <BASE HREF="SiteURL"> </HEAD>

Note: This issue might also indicate an authentication or permissions problem on the server when accessing the external resources like images and CSS files. The HTML string is loaded into converter and the text is converted to PDF but the images and CSS files are still accessed from an URL and they might not be accessible.

If you are sure that the url base you have set is correct but the images still don't appear in PDF you can try to prefix a relative image URL from the HTML string with the the base url to construct a full image URL. Then you can put this url in the IE web browser on the server where you perform the conversion and check that the image is correctly displayed in the browser. After that you can try to convert the image URL to PDF using the GetPdfBytesFromUrl() method. If the image is not accessible you should get a "The URL is not accessible." error. See the question above regarding the 'URL is not accessible' exception to find out more details about how to localize and troubleshoot this problem.

Another special situation where this problem might occur is for ASP.NET applications using forms authentication. The ASP.NET forms authentication implementation usually stores the forms authentication ticket in a cookie which should be sent back to server each time a resource is requested but the converter does not have the ability to automatically send this kind of cookie back to the server and therefore the authentication of the requests of external resources like images and CSS files can fail. A possible workaround for this problm is to store the images and CSS files referenced by the web page to be converted in a location which doesn't require authentication. If this is not an acceptable solution then you can try to set the forms authentication to the cookieless mode. In this mode the encrypted authentication ticket is set in the URL query string and not in a cookie and the base URL parameter of the HTML string convert function should be set accordingly to the URL containing the authentication ticket. You can read more about forms authentication at the following address: Forms Authentication Explained .

A: The ExpertPDF HTML to PDF converter allows a very fine control of the PDF rendering process. The default settings of the converter should be acceptable for majority of the situations but sometimes more control and customizations are necessary. If want to learn more about the HTML to PDF rendering please check this article.

The converter internally uses a virtual display where to render the HTML page very similar to what the web browser does on the screen. This virtual display is different from display of your computer and it has a fixed resolution on your computer (which normally is 96 dpi) independent of the resolution of your computer screen. The web page elements dimensions are usually measured in pixels and this is the reason why the virtual display of the converter is also specified in pixels. These are the only dimensions used by the converter which are expressed in pixels. All the other dimensions are specified in points (1 point is 1/72 inches). However, because of the fixed resolution of the virtual display, the pixels dimensions of your web page can be easily converted to dimensions expressed in points . The converter API offers the UnitsConverter class which can be used to convert dimensions from pixels to points and from points to pixels.

You can specify the virtual display width and height in pixels using the PdfConverter.PageWidth and PdfConverter.PageHeight properties or you can specify the same values as parameters when you construct the PdfConverter object.

By default the PageWidth is set to 1024 pixels which should be sufficient to display the majority of the web pages. If the web page you are converting cannot be completely displayed in this width then you can increase this value or you can set the PageWidth to 0 to allow the converter to automatically determine your web page width from the HTML elements width. The PageHeight property is 0 by default which means the virtual display will be automatically resized to display the whole HTML page. There are situations when the converter cannot automatically determine the web page height for example when the web page is a frame set. In this case you can manually set the PageHeight to certain value in pixels such that the page is displayed in the way you expect.

After the HTML content is displayed in the virtual display the virtual display content will be transfered into PDF as you would take a picture of the virtual display and put that picture into a PDF document. The PDF documents pages have a fixed size in points. For example, the A4 page is 595 points in width and 842 points in height. If the virtual display width is more than 595 points then the rendered HTML content would be shrinked to fit the PDF page width and display the whole HTML content in the PDF document.  If the virtual display width is less than 595 points then the rendered HTML content will not be resized and will be rendered in the top left corner of the PDF page at real size.

The dimension of the A4 portrait page in virtual device pixels is 793x1122 pixels. This means that at a default virtual display width of 1024 pixels the HTML content will be shrunk to fit the PDF page. This is the reason why you see smaller fonts and images in PDF.

In the version version 3.5.2 of the converter a new property FitWidth was added to the PdfConverter.PdfDocumentOptions. The default value is true which makes the HTML content to be resized if necessary to fit the PDF page width. When false, the HTML content will not be resized and it will be rendered at the real size in PDF (the size it has in the virtual display at the usual resolution of 96 dpi).

When the FitWidth property is false the HTML content could be wider than the PDF page width and the therefore the HTML content will be cut off to the right in PDF. In this case, in order to get the whole content in PDF you have to set a wider page for the PDF document. You can first try to set landscape orientation for the PDF page by setting PdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Landscape. If this not enough you can choose a wider standard page like A3 or A2. You can even set a custom size for the PDF page. Starting with version 3.2 of the converter you can set the PdfConvert.PdfDocumentOptions.PdfPageSize=PdfPageSize.Custom and in this case the custom size of the PDF page will be taken from PdfConverter.PdfDocumentOptions.CustomPdfPageSize property.  

In version 4.0 of the HTML to PDF Converter product we added a new property PdfConverter.PdfDocumentOptions.AutoSizePdfPage which is has effect only when the FitWidth property is false. When FitWidth is false and AutoSizePdfPage is true, the PDF page width will automatically be resized to a custom value such that all the HTML content is displayed in PDF at real size.

If you don't want to resize the PDF page but you want to keep it A4 portrait for example, then you have to decrease the virtual display width. If your page can be correctly and entirely displayed in 793 pixels (which is the width of the A4 portrait page in pixels) you can set this value for PdfConverter.PageWidth property and you should get the whole HTML rendered at real size in PDF.

The HTML content centering in PDF problem can be observed when the HTML content can be normally displayed at a width less than 1024 pixels. In this case there will normally be an empty space in the right side of the virtual display. When the virtual display content is transfered to PDF the content will appear as not centered in PDF. You can also solve this if you set the PdfConverter.PageWidth to a value of 793 pixels or less.

A: Starting with version 3.5 the converter can run on all 64-bit Windows versions both in 64-bit mode and 32-bit WoW mode.

A: If you are trying to convert a ASP.NET page you can use the Server.Execute method from to obtain the HTML string. Here is some C# code to obtain the HTML string from a page of your application:

        StringWriter sw = new StringWriter();
        Server.Execute("PageToConvert.aspx", sw);
        string htmlCodeToConvert = sw.GetStringBuilder().ToString();

You can also use the methods from ConverterUtils class that we provide in the library to get the HTML code from a web page from Internet.

The converter library offers a set of methods for converting a HTML string to PDF. See the WebLibrary_DynamicInvoiceDemo for a complete sample of how to retrieve the HTML code and convert it to PDF. 

A: The converter executes the web page to be converted in a new session, different from the session in which your ASP.NET application runs. This basically happens because the converter does not send the session cookie from the browser back to the server. Therefore, the data currently stored in the session is not available in the converter web page even if the page is part of your application.

See the InvoicesDemo application for ASP.NET for a complete sample of how to retrieve the HTML code from a ASP.NET page, pass the session data to the converted page and convert the HTML string to PDF. This application is also installed as a live demo in our website.

Basically you have 2 options to consider when trying to overcome this situation: to send the necessary data for loading the page to be converted in the query string of the converted page URL or to get the web page HTML code using the Server.Execute(Url) method as we do in the InvoicesDemo sample . The Server.Execute method is executed in your application session so all the session data and existing authentication should be valid.

When getting the HTML string with the Server.Execute(Url) method the resulted HTML code should reference the external CSS, images and JavaScript code by a full URL not  by a relative URL. Here is some C# code to obtain the HTML string from a page of your application:

        StringWriter sw = new StringWriter();
        Server.Execute("PageToConvert.aspx", sw);
        string htmlCodeToConvert = sw.GetStringBuilder().ToString();

To instruct the converter how to automaticallt turn all the relative URLs into absolute URL you have to pass the baseURL parameter of the convert function with the full URL of the page from where you have taken the HTML string.

A: The session cookies stored by the browser are not automatically sent to the web server by the converter when the converter is called from an ASP.NET page.

Starting with the version 5.4 of the converter it is possible to send custom HTTP headers when a page is requested from the web server. A cookie can be sent to the web server using such a custom HTTP header. The syntax to configure the converter to send a cookie to the web server is:

        pdfConverter.HttpRequestHeaders = String.Format(
            "Cookie : {0}={1}\r\n", cookieName, cookieValue
        );

A: The converter offers support for server authentication, for example any type of IIS authentication (Integrated Windows Authentication, Basic Authentication, etc). To enable server authentication you have to set the PdfConverter.AuthenticationOptions property with the username and password. The server authentication is usually necessary when accessing Intranet resources.

Please do not confound the server authentication with the authentication implemented at the level of your application (usually implemented as a login page in your application ). If you need to deal with application level authentication please read below.

The converter executes the web page to be converted in a new session, different from the session in which your ASP.NET application runs. Therefore, the data currently stored in the session is not available in the converter web page even if the page is part of your application. Also the converter does not have any built-in support for authentication.

You have 2 options to consider  when trying to overcome this situation : to send the necessary data for loading the page to be converted in the query string of the converted page URL or to get the web page HTML code using the Server.Execute(Url) method from ASP.NET and then convert that string to PDF as we do in the dynamic invoices sample. The Server.Execute() method is executed in your application session so all the session data and existing authentication should be valid.

See the InvoicesDemo application for ASp.NET for a complete sample of how to retrieve the HTML code, pass the session data to the converted page and convert the HTML string to PDF. 

When getting the HTML string with the Server.Execute(Url) method the resulted HTML code should reference the external CSS, images and JavaScript code by a full URL not  by a relative URL. Here is some C# code to obtain the HTML string from a page of your application:

        StringWriter sw = new StringWriter();
        Server.Execute("PageToConvert.aspx", sw);
        string htmlCodeToConvert = sw.GetStringBuilder().ToString();

To instruct the converter how to automatically turn all the relative URLs into absolute URL you have to pass the baseURL parameter of the convert function with the full URL of the page from where you have taken the HTML string.

A: The HTML to PDF converter supports custom page breaks with standard CSS styles like page-break-before:always and page-break-after:always applied to any HTML object. The page-break-inside:avoid style can be applied to a element to prevent splitting the content inside the element between pages. 

A: You can apply inline the page-break-inside:avoid CSS style to the HTML element you want to keep appear in the rendered PDF document on same page. Of course the element height must be less than the page height, otherwise the style will be ignored by the converter. Please note that unlike the page-break-before and page-break-after , the page-break-inside:avoid style must be specified inline as in the example below:

<table>
        <tr style="page-break-inside : avoid">
            <td>
                <img width="100" height="100" src="img1.jpg">
            </td>
            <td>
                My text 1
            </td>
        </tr>
    
        <tr style="page-break-inside : avoid">
            <td>
                <img width="100" height="100" src="img2.jpg">
            </td>
            <td>
                My text 2
            </td>
        </tr>
</table>

In this example the table can contain a large number of rows, each row containing an image in the left and a text in the right and we don't want such a row to span on two pages. This can be easily achieved by specifying the page-break-inside:avoid style inline for the table row.

A: Starting with version 3.5 of the converter you can add HTML in the header and footer of the rendered PDF document. To add HTML in the header you have to initialize the PdfConverter.PdfHeaderOptions.HtmlToPdfArea property with a HtmlToPdfArea object which can be constructed from a HTML string or an URL. The 'WinForms_HeaderAndFooterHtml' sample from the downloaded archive is a sample showing how to add HTML or pages numbering in the header and footer.

A: By default the header (or footer) is the same for all the pages in the generated PDF document. The header and footer content is defined by the PdfHeaderOptions and PdfFooterOptions properties of the PdfConverter class.

Starting with version 5.4 of the HTML to PDF Converter library it is possible to override the default header or footer for any of the pages of the generated PDF document. The Samples\WinForms\WinForms_HtmlInHeaderAndFooter sample from the installation folder contains sample code for how to alternate the header and footer content on odd and even pages of the generated PDF document.

A: Starting with version 5.1 it is possible to add many HTML documents to the same PDF document using the PostConvertActionEvent feature and we provide the MultipleHtmlConversions sample both for ASP.NET and Windows Forms to show how to do this. The first document is added to PDF using the usual methods like GetPdfBytesFromUrl() or GetPdfFromHtmlString(). The other documents are added in the PostConvertActionEvent handler as HtmlToPdfElement objects. You can add a HtmlToPdfElement on a new PDF page or you can continue right after the point where the rendering of the first HTML document ended. The 'Start second URL conversion on a new PDF page' checkbox in the sample application controls this. You can find where the first document finished rendering from the ConversionSummary property of the argument passed to the event handler. If you want to add many HtmlToPdfElement objects one after the other, you can find where a HtmlToPdfElement finished rendering from the AddElementResult object returned as result of adding the HtmlToPdfElement object to the PDF page and you can start the next HtmlToPdfElement object from that position.

A: The PdfConverter.PdfDocumentOptions.LiveUrlsEnabled controls the rendering of http links in the resulted PDF document. By default this property is true.

A: The converter supports any true type font preinstalled in Windows operating system. It also supports the open type fonts with the condition that the open type font has TrueType outlines not PostScript outlines. To check what type of outlines has an installed font, you can open the font from the Fonts folder in Control Panel. When a font is not supported by the converter the MS Sans Serif font is used by default.

The converter also supports custom true type fonts you can install from a .ttf or a .otf file. After you have installed a font it becomes available only for the currently logged in Windows user who installed the font. In order to make the font available for all the users, including the ASP.NET user in the case you are using the converter from an ASP.NET application, you have to reboot the computer after font installation.

To embed the true type fonts in the generated PDF you have to set PdfConverter.PdfDocumentOptions.EmbedFonts=true. By default this property is false. The same property is also available in the HtmlToPdfElement class defined by the PDF Creator and HTML to PDF Converter libraries.

A: First make sure that you restarted the server after true type font installation. After you have installed a font it becomes available only for the currently logged in Windows user who installed the font. In order to make the font available for all the users, including the ASP.NET user, in case you are using the converter from an ASP.NET application, you have to restart the server after font installation.

If the server restarting didn't solve the problem then make sure you installed a supported type of font. The converter supports any true type font preinstalled in Windows operating system. It also supports the open type fonts with the condition that the open type font has TrueType outlines not PostScript outlines. To check what type of outlines has an installed font, you can open the font from the Fonts folder in Control Panel. When a font is not supported by the converter the MS Sans Serif font is used by default.

Another situation when the default font is used occurs when the style used for a font is not supported by that font. The true type fonts have separate glyphs for different styles. For example a font can have separate glyphs for the normal, italic or bold styles. Some fonts can support only the normal style other fonts can support only the italic style. You have to use only the styles supported for a true type font. You can see what styles are available for a font in the Fonts folder of the Control Panel. If a font does not have the required style the converter first tries to use a supported style and if it is not possible then a default font is used.

A: Set the PdfConverter.AvoidImageBreak property on true. By default this property is false and the images might get cut off between PDF pages. You can also set the page-break-inside:avoid CSS style inline on the IMG tag to achive the same result.

A: By default the the converter is using JPEG to compress images in PDF and to reduce the size of the generated PDF document. The compression level of the images is controlled by the PdfConverter.PdfDocumentOptions.JpegCompressionLevel property. When the JpegCompressionLevel is 0, the compression rate is the lowest and the quality of the images is the best. When the JpegCompressionLevel is 100, the compression rate is the highest and quality of the images in PDF is the worst. The default JPEG compression level is 10, which should offer a good balance between the compression rate and the quality of the images in PDF.

It is also possible to completely disable the JPEG compression and store the images as bitmaps in PDF if you set PdfConverter.PdfDocumentOptions.JpegCompressionEnabled to false. This produces the best quality of the images but the generated PDF document can be very large and the conversion process is slower.

A: The PdfConverter has the following properties controlling the JavaScript, Java Applets and ActiveX download and execution during conversion: ScriptsEnabled, ScriptsEnabledInImage, ActiveXEnabled, ActiveXEnabledInImage. By default these properties are false which means the JavaScript code is not enabled during conversion. To activate JavaScript simply set PdfConverter.ScriptsEnabled = true when converting to PDF with selectable text or set PdfConverter.ScriptsEnabledInImage = true when converting to PDF with embedded image.

If you already set the PdfConverter.ScriptsEnabled on true and the JavaScript code is still not executed it means the Internet Security Settings on your server don't allow the JavaScript execution. JavaScript code could work when you load the page in Internet Explorer because the browser runs under the currently logged in user and for this user the JavaScript execution is allowed by the Internet Security Settings for the security zone of the page you are trying to convert. When you run the converter from an ASP.NET application the JavaScript execution might not be allowed for the ASP.NET user and for the security zone of the web page you are converting. A simple thing you can do is to move the web page in a more permisive Internet Security Zone like Local Machine. You can achieve this if you set the PdfConverter.InternetSecurityZone property with the InternetSecurityZone.LocalMachine value. If it's still not working you might have to modify directly into the Windows Registry the ASP.NET user Internert Security profile to allow JavaScript execution. The following technical article from Microsoft shows how to configure the internet security zones registry, including the JavaScript and ActiveX execution.

Internet Explorer security zones registry entries

The key 1400 in each security zone should be set to 0 both in HKEY_LOCAL_MACHINE and in HKEY_USERS for the user running the converter. After you have modified the registry you have to reboot the computer to make sure the new configuration is applied.

A: The flash images and movies are rendered by an external flash player which is an ActiveX control. First you have to make sure a flash player is installed on your server and the flash image or movie is displayed when the web page is loaded in the IE browser running on your server without any warnings. Then you have set the PdfConverter.ActiveXEnabled=true when converting to PDF with selectable text or PdfConverter.ActiveXEnabledInImage=true when converting to PDF with embedded image. Please note that the converter could automatically switch to a PDF with embedded image when ActiveXEnabled property is true. Sometimes the ActiveX control are written in HTML using JavaScript. In this case the JavaScript execution should also be enabled during conversion as explained in the answer to the previous question.

If you already activated ActiveX controls during conversion but your flash image still doesn't appear in PDF or is empty then this probably happens  because the flash control did not finish to initialize the image when the converter detected the web page was completely loaded. You can try to manually set a delay before starting the PDF conversion using the PdfConver.ConversionDelay and setting it to a small value in seconds (you can start with a 3 seconds delay for example).

If the flash images still don't appear in PDF it means the Internet Security Settings on your server don't allow the ActiveX execution. The ActiveX can work when you load the page in Internet Explorer because the browser runs under the currently logged in user and for this user the ActiveX execution is allowed by the Internet Security Settings for the security zone of the page you are trying to convert. When you run the converter from an ASP.NET application the ActiveX execution might not be allowed for the ASP.NET user and for the security zone of the web page you are converting. A simple thing you can do is to move the web page in a more permisive Internet Security Zone like Local Machine. You can achieve this if you set the PdfConverter.InternetSecurityZone property with the InternetSecurityZone.LocalMachine value. If it's still not working you might have to modify directly into the Windows Registry the ASP.NET user Internert Security profile to allow ActiveX execution. The following technical article from Microsoft shows how to configure the internet security zones registry, including the JavaScript and ActiveX execution.

Internet Explorer security zones registry entries

The key 1200 in each security zone should be set to 0 both in HKEY_LOCAL_MACHINE and in HKEY_USERS for the user running the converter. After you have modified the registry you have to reboot the computer to make sure the new configuration is applied.

A: The converter generates PDF documents in conformance with PDF 1.4 specification. This specification is fully supported starting with Adobe Reader 5.0.

A: Instead of the code from our samples which sends the PDF bytes to the browser as an attachment you can use the following code to open the generated PDF document inline:

        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
        response.Clear();
        response.AddHeader("Content-Type", "application/pdf");
        response.AddHeader("Content-Disposition",
            "inline; filename=" + downloadName + "; size=" + downloadBytes.Length.ToString());
        response.Flush();
        response.BinaryWrite(downloadBytes);
        response.Flush();
        response.End();

A: You can add external PDF files and streams to the conversion result using the AppendPDFFile, AppendPDFFileArray, AppendPDFStream and AppendPDFStreamArray properties of the PdfConverter.PdfDocumentOptions. You can find a full sample of how to use these properties under the 'WinForms_PrependAppendExternalPdfs' sample from the downloaded archive. If you need more flexibility in merging conversion results with external PDF documents then you can try our PDF Merge library which is a separate product.

A: Starting with version 3.2 of the converter you can set the PdfConvert.PdfDocumentOptions.PdfPageSize=PdfPageSize.Custom and in this case the custom size of the PDF page will be taken from PdfConverter.PdfDocumentOptions.CustomPdfPageSize property where you can specify the width and height of the PDF page in points.

A: The HTML to PDF converter library is a .NET 2.0 or above library and it is not working with .NET 1.1 directly. The workaround for this is to create an HTML to PDF Converter Web Service which exposes a simple method to return the rendered PDF document bytes from a specified URL. The web service internally should make calls to the converter library. 

Note: Another possible solution is to create a .NET 2.0 or above command line tool to be called from your application but there might be some additional overhead with this approach to execute the command line and retrieve the generated PDF document. We provide a sample console application Console_HtmlConvertDemo_CS in the HTML to PDF Converter archive that might be a good starting point.

A: Use the following property:

pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Landscape;

A: This indicates the converter was not able to correctly determine the height of the web page. The work around is to explicitly set the web page in pixels or to convert directly the web pages referred by the frameset frames. For example you can set pdfConverter.PageHeight = 2000;

A: The converter requires Full Trust level for the ASP.NET application calling it. The default trust level for an ASP.NET applications is Full Trust but the shared hosting providers usually modify the trust level to Medium Trust which makes our converter to not run properly in such environments. In order to solve this issue you can ask you shared hosting provider to give Full Trust level for you ASP.NET application. Another possibility is to create a ASP.NET web service around the converter library, install that web service on a machine where the full trust is allowed and call the web service from your application. You have to ensure that the web service you create can be used only from your application.

A: The converter needs a full trust level for your ASP.NET 2.0 application in order to correctly execute. The default trust level is full but some of the hosting providers set this to medium or lower. The trust level can be set in the Web.config of the application ( <trust level="Full"/> under the <system.web> config section) but the hosting provider could also forbid overriding the trust level from the web site configuration file.  

If your application already has full trust that means more security restrictions are imposed by the Windows to the assembly. Adding the assembly to the GAC (Global Assembly Cache) usually makes the assembly more trusted and solves the problem.

A special situation when this exception can occur is on Windows Vista family of operating systems (Windows Vista SP2, Windows 7). When you download the assembly from Internet the operating system marks the file as "Blocked". You can check the assembly was blocked if you right click on the file in Windows Explorer and select Properties. At the bottom of the Properties tab there should be an "Unblock" botton if the assembly was blocked and the message "This file came from another computer and might be blocked to help protect this computer" should be displayed near that button. To unblock the assembly and allow its execution simply click the "Unblock" button and restart the IIS application pool of your application to make sure the change was applied.

Another solution in this situation is to change the identity of the IIS pool of your application to a less restrictive account. The Network Service account should normally allow the execution of the assembly.

A: This error indicates the WebBrowser control could not access the COM interface of the Internet Explorer. You can try to use the dcomcnfg utility to allow the user running the application to access the interface. In Start->Run type dcomcnfg and under Component Services -> Computers -> My Computer -> DCOM Config select Internet Explorer. Right click on it and from tabbed properties select Security. To customize the access permissions select Customize radio button and give access to the user running the application ( for ASP.NET this should be the IUSR_{MACHINE_NAME} if your application is using impersonation to execute )

A: This defect was fixed in version 3.6.2 of the converter. If the problem persists with the latest version please contact support by email and provide the HTML document and the test application for which this problem occured.

The workaround you can try is to set PdfConverter.BatchConversion=true and make sure the converter is called from a STAThread. If you are using the converter from a console application the Main function of the console application has to be assigned with the [STAThread] attribute. In the Windows Forms applications the main thread of the application is a STA thread. If you call the converter from a ASP.NET page then you can set the AspCompat="true" attribute on @Page directive of the .aspx page.
As an alternative you can create a new thread to run the conversion loop and call SetApartmentState(ApartmentState.STA) against the Thread object before starting the thread.

A: In general, yes. There are a few situations when a HTTPS URL cannot be converted to PDF. The most common situation is when using self-signed test SSL certificates or invalid SSL certificates. When you are using a test certificate or an invalid SSL certificate the IE browser will display a page containing an warning about an invalid certificate being used. Similar to the browser behavior, the converter will also fail to convert the web page when an invalid certificate is used to secure the web page.

Other situation when the converter can fail is when various security restrictions are set on your computer or in your network. For example we have found situations when the firewall set in a network was blocking the access to the Certificate Revocation List file (a file with .crl hosted on the certificate issuer website). The converter was failing to retrieve the revocation list for the certificate and therefore the whole conversion was failing.

We have found also situations when the network architecture was designed in such a way that only computers from the Internet were allowed to access secured web pages hosted inside the internal network while the accesses coming from clients inside the internal network were rejected. To eliminate such a possibility you can try to convert a secured web page from Internet like https://www.paypal.com.

There might other restrictions in your network, some of them based on the Windows user credentials. If you can access a HTTPS web page from the IE web browser on the server but the same URL is reported as inaccessible by the converter then you can try to convert that URL using our Windows Forms sample application (in the Bin folder of the installation). The IE web browser and the Windows Forms application should run under the same Windows user account and should present the same credentials in your network. If the conversion works from the Windows Forms application but it's not working from an ASP.NET application then probably there is a restriction somewhere based on the Windows user account and you should contact your network administrator to learn more about the architecture of your network. The ASP.NET applications run in general under a less privileged Windows account. You can try to use a more privileged user account like NetworkService or even an Administrator to run the IIS application pool of your website.

To avoid this kind of issues with HTTPS URL try to use HTTP instead HTTPS when this is possible. You can also consider to get the HTML string of the web page (as explained in the next section) and set the base URL parameter to be a HTTP address if accessing the images and the CSS style files by a normal HTTP address is possible. This way you can have a secured access to the text in the web page while the access to images and CSS files is not secured.

A: ExpertPdf works on Windows Azure only if it is used in a virtual machine or a cloud service. Due to some security restrictions, ExpertPdf does not work on Azure if the web site execution mode is used.

You can read more details about Windows Azure execution models here:
http://azure.microsoft.com/en-us/documentation/articles/fundamentals-application-models/

If you need to convert from html to pdf in a website hosted on Windows Azure, run your website using a virtual machine or cloud service execution model that offer more flexibility than the simple web site execution model.

Latest News

Dec 4th, 2023

ExpertPdf HtmlToPdf Converter v18.1.0 was released.

read more
Mar 30th, 2023

ExpertPdf Pdf To Image Converter v8.0.0 was released.

read more

Pdf Library for .NET

ExpertPDF Html To Pdf Converter

Html to Pdf asp.net

"HTML to PDF is a quality component that is clearly valuable to any Web developer in need of an easy and flexible way to generate PDF files."

Steve C. Orr - MCSD, Microsoft MVP in ASP.NET

more testimonials
customers list

With ExpertPdf you can convert html to pdf in .NET.

Professional aspx to pdf converter, ExpertPdf works with Microsoft Azure if used in a virtual machine or a cloud service.

Copyright 2024. Outside Software Inc.