Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > ASP.NET 4.5.1 General Discussion
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 16th, 2018, 04:57 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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;
}
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
converting pdf file to jpegs arnabghosh ASP.NET 3.5 Professionals 0 February 4th, 2010 07:11 AM
converting pdf file to jpegs with PHP arnabghosh PHP How-To 0 February 4th, 2010 06: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



All times are GMT -4. The time now is 08:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.