Free Support Forum - aspose.com

Can aspose be used to convert a .html file into a .pdf document as part of a C# application

I’m creating a application in c#. As part of the program program I need aspose to convert an .html file to a .pdf that the application can then save to a folder. The html containes tables which need to be accurately converted.
Can aspose do this? What product would I need to purchase? Are there any code examples?
Thank You

@MKNOWLES,

Thanks for contacting support.

Can you please share source files along with sample project so that we may further investigate to help you out.

Hi - We’ve decided it would be better to do this from a classic asp page, rather than from a C# application. The user selects that he wants to create the Purchase Order PDF from our classic asp page intranet. The thougts are to either build the pdf or build it as a .html then convert that to the pdf. We already have the code to generate the html. Can aspose create a .pdf from classic asp code? Also could it render an existing .html file via a .asp

Thanks

@MKNOWLES,

I regret to inform that Aspose.PDF does not support classic ASP. A ticket with ID PDFNET-48344 has been created as in our issue tracking system as a new feature request. We will look into the possibility of implementation of the requested feature. This thread has been associated with this new feature request, so that you can be automatically notified as soon as this issue is resolved.

Hi - Our developer has found this link

https://docs.aspose.com/display/pdfnet/ASP+-+VBScript+via+COM+Interop

which he says does imply Aspose.PDF supports Classic ASP?

Thank You.

@MKNOWLES

You can not use Aspose.PDF API directly but with COM Wrapper, it can be used. For more details, please visit this thread.

Hi - I now have an .html page being producing a .pdf file.
Just have the image being centralised rather than being on the left.

This is the .html code

<page size="A4">
 <div class="clsPageWidthBlock">
	<div class="clsPageBody">
			<div class="clsDocHeader">
				<img class="imgLogo" src="logo_tm_rgb.png">
				<span>Purchase Order</span>
			</div>
			<div class="clsFormHeader">
				<div class="spnAddrBlock">

and the class

Html original .png (2.5 KB)

pdf file .png (32.4 KB)

and i’ve attached the class in a png class.png (3.3 KB)
file as I couldn’t paste it in.

Guess I need to know how Aspose.pdf handles headers and footers that might give me a .clue as to the correct .html coding.

@MKNOWLES

We have tested the scenario in our environment while preparing a sample HTML file having same CSS Class that you shared for image. We were unable to notice any issue in output PDF document as image was rendered on the top-left corner of the PDF page. For your kind reference, attached are input HTML and Output PDF:

inputHtml.zip (331 Bytes)
table.pdf (8.5 KB)

var loadoptions = new HtmlLoadOptions(dataDir);
loadoptions.PageInfo.Width = PageSize.A4.Height;
loadoptions.PageInfo.Height = PageSize.A4.Width;
loadoptions.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
Document doc = new Document(dataDir + "inputHtml.html", loadoptions);
doc.Save(dataDir + "Table.pdf");

Would you kindly share your complete HTML file with which we can replicate the issue in our environment? We will again test the scenario and address it accordingly.

Hi - I’ve uploaded our test .html file. as a .zip file, and gthe output we were getting.

MBMTEST_PORDER_PP123456.html.pdf (1.0 MB)
MBMTEST_PORDER_PP123456.zip (3.7 KB)