Problem converting HTML to PDF

I was given a sample HTML document to convert to PDF. The conversion is simple, as follows.

var pdf = new Pdf();

pdf.BindHTML(filePath);

pdf.Save(convertedFilePath);

I understand that the PDF converter cannot recognise all style attributes, but much of the information is missing in the PDF document...



Document Title




Hei!

Som avtalt oversendes tilstandsrapport for FORD MONDEO TREND med avtalenummer 012345.

Har du spørsmål er det bare å ta kontakt med oss på telefon 9999000, eller svare på denne mailen.



Med vennlig hilsen

Test AS



Sender



Test as

1111 Oslo

Telefon: 9999000

Telefax: 9999001

www.test.nowww.test.no">www.test.no<br>
Se biler på nett: www.test.nowww.test.no">www.test.no<br>



























Ordrenr: 012345 - 2001
FORD MONDEO TREND
2,0 TD STV 115 HK























Bedømmelse:
1 = Normal


2 = Under oppsyn


3 = Defekt/Må repareres





















































































Komponent



Kommentar
Bremser foran 2 UJEVN PULSERER
Bremser bak 1
Parkbrems 1
Styring 1
Hjuloppheng 1
Støtdempere 1
Fjærer 1
Lys 1
Horn 1
Viskermotor 1
Motor 1












































































Komponent



Kommentar
Gearkasse 1
Drivverk 1
Kjølesystem 1
Ventilasjonsanlegg 1
Dynamo/lading 1
Instrumenter 1
Clutch 1
Dørlåser 1
Vindusmekanisme 1
Starter 1
HC/CO test

































Bilen er kjørt i bremsetester: ja
Rust i bærende konstruksjoner: nei
Tidligere:
Kommentar:
EL SETE.3.
RADIOFRONT ER HER.
SLITEKANT+RUSTENE BREMSESKIVER.









Hi,

Some of the data is missing because the pdf page is not wide enough and the data gets truncated. Please decrease the width of data or increase the page width of pdf.

Thanks.

The default size for the PDF is A4. Internet Explorer manages to render the HTML perfectly well in an A4 page. I am not able to increase the page width beyond A4 because our client expects to be able to print the PDF on A4 paper.

As a further investigation, I simplified the HTML (below) by removing all absolute width values. But the rendering engine produces output that is completely unlike that shown in any browser.

When we go live, I am expected to be able to print on A4 paper a PDF constructed from any reasonably formatted HTML. Internet Explorer can print this but your component does not so it looks like I will have to research another solution.

You have a very difficult job on your hands if you claim to be able to reliably convert HTML to PDF. Perhaps you should consider intercepting the print output of Internet Explorer and converting that to a PDF instead.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/1999/xhtml">


Untitled Document


Hei!

Som avtalt oversendes tilstandsrapport for FORD MONDEO TREND med avtalenummer 012345.

Har du spørsmål er det bare å ta kontakt med oss på telefon 9999000, eller svare på denne mailen.



Med vennlig hilsen

Test AS



Sender



Test as

1111 Oslo

Telefon: 9999000

Telefax: 9999001

www.test.nowww.test.no">www.test.no<br>
Se biler på nett: www.test.nowww.test.no">www.test.no<br>



























Ordrenr: 012345 - 2001
FORD MONDEO TREND
2,0 TD STV 115 HK























Bedømmelse:
1 = Normal


2 = Under oppsyn


3 = Defekt/Må repareres





















































































Komponent



Kommentar
Bremser foran 2 UJEVN PULSERER
Bremser bak 1
Parkbrems 1
Styring 1
Hjuloppheng 1
Støtdempere 1
Fjærer 1
Lys 1
Horn 1
Viskermotor 1
Motor 1












































































Komponent



Kommentar
Gearkasse 1
Drivverk 1
Kjølesystem 1
Ventilasjonsanlegg 1
Dynamo/lading 1
Instrumenter 1
Clutch 1
Dørlåser 1
Vindusmekanisme 1
Starter 1
HC/CO test

































Bilen er kjørt i bremsetester: ja
Rust i bærende konstruksjoner: nei
Tidligere:
Kommentar:
EL SETE.3.
RADIOFRONT ER HER.
SLITEKANT+RUSTENE BREMSESKIVER.









Hi,

The HTML to PDF functionality is not very mature and we are constantly trying to improve it. I have logged this issue as PDFNET-4764 in our issue tracking system. We will try our best to resolve this as soon as possible.

Thanks.

Hi,

Thank you very much for considering Aspose.Pdf. We have find the root cause of the problem. In Aspose.Pdf, the page width of A4 is 595 and the left margin and right margin are both 90 by default. So when the width of content in Pdf is greater than 505(595-90), the content will be cut. While the width of outtest table in your html file is at least 783(183+300+300) which is much greater than 505. So the output pdf file converted by Aspose.Pdf will be different from the original html file. But if you use test code as below, the output will be much more satisfactory.

var pdf = new Pdf();

pdf.HtmlInfo.PageWidth=1000;

pdf.BindHTML(filePath);

pdf.Save(convertedFilePath);