PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

PDF Generated with Wingings Font

Open bboynton97 opened this issue 6 years ago • 4 comments

When I generate a pdf and upload it to azure blob storage, the html string I'm passing in is somehow being turned into Wingdings when I generate the PDF.

var html = "<p>Normal HTML Content</p>";

// Create CarrierHQ pdf from HTML
var pdf = VetCV.HtmlRendererCore.PdfSharpCore.PdfGenerator.GeneratePdf(html, PageSize.A4);
            
//  ** Removing this doesn't help **
// Download and append Aon pdf to CarrierHQ pdf
var appendBlob = container.GetBlockBlobReference("append.pdf");
await using (var ms = new MemoryStream())
{ 
    await appendBlob.DownloadToStreamAsync(ms);
    var appendPdf = PdfReader.Open(ms, PdfDocumentOpenMode.Import);
    foreach (PdfPage page in appendPdf.Pages)
    { 
         pdf.AddPage(page);
    }
}

 // Upload final document to Azure
using (var ms = new MemoryStream())
{ 
      pdf.Save(ms);
      await chqBlob.UploadFromStreamAsync(ms);
}

The weirdest part is when I copy-paste the wingdings text into Word, it pastes in English.....

bboynton97 avatar Feb 06 '20 19:02 bboynton97

Interestingly, when I run the server and generate the pdf on Windows, it works fine. When I run it on Linux/Mac, it produces wingdings icons instead of text.

Our production hosting is on Linux, so this package won't work for us unless it supports Linux.

bboynton97 avatar Feb 06 '20 21:02 bboynton97

Strangely enough, it generates in greek for me on a mac, did you find a solution?

eliahuhorwitz avatar Feb 17 '20 16:02 eliahuhorwitz

That is hilarious. We ended up going with IronPDF. It's expensive, but we needed a solution quick.

bboynton97 avatar Feb 17 '20 17:02 bboynton97

I know this is an old thread but I encountered this on my Mac and after a bit of troubleshooting I was able to fix it. The issue is the location of fonts on my OS is actually /System/Library/Fonts/Supplemental not the location that the default font resolver expects /Library/Fonts. That is the location where all *.ttf fonts are saved. I am running MacOS 12.6 Monterey. So to resolve this issue I simply created a bunch of symbolic links in the /Library/Fonts location pointing to the actual location of the ttf fonts. That solved the issue for me. Perhaps default font resolver can become a bit more robust and if it does not find any ttf fonts in the default location try a couple of other options.

keshmir avatar Oct 27 '22 21:10 keshmir