We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Title: Aspose Pdf from HTML with OpenType font

We have an issue with the OpenType font.
There are two fonts:


and the following code:
FontRepository.Sources.Add(new FolderFontSource(“Folder with fonts”));
var d = new Document(“index.html”, new HtmlLoadOptions()));
d.Save(“created by Aspose.pdf”);

When NotoSans font is used, it’s applied to numbers only, that’s expected result.

When NotoSansJP font is used, it’s applied to hieroglyph improperly.

DocumentService - Microsoft Visual Studio (Administrator).png (12.2 KB)

created by Aspose.pdf (3.7 MB)

Despite the symbols which look improperly, the text itself is correct (I can copy it from pdf, paste to Notepad and see the expected text).
For the comparison if the document with the same font is created via Adobe Acrobat, everything looks good.

created by Adobe.pdf (18.5 KB)

So I conclude that font is embed incorrectly to pdf file when Aspose is used.

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="style.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
    1234567890 1234567890
    <br />
    取引に関連して弊社が負担する損害賠償の範囲は、現実に生じた通常かつ直接の損害に限り、
    <br />
    また、賠償額は取引の対価相当額を上限とさせていただきます。
</body>
</html>

style.css:

@font-face {
    font-family: 'Noto Sans Regular';
    font-style: normal;
    font-weight: normal;
    src: local('Noto Sans Regular'), local('NotoSansJP-Regular'),
    url('fonts/NotoSansJP/NotoSansJP-Regular.otf') format('embedded-opentype');
}
body {
    font-family: 'Noto Sans Regular', sans-serif;
    font-size: 11px;
    line-height: 17px;
}

@kvart714

Could you please share the environment details i.e. OS Name and Version, .NET Framework information, etc. with us. We will test the scenario in our environment and address it accordingly.

.NET Framework 4.7.2
Aspose 18.12.0 (also i tried the latest version but no license. the result was the same)

OS:
|Edition|Windows 10 Pro|
|—|---|
|Version|20H2|
|Installed on|‎1/‎11/‎2021|
|OS build|19042.804|
|Experience|Windows Feature Experience Pack 120.2212.551.0|

@kvart714

We tested the scenario in our environment while using Aspose.PDF for .NET 21.2. We did not notice any issue. Please note that we tested the scenario in an environment where all Microsoft Essential Fonts were installed. However, we have used below line of code to include mentioned fonts as well in the FontRepository Sources:

FontRepository.Sources.Add(new FolderFontSource(dataDir + "Noto_Sans\\")); 
FontRepository.Sources.Add(new FolderFontSource(dataDir + "Noto_Sans_JP\\")); 

Attached are the output PDFs generated at our end:

created by Aspose_Noto_Sans_JP.pdf (230.3 KB)
created by Aspose_Noto_Sans.pdf (230.3 KB)

Could you please share steps to reproduce the issue. Please share what other fonts are installed/present in the font folder which you are including as new source to the FontRepository? Are you clearing font sources before including a new source for fonts? We will again test the scenario in our environment and address it accordingly.

In your example, the font was not applied at all

image.png (43.9 KB)

If you generate pdf from my html and css files, then please check that you have font path specified correctly in css

@font-face {
    ...
    url('fonts/NotoSansJP/NotoSansJP-Regular.otf') format('embedded-opentype');
}

My fonts folder contains only NotoSans and NotoSansJP. I’ve tried both: when these fonts are installed on the system and when aren’t. As a result, the NotoSansJP font is applied (this is noticeable by the numbers), but the hieroglyphs are broken.
FontRepository.Sources.Add (new FolderFontSource ("..."))

@kvart714

We were able to notice the issue in our environment and have logged it as PDFNET-49436 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi guys, could you please provide any information when the fix is expected to be available? The issue causes a critical bug on our side.
Could you please also clarify if you fix a bug only in a new version (and we have to upgrade) of it will be applied for previous ones?

@kvart714

The ticket is currently under the phase of investigation and we will surely inform you as soon as it is resolved. Please note that issues in free support model are resolved on first come first serve basis and fix to the issues is always included in the new versions. We do not fix issues in the previous or older versions. We have recorded your concerns though and will surely let you know once we have additional updates in this regard. Please give us some time.

We apologize for the inconvenience.