Visualizzazione dei risultati da 1 a 1 su 1
  1. #1
    Utente di HTML.it L'avatar di Kahm
    Registrato dal
    Dec 2004
    residenza
    Rome
    Messaggi
    3,580

    itextsharp HTML a PDF con p'u font

    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?
    Ultima modifica di Kahm; 31-10-2018 a 12:27
    NN vi diro mai chi sono in realta,
    tutti i miei 3D sono orfani, non insistete per farmi rispondere ai 3D aperti da me

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.