Unable to convert HTML to PDF - 'Unknown token Nan'

I am trying to convert an HTML file to pdf. It is generating the file. On opening the pDF file, it gives 'unknown Tokan Nan found'.

I am attaching teh HTML I have been using. I have used only allowable html tags as mentioned on your site. Could you please check.

I am using 'BindHTML' for generatinng the file.

HTML:


B/S MR
Kundesenter
Reisedokument - Travel Document
Flygning - Flight Reisende - Traveller
1303 15 Jun 2006 (08:55) 1303 15 Jun 2006 (08:55)
Avreise Departure 10:55 London Stansted (STN)
Ankomst Arrival 12:00 Oslo Gardermoen (OSL)
Booking oppdatert Booking updated 08 Jun 2006 (13:04)
Bagasje Baggage Max. 8 kg håndbagasje/cabin baggage
Max. 20 kg fribagasje/free baggage allowance
Ankomst Arrival 12:00 Oslo Gardermoen (OSL)
Booking oppdatert Booking updated 08 Jun 2006 (13:04)
Kvittering Receipt Faktureres arbeidsgiver / Debited employer
Belastet ved bestilling
Charged upon reservation
Beskrivelse / Produkt Description / Product Currency Net VAT Total
Pris flyreise inklusive skatter Air Fare Incl. Tax (NOK) 0.00 0.00 0.00
Takk for at du flyr / Thank you for flying

Dear Kundesenter,

Can you please provide the HTML and code with attachment? Which version of Aspose.Pdf are you using?

I am using 3.6.1 version of dll. I have already pasted the html in my original message. I am pasting it again below.WHen I paste my HTML code, your editor converts teh code into html preview form. Can't understand what do you mean by sending the code thru attachmnet.Can't see any option of attachment in forum.

Here is the HTML:

B/S MR
Kundesenter
Reisedokument - Travel Document
Flygning - Flight Reisende - Traveller
1303 15 Jun 2006 (08:55) 1303 15 Jun 2006 (08:55)
Avreise Departure 10:55 London Stansted (STN)
Ankomst Arrival 12:00 Oslo Gardermoen (OSL)
Booking oppdatert Booking updated 08 Jun 2006 (13:04)
Bagasje Baggage Max. 8 kg håndbagasje/cabin baggage
Max. 20 kg fribagasje/free baggage allowance
Ankomst Arrival 12:00 Oslo Gardermoen (OSL)
Booking oppdatert Booking updated 08 Jun 2006 (13:04)
Kvittering Receipt Faktureres arbeidsgiver / Debited employer
Belastet ved bestilling
Charged upon reservation
Beskrivelse / Produkt Description / Product Currency Net VAT Total
Pris flyreise inklusive skatter Air Fare Incl. Tax (NOK) 0.00 0.00 0.00
Takk for at du flyr / Thank you for flying

You have not post the HTML as attachment so we copy the HTML and paste it into a new file. We have not found the error when testing the file. If you can’t attach file, you can send the files to tommy.wang@aspose.com. Please also include the resulting pdf. Which language are you using in your system? Have you tried the latest hotfix of Aspose.Pdf?

I have sent the attachment thru mail. I have used latest 7.0 version of the dll. Still it is giving the same error.

Thanks for your response. I was trying that in windows application. Anyways could you please help me with following 3 queries:

1) Though original html has images, same has not been included in the pdf. Does that mean images will not be transferred to pdf.

2) We need to include a footer on each page of pdf, how can I do that ? Could you please send me a sample code for that. I searched on your site and appears that it is possible for text. But I need to do that in the same html file that you just used.

3) How can I add bookmarks.

Please note that I need to achieve this using BindHtml only as I will be passing html file to the method.

  1. In my test, if the image file (“d:\PDF\PASNGR.gif”) exist, the image is included in the pdf. If the image is not exist, it is ignored.

  2. Here is an example to add a footer:

pdf1.BindHTML(@“D:\test\test.html”);

//add a footer
HeaderFooter hf = new HeaderFooter();
hf.Paragraphs.Add(new Text("footer"));
pdf1.Sections[0].OddFooter = pdf1.Sections[0].EvenFooter = hf;

pdf1.Save(@"d:/test/test.pdf");
  1. The bookmark function in Aspose.Pdf is based on headings so it can’t be used when converting HTML to Pdf. You can add the bookmark using Aspose.Pdf.Kit. Please refer to Create Bookmarks.

I probably figured out why image was not appearing, it was becasue I used align attribute in . When are you planning to support attributes like: align, style and div. It is very cumbersome to place font in each and evry cell of table whereas we want whole tabel to have same font.

Another query: I need to put a horizontal line just above my footer on every page. Line class is there but it seems it works with Graphs only...

Here is an example:

pdf1.BindHTML(..);

//add a footer
HeaderFooter hf = new HeaderFooter();

//add a line
Graph graph1 = new Graph(450,5);
Line l1 = new Line(new float[]{0,3,450,3});
graph1.Shapes.Add(l1);
hf.Paragraphs.Add(graph1);

//you can also add a line using tab stop
Text t1 = new Text("#$TAB");
t1.TabStops = new TabStops();
TabStop stop1 = t1.TabStops.Add(450,TabLeaderType.Solid);
hf.Paragraphs.Add(t1);

//add a text
hf.Paragraphs.Add(new Text("footer"));
pdf1.Sections[0].OddFooter = pdf1.Sections[0].EvenFooter = hf;

pdf1.Save(..);

Our product has already supported the align attribute in when processing the HTML to PDF.

Thanks.