Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > ASP.NET 4.5.1 General Discussion
|
ASP.NET 4.5.1 General Discussion For ASP.NET 4.5.1 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5.1 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2018, 04:57 AM
Registered User
 
Join Date: May 2018
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting HTML to PDF using OfficeComponent lib

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
converting pdf file to jpegs arnabghosh ASP.NET 3.5 Professionals 0 February 4th, 2010 08:11 AM
converting pdf file to jpegs with PHP arnabghosh PHP How-To 0 February 4th, 2010 07:54 AM
Converting PDF to HTML sunil.konduri C# 2005 1 July 11th, 2008 07:34 AM
Dot net - Converting word to pdf and pdf to word Manoah Classic ASP Basics 2 July 7th, 2008 10:21 PM
Converting TIF images to PDF Zeus_Man Crystal Reports 0 October 4th, 2006 10:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.