Winnovative Software - Questions and Answers
For technical and sales questions please check this web page before contacting us. The answer to your question might be here already.
Sales Questions
Q: What is the difference between a Deployment and a Redistributable license?
A: A deployment license can be used in a single application that can be deployed
on a single server.
A redistributable license can be used in an unlimited number of applications that
can be deployed on an unlimited number of servers and it can be used by an unlimited
number of developers inside your company. A redistributable license can be distributed
as part of your software with the condition to protect the license key in the compiled
code of your application or to store the license key in an encrypted format out
of the compiled code of your application. When you purchase a redistributable license
key you also get free full maintenance for the first year including priority technical
support and minor and major version updates for the software.
A full description of the license types can be found on the Buy Now
web page of our website.
Q:
What do you deliver after purchase?
A: After a purchase order is successfully processed by one of our payment providers
you'll receive by email a license key string for the product. In order to get the
license key you have to make sure that the emails are not blocked by
any spam filter you might have on your computer or in your network.
We don't do any physical delivery like DVDs or printed material.
Q: Do you work with resellers?
A: Yes, we work with resellers. As reseller, when you place the order, you can use your
information (credit card, company name, etc.) for billing and your customer information for delivery (name, email address, etc.).
If use your company information both for billing and delivery then you have the obligation to transfer
the license to your customer and to inform us about the identity of your client (company name, a contact
person and email) such that your customer can get technical support from us directly. You also have the obligation
to communicate to your customer the purchase order ID.
Q: Do you have any discounts for non-profit organizations?
A: We don't have special prices for a non-profit organizations.
Q: Are the licenses for your products perpetual?
A: Yes, all our license types are perpetual. A purchased license will work with
the version of the product for which it was purchased for an unlimited period of
time and you can use it under the licensing terms and
conditions without any additional fees.
Q: Under which circumstances I can distribute your component as part of my application
to my own clients?
A: First you need to purchase a redistributable license. Then you have to protect
the license key string that you received after purchase either by including it in
the compiled code of your application or by storing it in an encrypted format. You
also have to clearly specify in the terms and conditions of your application that
the usage of our component outside the functionality your application is illegal.
Finally you have to make sure (by contacting our support or sales team directly)
that your application does not compete with our products and the usage of our component
is fully compliant with the terms and conditions from our license agreement
Q: What refund policy do you have?
A: In general we don't accept refund requests for Winnovative Software products.
The reasons for this decision are:
- All of our evaluation versions are fully functional
- You can evaluate our products for an unlimited period of time
- The products are well documented and we offer fully functional samples with full
source code to get started with the product
- We offer free technical and sales support by email during the evaluation period
and after the product purchase
- We encourage you to completely test our products both in development and production
environments to see if they entirely meet your expectations before making the purchase
decision
If you think there are any special circumstances for requesting a refund, please
write us to support@winnovative-software.com
and provide us with the details about the situation. We'll try to analyze your request
as soon as possible.
Technical Questions - HTML to PDF Conversion
Q: I set the purchased license in my code but I still get a red demo message on the generated PDF documents.
A: The LicenseKey property of each PdfConverter and Document object must
be set with the purchased license key. If you are confident that all these objects have this property properly set
then make sure that you don't set a demo license key somewhere else in your code and the purchased license key
is the only one used in your code. Our demo applications are using a demo license key and you might have copied
code from our samples and left a demo license key in your code.
If nothing from suggestions above help then run your application in a debugger and check the value of the LicenseKey property
of each PdfConverter and Document object right before the PDF document is produced and make sure that the
purchased license key got set.
Q: When I convert an URL to PDF I get the "Load HTML error or navigation timeout"
exception.
A: In general this error occurs when the web page referenced by the URL to convert
is not accessible from the server where the converter is executed. The URL might
not be accessible because it is invalid, because of network or DNS problems or because
it requires authentication. In order to check that the URL you convert is accessible
from the server start a new instance of a web browser on that server and try to
open the web page from the URL you convert. Make sure the web page can be completely
loaded without any warnings, errors, prompts or popups. If the web page requires
HTTP authentication (like IIS Integrated Windows Authenication) you can set the
credentials in PdfConverter.AuthenticationOptions property.
Another situation when this error can occur is when the web page takes too long
to be loaded. In this case you can increase the PdfConverter.NavigationTimeout value.
See the section below regarding the 'Navigation timeout' exception for more details.
Q: When I convert a HTML string to PDF, the external CSS files and images are not
applied in the rendered PDF document.
A: When you convert a HTML string referencing external CSS files and images by relative
URLs, the converter cannot determine the full URLs.
In order to solve this you have to set the baseURL parameter of
the HTML string conversion method with the full URL of the page from where you have
retrieved the HTML string.
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 the images and CSS require HTTP authentication (like IIS Integrated
Windows Authentication) you have to set the AuthenticationOptions property
of the converter.
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 a 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
full URL to PDF using the GetPdfBytesFromUrl() method. If the image is not accessible
you should get an error.
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 problem is to manually send the forms authentication cookie
( .ASPXAUTH ) using the PdfConverter.HttpRequestCookies property:
PdfConverter pdfConverter = new PdfConverter();
// add the Forms Authentication cookie to request
if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
{
pdfConverter.HttpRequestCookies.Add(FormsAuthentication.FormsCookieName,
Request.Cookies[FormsAuthentication.FormsCookieName].Value);
}
pdfConverter.GetPdfBytesFromUrl(urlToConvert);
Another workaround for forms authentication is to store the images and CSS files
referenced by the web page to be converted in a location which doesn't require authentication
(you can configure this in the web.config of your application). 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 .
Q: Sometimes the asynchronous content like an AJAX update panel is not rendered
in PDF. Is there any option to wait for this content to be completeley loaded before
rendering the PDF?
A: The PdfConverter class (and the HtmlToPdfElement class) has a ConversionDelay
property which can be used to specify an additional period of time in seconds to
wait for asynchronous content to be loaded before starting PDF rendering.
Q:
The images and texts appear to be smaller than they are in the HTML document and
for other HTML documents the content is rendered in the left side of the document
and is not centered.
A: The converter internally uses a HTML viewer to render the HTML page very similar
to what the web browser does on the screen. The HTML viewer resolution is 96 DPI.
The web page elements dimensions are usually measured in pixels and this is the
reason why the HTML viewer width and height are 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). The UnitsConverter
class can be used to convert dimensions from pixels to points and from points to
pixels.
You can specify the HTML viewer width and height in pixels using the PdfConverter.HtmlViewerWidth
and PdfConverter.HtmlViewerHeight properties or you can specify the same values
as parameters when you construct the PdfConverter object.
By default the HtmlViewerWidth 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. The HtmlViewerHeight
property is 0 by default which means the HTML viewer height will be automatically
set to display the whole HTML page height.
After the HTML content is displayed in the HTML viewer the content will be transferred
into PDF as you would take a picture of HTML viewer display and put that picture
into a PDF document. The PDF documents pages have a fixed size in points. For example,
the A4 portrait page is 595 points in width and 842 points in height. If the HTML
viewer width is more than 595 points then the rendered HTML content will be shrunk
to fit the PDF page width and display the whole HTML content in the PDF document.
If the HTML viewer 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 pixels is 793x1122 pixels. This means that
at a default HTML viewer width of 1024 pixels the HTML content will be scaled down
to fit the PDF page. This is the reason why you see smaller fonts and images in
PDF.
The calculation above does not take into account the possible margins set for the
PDF page. If you have set the PDF page margins then the exact calculation of the
available width in PDF page can be made using UnitsConverter API.
The FitWidth property was added to the PdfConverter.PdfDocumentOptions to control
if the rendered HTML content can be scaled to fit the PDF page width. 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.
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. It is also
possible to set a custom size for the PDF page when the PdfConvert.PdfDocumentOptions.PdfPageSize=PdfPageSize.Custom
In this case the custom size of the PDF page will be taken from PdfConverter.PdfDocumentOptions.CustomPdfPageSize
property. The PdfConverter.PdfDocumentOptions.AutoSizePdfPage was added to automatically
determine a custom PDF page width when the FitWidth property is false. The AutoSizePdfPage
can create PDF documents with non-standard PDF page 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 HTML viewer width. If your page can be correctly
and entirely displayed in 793 pixels (which is the width of the A4 portrait page
in pixels without margins at default 96 dpi resolution) you can set this value for
PdfConverter.HTmlViewerWidth 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
size is fixed and it is less than 1024 pixels in width. In this case there will
normally be an empty space in the right side of the web page displayed at 1024 pixels.
When the HTml viewer content is transfered to PDF the content will appear as not
centered in PDF. You can also solve this if you set the PdfConverter.HtmlViewerWidth
to a value of 793 pixels or less.
Q: For some HTML documents, the HTML content appears as truncated at the right side
of the PDF page. How can I make the whole HTML content to fit the PDF page width?
A: If the PdfConverter.PdfDocumentOptions.FitWidth property value is true as it
is by default (or HtmlToPdfElement.FitWidth when using a HTML to PDF element), then
it means that the HTML document cannot be completely displayed in 1024 pixels which
is the default value for the width of the internal browser display. To solve this
issue you have to increase the PdfConverter.HTmlViewerWidth property (or HtmlToPdfElement.HtmlViewerWidth
when using a HTML to PDF element) to a value in pixels enough to allow the full
display of the HTML document.
If you set the PdfConverter.PdfDocumentOptions.FitWidth property on false in your
code (or HtmlToPdfElement.FitWidth property when using a HTML to PDF element) then
most probably the rendered HTML content width is larger than PDF page width and
since the converter was not set to fit the width of the PDF page the content will
be truncated at the right side.
There are at least two possibilities to solve this problem function of if you want
to use only standard PDF page sizes (like A4, A3, etc) or you can use custom PDF
page sizes as well.
1. If want to use only standard PDF page sizes you can try first to set a landscape
orientation for the PDF pages. You can do this by setting the PdfConverter.PdfDocumentOptions.PdfPageOrientation
= PDFPageOrientation.Landscape (or when using the HtmlToPdfElement specify a landscape
orientation when you add the page that will hold the HtmlToPdfElement to the document).
You can also choose a wider standard page like A3 instead of A4 and keep the portrait
orientation.
2. If you can work with custom sized PDF pages than you can simply set the PdfConverter.PdfDocumentOptions.AutoSizePdfPage=true
and the converter will automatically select a custom PDF page width such that all
the HTML document can be displayed or you can set PdfConverter.PdfDocumentOptions.SinglePage
= true to automatically determine both the width and height of the PDF page and
produce a single PDF page containing all the rendered HTML document.
Please note that the AutoSizePdfPage and SinglePage properties are available only
in PdfConverter and they are not available for a HTML to PDF element.
Another possibility, which works both for the PdfConverter and for the HtmlToPdfElement,
is to specify a custom PDF page size wide enough to display the whole HTML content.
For the PdfConverter you have to set the PdfConvert.PdfDocumentOptions.PdfPageSize=PdfPageSize.Custom
and the PdfConvert.PdfDocumentOptions.CustomPdfPageSize to the desired size in points
of the PDF page.
For the HtmlToPdfElement you can specify the size of the PDF page when you add the
page holding the HtmlToPdfElement to the PDF document.
In general, when creating PDF pages with custom size, you have to correlate the
PDF page size with the HTML viewer width (which is 1024 pixels by default). For
example, if you want to render the HTML document in 1200 pixels when the FitWidth
is false, then the custom PDF page width in points can be determined using a call
to UnitsConverter.PixelsToPoints(1200).
Q: For some HTML documents there is an additional margin at the top and left sides
of the HTML document. How can I remove those additional margins?
A: The margins come from the HTML document. To remove those margins, in the HTML
document you convert set the BODY element margins to 0 pixels like in the example
below:
<body style="margin: 0px">
Q: When I convert a web page I get an "Out of Memory" exception.
A: The "Out of memory" exception can occur when converting a very large HTML document
with many images and complex formatting or when many conversions run at the same time
in the same process. The error can occur more often in a 32-bit process where the address
space available for application is limited to about 2 GB and therefore it is highly recommended
to run the converter in a 64-bit process in a 64-bit Windows.
Please be aware that in ASP.NET, even if your server is a 64-bit Windows, the IIS applications pool
hosting your application can run in 32-bit mode if the 'Enable 32-Bit Applications' is True in
application pool advanced settings. To make sure the converter runs in a 64-bit process you have to
put this flag on False.
Q: When I convert a web page I get the "Navigation timeout" exception.
A: The "Navigation timeout" exception normally occurs when converting very large
or slowly accessible web pages and when loading of the web page to convert takes
more than 45 seconds. In this case you can simply set a bigger value for the PdfConverter.NavigationTimeout
property.
When you load the web page to convert in a web browser on the server it might appear
that the page is loaded properly but it can happen that an external resource like
an image or a CSS file referenced by the web page is not accessible. In this case
the IE web browser for example displays a "Waiting for..." message in the
bottom status bar. The web browser can start rendering of the web page before all
the resources are available but the converter will wait until all the resources
are available before starting conversion. Therefore you first have to make sure
that a web browser on the server displays a "Done" message in the bottom
status bar when you load the web page to convert.
Q: When I try to convert a web page I get the "Could not start conversion. WinApi
error code 5" exception.
A: This error can occur when the wnvinternal.dat file does not have execute permission
for the user running the converter. To correct this you can change the wnvinternal.dat
file security permissions in Windows Explorer and grant execute permission to Everyone
or only to the user running the converter.
Q: Can
the converter be used in Windows Azure?
A: Yes, the converter can be used in Windows Azure Cloud Services and in Azure Virtual Machines.
It cannot be used in Azure Web Sites because this type of applications impose some restrictions
which make the converter to fail.
If you already have an ASP.NET or MVC Visual Studio project for .NET 4.0 or later you can add
a Cloud Service project and transform your ASP.NET application into a Web Role for this cloud
service. Just right click on the ASP.NET project and select 'Add Windows Azure Cloud Service Project'
option from the contextual menu.
Now you can create a package you can deploy as a Windows Azure Cloud Service. Right click on the
Cloud Service Project that has been added to your Visual Studio Solution and select 'Package'
option from the contextual menu and click the 'Package' button from the opened dialog using 'Cloud' option
for service configuration and 'Release' for build configuration. The location where the package and the
package configuration file were created is automatically opened in Window Explorer.
To deploy the cloud service login into Windows Azure Management Portal and create a cloud service.
Choose 'Custom Create' instead of the default 'Quick Create' and in the opened dialog enter an URL
for the cloud service that will be used later to run your application and check on the
'Deploy a cloud service package' checkbox, validate and go to the next dialog. Enter a deployment name
and select the package and package configuration files that have been previously
created by Visual Studio. Select 'Production' as deployment environment and check on the
'Deploy even if one or more roles contain a single instance' and 'Start deployment' checkboxes and
validate the dialog. The cloud service creation and deployment should be in progress now.
It takes a few minutes until the cloud service instance is started. You can monitor the instance status
in cloud service Instances tab and wait until the instance status becomes 'Running'. At that moment your
cloud service is ready to run.
Q: Can
the converter be used with on 64-bit Windows servers?
A: Yes, the converter works both in 32-bit and 64-bit environments. In general it
is recommended to run the converter in 64-bit process because it offers more internal
memory.
Q: Which versions of the .NET Framework does the converter support?
A: The converter can be used in applications targeting .NET Framework 2.0 or a later
version (.NET 3.0, 3.5, 4.0, 4.5).
There are two distinct sets of of libraries and samples in the same installation
folder: for .NET CLR 2.0 (which is the runtime for .NET 2.0, .NET 3.0 and .NET 3.5)
and for .NET CLR 4.0 (which is the runtime for .NET 4.0 and .NET 4.5). The samples for Visual
Studio 2005 and 2008 are targeting .NET CLR 2.0 and the samples for Visual Studio
2010 are targeting .NET CLR 4.0.
Grace to In-Process Side by Side (inproc SxS) feature of the .NET 4.0 CLR, the library
built for .NET 2.0 CLR can be used without change in applications targeting the
.NET 4.0 framework, but in this case there will be an overhead because .NET 2.0
CLR and .NET 4.0 CLR will run side by side in the same process. So it is recommended
to always use the library built for .NET CLR 4.0 in applications targeting the .NET
4.0 framework.
Q: Can
the converter convert HTTPS (SSL secured) URLs ?
A: Yes, the converter supports SSL secured web pages.
Q: How can I obtain the HTML string from a web page and convert it to PDF?
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();
The converter library offers a set of methods for converting a HTML string to PDF.
See the PdfInvoicesDemo sample for ASP.NET for a complete example
of how to retrieve the HTML code and convert it to PDF.
Q: Is the ASP.NET session data available in the converted ASP.NET page during conversion?
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 PdfInvoicesDemo sample for ASP.NET for a complete example
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 sample is also installed
in the 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 string using the Server.Execute(Url)
method as we do in the PdfInvoicesDemo 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 automatically turn all the relative URLs into absolute
URL you have to pass the baseURL parameter of the conversion method
with the full URL of the page from where you have taken the HTML string.
Q:
Does the converter use during conversion the session cookies stored in the current
web browser session when the converter is called from an ASP.NET application?
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.
It is possible to send cookies when a page is requested from the web server using
the HttpRequestCookies property which is the recommended method. A cookie can also
be sent to the web server using such a custom HTTP header defined in the HttpRequestHeaders
property like below:
pdfConverter.HttpRequestHeaders.Add("Cookie", "cookieName1=cookieValue1; cookieName2=cookieValue2");
Q: Does the HTML to PDF converter support authentication when used in ASP.NET application?
A: The converter offers support for HTTP 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 a username and password. The server authentication is usually necessary
when accessing Intranet resources.
Please do not confound the server authentication with the ASP.NET forms authentication
or a custom authentication method 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 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 problem
is to manually send the forms authentication cookie ( .ASPXAUTH ) using the PdfConverter.HttpRequestCookies
property:
PdfConverter pdfConverter = new PdfConverter();
// add the Forms Authentication cookie to request
if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
{
pdfConverter.HttpRequestCookies.Add(FormsAuthentication.FormsCookieName,
Request.Cookies[FormsAuthentication.FormsCookieName].Value);
}
pdfConverter.GetPdfBytesFromUrl(urlToConvert);
Another workaround for forms authentication is 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 .
An option to consider when trying to resolve the authentication issues (including
authentication implemented at application level) is to get the HTML code of the
web page using the Server.Execute(Url) method from ASP.NET and
then convert that string to PDF as we do in the PdfInvoicesDemo sample for ASP.NET.
The Server.Execute() method is executed in your application session so all the session
data and existing authentication should be valid. However, the CSS files and images
referenced by the HTML code to be converted should be placed in a location which
doesn't require authentication.
See the PdfInvoicesDemo application for ASP.NET for a complete
sample of how to retrieve the HTML code 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 conversion method with the full
URL of the page from where you have taken the HTML string.
If the images and CSS files referenced in the HTML string obtained as above require
HTTP or forms authentication then you have to resolve these authentication types
otherwise the images and CSS styles will not be applied in the generated PDF.
Q: How can I control the page breaks in the resulted PDF document?
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. These styles can be used either in a CSS class to be
applied to an element or inline in the element style attribute. It is not recommended
to use the page-break-after:always style on an empty element (like an empty DIV
tag). Instead you can use the page-break-before:always on an empty element to produce
the same effect.
The page-break-inside:avoid style can be applied to a element to
prevent breaking the content of the element between PDF pages.
Q: How can I specify to the converter to not break (keep together on the same page)
a HTML region between PDF pages?
A: You can apply the page-break-inside:avoid CSS style to the HTML
element you want to appear in the rendered PDF document on the same page. Of course
the element height must be less than the page height, otherwise the style will be
ignored by the converter.
<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 for the table row.
Q: Some images are cut off between PDF pages? Is there any option to avoid this?
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 achieve the same result.
Q: How can I automatically repeat the header and footer of a long HTML table on each PDF page
where the table is rendered?
A: The HTML table header and footer are automatically repeated on each PDF page when the thead
tag of the HTML table has the display:table-header-group style and the
tfoot tag of the HTML table has the display:table-footer-group style.
These are the default styles in HTML and the header and footer are automatically repeated in PDF.
To disable the header and footer repeating you have to explicitly set the display:table-row-group
style for thead and tfoot tags.
We provide the Repeat Table Head sample in the demo application of the converter to
demonstrate this feature.
Q: Can the converter render a HTML string or an URL in the header and footer of
the generated PDF document?
Q: Is it possible to have different content in the header (or footer) of different
PDF pages?
Q: How can I add many HTML documents into the same PDF document?
A: Please check the 'Convert Multiple URLs into Same PDF' sample from the demo application.
Q: Can I disable the HTTP links from the generated PDF document?
A: The PdfConverter.PdfDocumentOptions.LiveUrlsEnabled controls the rendering of
http links in the resulted PDF document. By default this property is true.
Q: What type of fonts does the converter support and how can I embed the fonts in
the generated PDF document?
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.
Q: I installed a true type font on the server but the converter is still using a
default font instead of the installed font.
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.
Q: The Unicode characters are not displayed or they are incorrectly displayed for
some fonts.
Each true type font has a table of supported unicode characters. If you are trying
to use a font for a Unicode text for which the font does not have associated glyphs
the displayed text in PDF will be incorrect. You always have to make sure that the
font used for a Unicode text supports the language of that text.
If you have a Windows XP or a Windows Server 2003 computer it is also recommended
to enable the support for supplemental languages by checking on the checkboxes 'Install
files for complex script and right-to-left languages' and 'Install files for East
Asian languages' in the 'Languages' tab accessible from Windows Control Panel under
'Regional and Language Options' section.
For Windows Vista, Windows Server 2008 and later Windows versions the support for
these languages is enabled by default and no special setup is necessary.
Q: Does the converter support right-to-left and complex script languages (Arabic,
Hebrew, Indic, Thai, etc) and East Asian languages (Chinese, Japanese, Korean)?
Yes, the converter supports all these types of languages. If you have a Windows
XP or a Windows Server 2003 computer you have to explicitly enable the support for
supplemental languages by checking on the checkboxes 'Install files for complex
script and right-to-left languages' and 'Install files for East Asian languages'
in the 'Languages' tab accessible from Windows Control Panel under 'Regional and
Language Options' section.
For Windows Vista, Windows Server 2008 and later Windows versions the support for
these languages is enabled by default and no special setup is necessary.
Q: How can I control the images quality in PDF?
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.
Q: Can I open the generated PDF document directly into a browser window instead
of displaying the Open/Save dialog in browser?
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();
Q: How can I execute a JavaScript code (Acrobat JavaScript) when the PDF document
is opened in the viewer?
A: You can use the Document.OpenAction.Action property to set a PdfActionJavaScript
object representing the JavaScript code you want to execute when the PDF document
is opened in the viewer. For example you can use the code below to display an alert
message when the document is opened:
document.OpenAction.Action = new PdfActionJavaScript("app.alert('Hello');");
The document object is either the Document instance created by your application
or a Document object produced by the HTML to PDF library when using a method like
PdfConverter.GetPdfDocumentObjectFromUrl().
Q: How can I make the PDF viewer to automatically go to a specified page when the
PDF document is opened in the viewer?
A: You can use the Document.OpenAction.Action property to set a PdfActionGoTo object
representing the destination displayed when the PDF document is opened in the viewer.
For example you can use the code below to automatically go to the second page in
document when the document is opened in the PDF Viewer:
document.OpenAction.Action = new PdfActionGoTo(new ExplicitDestination(document.Pages[1],
new PointF(0,0)));
The document object is either the Document instance created by your application
or a Document object produced by the HTML to PDF library when using a method like
PdfConverter.GetPdfDocumentObjectFromUrl().
Q: How can I append external PDF documents to the PDF document resulted after conversion?
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 or using the Document.AppendDocument() method.
We have examples for both techniques in the demo application.
Q: How can I specify a custom PDF page size for the generated PDF document?
A: 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.
Q: How can I use the HTML to PDF converter library from .NET 1.1 applications or
from PHP applications?
A: The HTML to PDF converter library is a .NET 2.0 or 4.0 library and it is not
working with .NET 1.1 directly. The workaround for this is to create a .NET web
service and call that service from your application.
Q: How do I perform a conversion to Landscape page orientation?
A: Use the following property:
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Landscape;
Q:
When I converted a web page containing a frameset tag only the top part of the page
was rendered in PDF.
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.HtmlViewerHeight = 2000;
Q: Can I deploy my ASP.NET application using the HTML to PDF Converter on a shared
server?
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.
If you don't want to manage your own server then you can try to use the Windows
Azure Cloud service. The converter should work well in this environment.
Q:
The exception "System.Security.SecurityException: Request failed" or the exception
"System.Security.SecurityException: Request for the permission of type ... failed"
is thrown by converter.
A: The converter needs a full trust level for your ASP.NET 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.
A special situation when this exception can occur is when the operating system marks
the assembly as "Blocked" because it was downloaded from Internet. 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"
bottom 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.
Q:
After I have installed IE9 some of the transparent PNG images are rendered blurred
in PDF and some of the table borders are rendered as black in PDF even if they have
a different color in the HTML document.
A: This problem was occuring in old versions of the converter because of the IE9 or later rendering engine.
Starting with version 9.0 of the converter IE is not used anymore as rendering engine and therefore the problem should not occur anymore.