Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Jan 13, 2015 9:09 pm

I am creating a pdf from an html page like so
Code: Select all
Spire.Pdf.PdfDocument pp = new Spire.Pdf.PdfDocument();
        Spire.Pdf.PdfPageSettings pst = new Spire.Pdf.PdfPageSettings();
        PdfHtmlLayoutFormat format = new PdfHtmlLayoutFormat();

        format.FitToPage = Clip.Both;
        format.Layout = PdfLayoutType.OnePage;

        pst.Size = Spire.Pdf.PdfPageSize.Letter;
        pst.Orientation = Spire.Pdf.PdfPageOrientation.Portrait;
        pst.SetMargins(0);

        string testUrl = theDestUrl;

        Thread thread = new Thread(() =>
        {
            pp.LoadFromHTML(testUrl, true, true, false, pst, format);
        });

        thread.SetApartmentState(ApartmentState.STA);
       
            thread.Start();
            thread.Join();
       
        string path = pathToSaveFile;
        pp.SaveToFile(path, Spire.Pdf.FileFormat.PDF);


The html page has a link to a css file that specifies fonts like so
Code: Select all
@font-face {
       font-family: 'Some Font';
        src: url('fonts/fontFile.eot');
        src: url('fonts/fontFile.eot?#iefix') format('embedded-opentype'),
            url(fonts/fontFile.otf);
}


We then have an H2 set to use that font family like this

Code: Select all
font-family: 'Some Font', Arial, sans-serif;


When we open the page that is to be converted to a pdf in IE the correct font is displayed, however, in the resulting pdf Arial is displayed.

How can I get it to display the correct font on the pdf?

danm
 
Posts: 6
Joined: Mon Jan 05, 2015 3:01 pm

Wed Jan 14, 2015 1:28 am

Dear danm,

Thanks for your inquiry.

To help us reproduce this problem, please give us the sample url or html file, thank you.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.Doc