Table width is changed | HTML to PDF conversion using .NET

I’m currently encountering an issue that I require a bit of help with.
I’ve an html document which has two tables in it. The left hand table contains the main text of the document and takes up approximately 66% width. The right hand table contains a bit of blurb and takes up the remaining 33% width.
When I convert the html document to a pdf the current table widths are being lost and both tables take up 50% width each.
I’ve tried converting from html to word doc and then to pdf but the same issue still occurs. Is there any way to code or configure Aspose so that it will retain the orginal table widths?
Thanks in advance for any comments and advice.

Hi Mark,

Thanks for using our products.’

I have tried creating a sample HTML document but I am afraid I could not produce the HTML file which can help me in replicating this issue. Can you please share the file which you are using so that we can test the scenario at our end. We are sorry for this inconvenience.

Hi Nayyer
Thanks for the response. I’m leaving the office for the evening but I’ll create a file tomorrow morning and send it to you.

Hi Nayyer
I’ve attached a zip file containing the html file I’m trying to convert and the pdf produced. Below is the code I’m using.

public static void CreateDoc1()
{
    Document doc = new Document(@"C:\TestTextFiles\HTMLtoPDF\test2.html");
    var builder = new DocumentBuilder(doc);

    builder.PageSetup.LeftMargin = 5;
    builder.PageSetup.RightMargin = 5;
    builder.PageSetup.BottomMargin = 5;
    builder.PageSetup.TopMargin = 5;
    builder.PageSetup.PaperSize = PaperSize.A4;

    builder.Font.Size = 8;

    builder.PageSetup.PageWidth = 875;
    builder.PageSetup.PageHeight = 1200;

    doc.UpdatePageLayout();
    doc.Save(@"C:\TestTextFiles\HTMLtoPDF\test2.pdf");
}

Hi Mark,

Thanks for sharing the details and resource files.

As per my observations, you are using Aspose.Words for .NET to read the contents of HTML file and save them in output format, so I am going to move this thread to respective forum where my fellow workers taking care of this product would be in better position to answer this query. Soon you will be updated with the status of correction.

Besides this, please note that Aspose.Pdf for .NET also supports the capability to convert HTML files into PDF format. But I am afraid during my testing, I have observed that the output PDF file generated with Aspose.Pdf for .NET has some formatting issues i.e. Tables are re-sized, formatting is lost and also contents are overlapping. For
the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-34204. We
will investigate this issue in details and will keep you updated on the status
of a correction.

We
apologize for your inconvenience.

Hi Mark,

Thanks for your interest in Aspose.Words.

I have tested the scenario and have managed to reproduce the same issue at my side. I have logged this issue as WORDSNET-6857 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Mark,

As per your email request about the ETA of this issue (WORDSNET-6857), I am afraid this issue has now been postponed till a later date due to some other important issues and new features. We will inform you as soon as there are any further developments.

We apologize for your inconvenience.

Hi Tahir
Do you know when this later date will be and do you have a workaround for this issue?
Regards
Mark.

Hi Mark,

Thanks for your patience.

I am afraid due to some technical difficulties, the issue PDFNEWNET-34204 (HTML to PDF conversion using Aspose.Pdf for .NET) is not yet resolved. Nevertheless the team is still working on resolving these issues and as soon as we have made some progress towards its resolution, we would be more than happy to update you with the status of correction.

Your patience and comprehension is greatly appreciated in this regard.

Hi Mark,

I am afraid this issue WORDSNET-6857 has now been postponed till a later date due to some other important issues and new features. We will inform you as soon as there are any further developments.

We apologize for your inconvenience.

Hi Mark,

I was facing similar issue and I think I have work around for you.

I’ve attached sample html (input file), doc and pdf files.
Doc and pdf files are converted from html file and its working for me.

Thanks to you as I’ve used your method (documentbuilder code) and then had a look into object structure of document class.
Try using inline css in your html.

I’ve used following code…

	String inputfile = @"C:\test\Print\ttt.htm";
	String outputdoc = @"C:\test\Print\ttt.doc";
	String outputpdf = @"C:\test\Print\ttt.pdf";

	Word.Document doc = new Word.Document(inputfile);
	var builder = new DocumentBuilder(doc);
	builder.PageSetup.PaperSize = PaperSize.A4;
	builder.PageSetup.LeftMargin = 70;
	builder.PageSetup.RightMargin = 70;
	builder.PageSetup.BottomMargin = 5;
	builder.PageSetup.TopMargin = 5;
	doc.UpdatePageLayout();
	doc.Save(outputpdf);

I hope it will work for you.
Dharmesh

Hi Dharmesh
Thanks for taking the time to respond. Unfortunately I’m not able to view or download your attachment. On my screen there is a message saying it is “Present (inaccessible)”. Would you be able to change this so I can look at the attachment?
Thanks!
Mark.

Hi Mark

Please find herewith attached files. If you face same problem try to login again.

Dharmesh

Hi Dharmesh
I’m currently logged in to the forums but I’m still getting the same issue. Would it be possible for you to email the files to me at mark.baxter@equiniti-ics.com ?
Thanks,
Mark.

Hi Dharmesh
I’m currently logged in but still unable to see the attached files. Would it be possible for you to email the files to mark.baxter@equiniti-ics.com ?
Thanks
Mark.

I’ve sent files to you in email.

Hi,

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Thanks for the files Dharmesh.
I’ve checked through them and tried to apply some formatting to the tables in my document to see if it makes a difference but unfortunately it does not.
I’ve attached the file.

Hi Mark,

I have also tested the shared workaround by Dharmesh, it do not work. We will update you via this forum thread once this issue WORDSNET-6857 is resolved.

We appreciate your patience.

The issues you have found earlier (filed as PDFNEWNET-34204) have been fixed in Aspose.Pdf for .NET 9.7.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.