salve a tutti
sto usando iTextSharp 5.5.7.0
dovrei convertire un file HTML che contiene piu font in un file PDF
codice:<body> <table> <tr> <td style='text-align:right;font-family:Courier New'>MCV</td> <td>102,2</td> <td>fl</td> <td></td> </tr> <tr> <td style='text-align:right;font-family:Courier New'>MCH</td> <td>33,8</td> <td>pg</td> <td></td> </tr> <tr> <td>MCHC</td> <td>33,1</td> <td>g/dl</td> <td></td> </tr> <tr> <td>EOS2</td> <td>0</td> <td>10l</td> <td>0-0.78</td> </tr> </table> </body>
usando questo codice c# mi ritorna un PDF che ha solo un font per documento
codice:string fileHTML = @"F:\TemplateVL.htm"; string HTML = File.ReadAllText(fileHTML); FontFactory.RegisterDirectories(); StyleSheet css = new StyleSheet(); css.LoadTagStyle(HtmlTags.TABLE, HtmlTags.FACE, "Courier New"); byte[] bPDF = null; BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false); iTextSharp.text.Font blackFont = new iTextSharp.text.Font(bfTimes, 8); MemoryStream ms = new MemoryStream(); TextReader txtReader = new StringReader(HTML); Document doc = new Document(PageSize.A4, 25, 25, 25, 25); PdfWriter oPdfWriter = PdfWriter.GetInstance(doc, ms); HTMLWorker htmlWorker = new HTMLWorker(doc); htmlWorker.SetStyleSheet(css); doc.Open(); htmlWorker.StartDocument(); htmlWorker.Parse(txtReader); htmlWorker.EndDocument(); htmlWorker.Close(); doc.Close(); bPDF = ms.ToArray(); File.WriteAllBytes("F:\\file.pdf", bPDF);
cosa sbaglio?
come posso mantenere piu font?

Rispondi quotando