embeddedFonts not working in JS

Stimulsoft Reports.JS discussion
Post Reply
robops
Posts: 14
Joined: Thu Dec 07, 2023 8:02 am

embeddedFonts not working in JS

Post by robops »

Hello,
I meet a strange problems when exporting pdf.
I used chinese characters in my reports,so i select "黑体" font.If i preview in desinger and select "save Adobe Pdf File",then check the "Embedded Fonts" option,I got a normal format Pdf file about 60+KB and it can be viewed in all devices wheather the device installed the font "黑体".
However,when i export the report by the code in JS,even i set embeddedFonts = true,I always got an incomplete pdf about 10+KB,I guess the font not be embedded successfully into the pdf.In that case, many mobile devices such as iphone can't view the pdf correctly.
Here are some effects.
Image
Image
Image
And here's my code.

Code: Select all

report.renderAsync(function(){
let settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
let service = new Stimulsoft.Report.Export.StiPdfExportService();
settings.embeddedFonts = true
let extension = ".pdf";
let contentType = "application/pdf"
let stream = new Stimulsoft.System.IO.MemoryStream();
service.exportToAsync(function () {
            var data = stream.toArray();
            Stimulsoft.System.StiObject.saveAs(data, reportName + extension, contentType);
   }, report, stream, settings);      
})
Also,I will provide the JS file I used.
https://webcc-pro.obs.cn-east-3.myhuawe ... reports.js
https://webcc-pro.obs.cn-east-3.myhuawe ... .viewer.js

Wish for your reply.
Thank you.
Lech Kulikowski
Posts: 6358
Joined: Tue Mar 20, 2018 5:34 am

Re: embeddedFonts not working in JS

Post by Lech Kulikowski »

Hello,

Please try to add fonts in the font collection before rendering:
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile(font);

Thank you.
robops
Posts: 14
Joined: Thu Dec 07, 2023 8:02 am

Re: embeddedFonts not working in JS

Post by robops »

Hello,
thanks for your reply.
I tried and it really works,but,caused other problems at the same time.
1.when i use <letter-spacing> tag,the font-size becomes small as is shown below.
Image

2.In some templates,some characters are missing.
Image

3.Since I checked the global setting in Stimulsoft.StiOptions.Export.Pdf.reduceFontFileSize = true,the size reaches several MB even if there's only one page.
Image

4.Last but not least,In some cases,the web page will loss response when I called exportToAsync,it seems the thread is blocked.Here's the .mrt and datasource.
https://webcc-pro.obs.cn-east-3.myhuawe ... %26110.mrt
https://webcc-pro.obs.cn-east-3.myhuawe ... 8D%95.json

All the problems both appeared after i using Stimulsoft.Base.StiFontCollection.addOpentypeFontFile('font/NotoSansHans-Regular.otf',"黑体").I will also provide the font file no matter it is useful.
https://webcc-pro.obs.cn-east-3.myhuawe ... egular.otf

:) That's all I met right now.Hope for your reply.
Thank you.
Lech Kulikowski
Posts: 6358
Joined: Tue Mar 20, 2018 5:34 am

Re: embeddedFonts not working in JS

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
robops
Posts: 14
Joined: Thu Dec 07, 2023 8:02 am

Re: embeddedFonts not working in JS

Post by robops »

Hello,
I tried to use latest js,and all problems except question 1 have already disappeared.
Thank you.
Lech Kulikowski
Posts: 6358
Joined: Tue Mar 20, 2018 5:34 am

Re: embeddedFonts not working in JS

Post by Lech Kulikowski »

Hello,

> except question 1 have already disappeared

Please send us a sample report with test data for analysis.

Thank you.
robops
Posts: 14
Joined: Thu Dec 07, 2023 8:02 am

Re: embeddedFonts not working in JS

Post by robops »

Lech Kulikowski
Posts: 6358
Joined: Tue Mar 20, 2018 5:34 am

Re: embeddedFonts not working in JS

Post by Lech Kulikowski »

Hello,

We couldn't reproduce the issue.
Please send us a sample project that reproduces the issue for analysis.

Thank you.
Attachments
Screenshot 2024-05-17 110941.png
Screenshot 2024-05-17 110941.png (98.33 KiB) Viewed 13 times
Post Reply