Page 1 of 1

embeddedFonts not working in JS

Posted: Tue May 07, 2024 2:05 am
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.

Re: embeddedFonts not working in JS

Posted: Tue May 07, 2024 1:39 pm
by Lech Kulikowski
Hello,

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

Thank you.

Re: embeddedFonts not working in JS

Posted: Wed May 08, 2024 1:34 am
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.

Re: embeddedFonts not working in JS

Posted: Wed May 08, 2024 8:41 pm
by Lech Kulikowski
Hello,

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

Thank you.

Re: embeddedFonts not working in JS

Posted: Tue May 14, 2024 1:30 am
by robops
Hello,
I tried to use latest js,and all problems except question 1 have already disappeared.
Thank you.

Re: embeddedFonts not working in JS

Posted: Tue May 14, 2024 7:43 pm
by Lech Kulikowski
Hello,

> except question 1 have already disappeared

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

Thank you.

Re: embeddedFonts not working in JS

Posted: Wed May 15, 2024 12:09 am
by robops

Re: embeddedFonts not working in JS

Posted: Fri May 17, 2024 9:11 am
by Lech Kulikowski
Hello,

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

Thank you.