I'v been trying to get OfficeComponent HTML to PDF converter to work using their code snippet as below. The code looks very long. I downloaded the lib try to convert cnn.com site's homepage but the images below the first page are not shown.
What could be the issue that the tool does not convert images below the first page?
Code:
public override string Execute()
{
#if WEB
_tpl.SetParameters(this);
#endif
if (Width <= 0 || Height < 0)
{
ShowError("Invalid Width or Height");
return null;
}
if (ConversionDelay < 0)
{
ShowError("Invalid conversion delay");
return null;
}
// Set output path.
var outputPath = Path.Combine(OutputDir, this.GetType().Name + ".pdf");
if (File.Exists(outputPath))
File.Delete(outputPath);
// Create a new converter.
var c = new HtmlToPdfConverter()
{
ViewportWidth = Width,
ViewportHeight = Height,
PageSize = PageSize,
PageMargin = Margin,
Portrait = Portrait,
Delay = ConversionDelay,
Timeout = Timeout,
SinglePage = SinglePage
};
if (Progress != null)
c.Progress += Progress;
try
{
if (ConvertUrl)
{
if (string.IsNullOrWhiteSpace(Url))
{
ShowError("Please specify the URL to convert.");
return null;
}
// Convert URL
c.Convert(Url, outputPath);
}
else
{
if (string.IsNullOrWhiteSpace(HtmlString))
{
ShowError("Please specify the HTML string to convert.");
return null;
}
// Convert the specified HTML string.
c.ConvertString(HtmlString, HtmlStringBaseUrl, outputPath);
}
}
catch (Exception ex)
{
ShowError(ex.Message);
}
return outputPath;
}