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

Free Support Forum - aspose.com

Aspose.Cells Save PDF Font disappears

Hi

I have a problem in a font change when save PDF.

Please see the attached file.(Meiryo => Gothic)

I tried the [1], [2], but I was no good

[1]

CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;

CultureInfo currentUICulture=Thread.CurrentThread.CurrentUICulture;

Thread.CurrentThread.CurrentCulture =new CultureInfo("en-US");

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

Workbook test = OpenWorkBook(@"C:\FontConvertTest.xlsx");

test.Save(@"C:\fontTest.pdf", SaveFormat.Pdf);

[2] Convert Font Name ( jp -> eu)

Workbook test = OpenWorkBook(@"C:\FontConvertTest.xlsx");
#region <>

Worksheet sheet = test.Worksheets[0];
//Get:InstalledFontCollectionObject
System.Drawing.Text.InstalledFontCollection ifc =
new System.Drawing.Text.InstalledFontCollection();
FontFamily[] ffs = ifc.Families;
// Get:US Culture ID
int cultureId = System.Globalization.CultureInfo.GetCultureInfo("en-us").LCID;
int jcultureId = System.Globalization.CultureInfo.GetCultureInfo("ja-JP").LCID;
int maxRow = sheet.Cells.MaxDataRow;
int maxColumn = sheet.Cells.MaxDataColumn;

for (int x = 0; x < maxRow; x++)
{
for (int y = 0; y < maxColumn; y++)
{
FontSetting[] fss = sheet.Cells[x, y].GetCharacters();
if (fss != null)
{
foreach (FontSetting fs in fss)
{
string name = fs.Font.Name;

foreach (FontFamily fm in ffs)
{
if (name == fm.GetName(jcultureId))
{
fs.Font.Name = fm.GetName(cultureId);
}
}


}
}

Style style = sheet.Cells[x, y].GetStyle();
if (style != null && style.Font != null)
{
string name = style.Font.Name;
foreach (FontFamily fm in ffs)
{
if (name == fm.GetName(jcultureId))
{
name = fm.GetName(cultureId);
}
}
style.Font.Name = name;
}

sheet.Cells[x, y].SetStyle(style);
}
}
#endregion

test.Save(@"C:\fontTest.pdf", SaveFormat.Pdf);

---------

Installed ASPOSE.CELL Version: 8.1.0.0

Test Solution: VS 2012

Japan Windows7 64bit

Hi Shizuka,


Thank you for considering Aspose products, and welcome to Aspose.Cells support forum.

Aspose.Cells APIs need the fonts used in the spreadsheet to be installed on the machine where conversion has to take place. If you properly install the required TrueType fonts (Meiryo & Meiryo UI) on your system, the Aspose.Cells for .NET API will not substitute the actual fonts while rendering the results to PDF. I have performed a test on my machine while placing the Meiryo font in the system’s font directory, you may notice from the attached snapshot that the API has embedded the correct font in the resultant PDF.

Please note, I have used the latest version of Aspose.Cells for .NET 8.1.0 on my end.

Thanks,

>Aspose.Cells APIs need the fonts used in the spreadsheet to be installed on the machine where conversion has to take place.

Fonts is installed on machine

Directory :C:\Windows\Fonts

File:meiryo.ttc

Is there any other settings?

Hi Shizuka,


Thank you for writing back.

Please use the CellsHelper.FontDir property to point the API to use the fonts from the location containing the Meriyo fonts. Also please give a try to the latest version of Aspose.Cells for .NET 8.1.0.1 on your end. In case the problem persists, please zip the Meriyo fonts from your machine and provide here for further investigation.

Please check the below provided code snippet for your reference.

C#

CellsHelper.FontDir = @“C:\Windows\Fonts”;

var book = new Workbook(myDir + “FontConvertTest.xlsx”);
book.Save(myDir + “output.pdf”, SaveFormat.Pdf);

I've tried both. However, as a result was the same.

I've attached the font file

Hi Shizuka,

Thank you for sharing the fonts used in the spreadsheet.

We have evaluated the scenario again on our end, and found that the embedded fonts in the resultant PDF are provided in below list, whereas the spreadsheet uses only Meriyo family of fonts with Calibri as base font.

  • ArialMT
  • PGothic
  • Meriyo

For further investigation, we have logged a ticket (CELLSNET-42742) in our bug tracking system. Please spare us little time to properly analyze the scenario on our end to provide further assistance. In the meanwhile, we will keep you posted with updates in this regard.

Thanks for reply.

Can I configured to use the client font? (Not use embedded fonts)

I want use Meiryo font and local font.

Hi Shizuka,


Thank you for writing back.

Let me explain how Aspose.Cells for .NET API uses the TrueType fonts behind the scene so you may understand the usage and gain benefits from it in future as well. Below is the process that Aspose.Cells follows.

  1. Aspose.Cells tries to find the fonts on the file system (in system’s fonts folder) matching the exact font name used in the spreadsheet, and upon finding the exact fonts the API renders the spreadsheet to PDF using these fonts.
  2. If Aspose.Cells cannot find fonts with the exact same name, it attempts to use the default font specified under the Workbook’s DefaultStyle.Font property. In case of your provided spreadsheet the default fonts is Calibri.
  3. If Aspose.Cells cannot locate the font defined under the workbook’s DefaultStyle.Font property, it attempts to select the most suitable fonts from all of the available fonts.

As narrated above, the default behavior of Aspose.Cells APIs is to locate and use the exact fonts for rendering purposes. In this presented case, the spreadsheet uses Meriyo & Meriyo UI fonts to format the text and the default font is Calibri. All of aforesaid fonts are available in system’s font directory although while rendering to PDF, the API embeds non-relevant fonts in the resultant PDF. This behavior could be bug or at least needs a justification, therefore we are currently looking into this matter to find out the problem cause.

Please feel free to write back in case you have further question or concerns.

Thank you your explain.

I checked which Japnes font is convertible.

And compare file that converted by COM object.

I hope that this problem be solved.

----

Other Environment

*ASP.net C#

*.netFrameFowrk 4.5

*VisualStudio2012(Debug) / IIS7.5 (or WindowsServer2008 R2 SP1)

Hi Shizuka,


Thank you for sharing the comparison.

We have already fix the problem logged earlier as CELLSNET-42742, and we will soon provide the fix with next major release of Aspose.Cells for .NET 8.1.1. We have requested the core development team to test your recently shared spreadsheet against the upcoming version, just to make sure that the latest build will generate desired results in terms of embedding fonts in the resultant PDF.

Hi Shizuka,


Your recently provided spreadsheet uses many fonts that are not present in our environment. It would be of great help in evaluating the conversion process on our end, if you can share all the fonts used in the spreadsheet. Please make an archive of all TTF/TTC files from your environment and share here. In case the archive file size is larger than 10MB, please upload the archive on any free file hosting services such as Dropbox or Google Drive, and share the download link here.

Thank you for your continues cooperation.

Thank you for confirmation
I have attached the font file.

However, I would like to use the most Meiryo.
And I have used the external character a special font.


I have other questions
- A Picture Based on Cell Reference can convert PDF?
- ConditionalFormat are not reflected in the PDF

Hi Shizuka,


Thank you for providing the fonts for our testing. We have forwarded the download link to the core development team, reason being; the latest release containing the fix for the ticket CELLSNET-42742 hasn’t been published yet therefore the concerned development team member will test your previously provided spreadsheet with upcoming release. We will keep you posted with updates in this regard.

Regarding your other questions, please find the answers as follow,

  • If your spreadsheet has images, they will be exported out to PDF format just fine.
  • If your spreadsheet has Conditional Formatting applied, it should reflect in the exported PDF file.

In case you are having troubles with any of the above mentioned scenarios, we would request you to please create a separate thread for each type of issue while providing your sample spreadsheet along with code snippet used on your side. We will thoroughly study the scenario to provide further assistance.

Hi Shizuka,


Thank you for your patience.

We have fixed the problem mentioned in the ticket CELLSNET-42742. Please give a try to the latest version of Aspose.Cells for .NET 8.1.0.3 on your end to see the results. We have confirmed that the latest build embeds the correct fonts in the resultant PDF file. Please check the attached snapshot “Embeded-Fonts-FontConvertTest.png” and resultant PDF file generated against your spreadsheet “FontConvertTest.xlsx”.

We have performed more test against the spreadsheet “testFont.xlsx” and noticed that the latest build (link shared above) produces the results close to the one generated with MS Excel application. Please check the snapshot “PDF-Comparison.png”. You will notice that the last value (on C12) wasn’t rendered correctly with MS Excel application, reason being, the test platform does not have this font installed. Whereas Aspose.Cells API found an alternative font to render this value, so it used the substituted font for it.

C#

CellsHelper.FontDir = @“C:\Windows\Fonts”;
var book = new Workbook(myDir + “testFont.xlsx”);
var saveOptions = new PdfSaveOptions(SaveFormat.Pdf);
book.Save(myDir + “testFont.pdf”, saveOptions);

Please feel free to write back in case you have further question or concerns.

Thank you!

I was able to confirm Meiryo embed

(About Font of C12,I am checking whether that send is possible or not..)

>If your spreadsheet has Conditional Formatting applied, it should reflect in the exported PDF file.

I found a case that can not be displayed

(Ex. CondtionFormatTest.xls => CondtionFormatTest.pdf)

Hi Shizuka,


Thank you for the confirmation on the issue of embedding Meriyo fonts in the Aspose.Cells generated PDF file. Regarding the font used for C12 of your recently provided spreadsheet, we believe the archive shared earlier by you did not contain the required fonts. Reason being, we have simply pasted the fonts from the archive to the system’s font directory, whereas when loaded with MS Excel 2010, the specified spreadsheet didn’t render the value of C12. Please provide the font used for C12, and we will re-evaluate the scenario on our end.

Thank you for sharing the sample file to elaborate the problem regarding the conditional formatting. We have noticed that the conditionally formatted colors are not rendered properly when your provided spreadsheet is converted to PDF while using the latest version of Aspose.Cells for .NET 8.1.0.3. We have logged this problem in our bug tracking system under the ticket Id CELLSNET-42784. Please spare us little time to properly analyze the problem cause, and to provide a fix (if applicable). In the meanwhile, we will keep you posted with updates in this regard.

The issues you have found earlier (filed as CELLSNET-42742) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

attached the font used for c12

I think external character is the cause

Hi Shizuka,


Thank you for providing the missing font.

We have checked that by placing this font in the system’s font folder, the Aspose.Cells for .NET 8.1.1 (download link shared by the Aspose Notifier) renders the text properly in the resultant PDF file. Please check the attached snapshots for you reference.

In case you find any ambiguity, please feel free to write back.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.1.1.1 and let us know your feedback.