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

Free Support Forum - aspose.com

Unicode subfont embedding slow to save

Hello,

Recently it came to my attention that Unicode fonts were not being displayed properly in my PDF generation code, and I got that fixed by setting the TextInfo property IsUnicode=true

My problem now is that the generated PDF is taking much longer to save. From 5 seconds to 50 in a simple example. I know that this is probably because of the need for Aspose to embed these subfonts when using IsUnicode=true.

  1. Is this expected behavior, or is there a smarter way or anything I can do on my end to speed things up?
    1. Currently I am setting the TextInfo of the PDF itself to use Unicode, and then when creating items like Tables, I clone that TextInfo. pdf1.TextInfo.IsUnicode = true;

All help is appreciated.

Thanks!

Hi Iirna,


Thanks for your inquiry. Could you please share your sample code here? So we test the unicode display issue and time lag in saving at our end and provide you more information accordingly.

Sorry for the inconvenience faced.

Best Regards,

I have included a code sample below. Ultimately I'm trying to:

  • use Unicode
  • have separate bold/regular font styles
  • save quickly.

Currently I'm using Aspose.Pdf 3.6.2.5, and I added IsUnicode. This showed the Unicode characters, but the time for the Save() method to run was much MUCH longer. I haven't checked if bold/regular Unicode font styles work (originally I was just using Helvetica and Helvetica-Bold). This won't work for the update I'm making to an existing project. Is there another way I can approach the code in this version (3.6.2.5) to make this quicker (as this would be an ideal situation for me).

I will note that if I switch to Aspose.Pdf 7.8.0.0, then I can use Unicode and the "Arial Unicode MS" font. And the Save() time is quick here. But I haven't found a way to have bold and regular Unicode styles (even after search these support forums). It seems to keep them all the same style. I tired setting IsTrueTypeFontBold to true and false in different areas but the result looks the same.

So I'd really like it if you can give me some advice for how to approach v3.6.2.5 Save() times. But if that's not possible, then a way to handle unicode and bold/regular styles in v8.7.0.0 would be helpful.

Thanks!

Code Under 3.6.2.5

using AsposePdfClass = Aspose.Pdf;using AsposePdfClass = Aspose.Pdf;

AsposePdfClass.Pdf pdf1 = new AsposePdfClass.Pdf();
pdf1.TextInfo.IsUnicode = true;

AsposePdfClass.Section sec1 = pdf1.Sections.Add();
AsposePdfClass.Table table1 = new AsposePdfClass.Table();
sec1.Paragraphs.Add(table1);
table1.DefaultCellTextInfo = sec1.TextInfo;

AsposePdfClass.Row row1 = table1.Rows.Add();
row1.Cells.Add(“≥$100”);
row1.Cells.Add(“≥100”);
AsposePdfClass.Row row2 = table1.Rows.Add();
row2.Cells.Add(“≥0.314159265358979”);
row2.Cells.Add(“≥three”);

MemoryStream MS = new MemoryStream();
pdf1.Save(MS);

Code under 8.7.0.0

using AsposePdfClass = Aspose.Pdf.Generator;

AsposePdfClass.Pdf pdf1 = new AsposePdfClass.Pdf();
AsposePdfClass.Section sec1 = pdf1.Sections.Add();

AsposePdfClass.Table table1 = new AsposePdfClass.Table();
sec1.Paragraphs.Add(table1);

table1.DefaultCellTextInfo.IsUnicode = true;
table1.DefaultCellTextInfo.FontName = “Arial Unicode MS”;
table1.DefaultCellTextInfo.IsTrueTypeFontBold = false;

AsposePdfClass.Row row1 = table1.Rows.Add();
row1.Cells.Add(“≥$100”);
row1.Cells.Add(“≥100”);
AsposePdfClass.Row row2 = table1.Rows.Add();
row2.Cells.Add(“≥0.314159265358979”);
row2.Cells.Add(“≥three”);

AsposePdfClass.Table table2 = new AsposePdfClass.Table();
sec1.Paragraphs.Add(table2);

table2.DefaultCellTextInfo.IsUnicode = true;
table2.DefaultCellTextInfo.FontName = “Arial Unicode MS”;
table2.DefaultCellTextInfo.IsTrueTypeFontBold = true;

AsposePdfClass.Row row3 = table2.Rows.Add();
row3.Cells.Add(“≥$100”);
row3.Cells.Add(“≥100”);
AsposePdfClass.Row row4 = table2.Rows.Add();
row4.Cells.Add(“≥0.314159265358979”);
row4.Cells.Add(“≥three”);


MemoryStream MS = new MemoryStream();
pdf1.Save(MS);

I found a solution that'll work for me in 3.6.2.5 (may also work in 8.7.0.0 but I haven't checked).

I can fix the Save() speed issue with: pdf1.IsTruetypeFontMapCached = true;

For those who may be looking for a similar solution for the Unicode Bold/Regular styles, this is what would up working for me:

using AsposePdfClass = Aspose.Pdf;
...

AsposePdfClass.Pdf pdf1 = new AsposePdfClass.Pdf();
pdf1.IsTruetypeFontMapCached = true;

AsposePdfClass.Section sec1 = pdf1.Sections.Add();

AsposePdfClass.Table table1 = new AsposePdfClass.Table();
sec1.Paragraphs.Add(table1);

table1.DefaultCellTextInfo.FontName = "Helvetica";
table1.DefaultCellTextInfo.IsUnicode = true;
table1.DefaultCellTextInfo.IsTrueTypeFontBold = false;


AsposePdfClass.Row row1 = table1.Rows.Add();
row1.Cells.Add("≥$100");
row1.Cells.Add("≥100");
AsposePdfClass.Row row2 = table1.Rows.Add();
row2.Cells.Add("≥0.314159265358979");
row2.Cells.Add("≥three");

AsposePdfClass.Table table2 = new AsposePdfClass.Table();
sec1.Paragraphs.Add(table2);

table2.DefaultCellTextInfo.FontName = "Helvetica-Bold";
table2.DefaultCellTextInfo.IsUnicode = true;
table2.DefaultCellTextInfo.IsTrueTypeFontBold = true;

AsposePdfClass.Row row3 = table2.Rows.Add();
row3.Cells.Add("≥$100");
row3.Cells.Add("≥100");
AsposePdfClass.Row row4 = table2.Rows.Add();
row4.Cells.Add("≥0.314159265358979");
row4.Cells.Add("≥three");


MemoryStream MS = new MemoryStream();
pdf1.Save(MS);

Hi Iirna,


Thanks for your feedback. Its good to know that you have manged to get your desired results and definitely your shared solution will help other community members having similar requirements.

Please feel free to contact us for any further assistance.

Best Regards,