Free Support Forum - aspose.com

Aspose.Cell AutofitRows Height did not fit in Linux (C#)

hi i have used autofitrow feature. when i use windows, i get suitable result. But, when I use linux, I found my text is truncated. can you help me to come up with a solution? thanks

image.png (45.7 KB)
image.png (41.1 KB)

@Isa_Mulia,

After seeing your screenshots, it looks like missing font(s) issue on linux machine. I think, on Linux machine, the required fonts are not there/same. Please note, Aspose.Cells requires underlying fonts used in the workbook for auto-fit operation and rendering (e.g Excel to PDF, Sheet to image feature, etc.) tasks. Please make sure that the fonts are installed/there in the relevant fonts folder (you may even copy the relevant fonts from Windows to Linux). Also, the fonts folder should be accessed seamlessly (there should not be any rights issue), you may add fonts folder path in code at the start of your program/application. Now you may try your scenario/ case, it should work fine. For further reference, see the document on it.

If you still find any issue, let us know with more details, sample code (runnable), sample files (you may zip the files prior attaching), we will check it soon.

Hi @Amjad_Sahi,
I have tried thhe documentation to change the font you have provided, but the font still does not changed. The font I use is dejavu sans, and I use AmazonLinux. this the code that i use

        [.net]
        pdfWorkbook = new Workbook();
        //Using Uploaded font
        MemoryFontSource sourceMemory = new MemoryFontSource(File.ReadAllBytes(@"app\Assets\DejaVuSans.ttf));
        //Using installed font at AmazonLinux
        FontConfigs.SetFontSources(new FontSourceBase[] { new FolderFontSource(@"\usr\share\fonts\dejavu", true), sourceMemory });
        Style style = _pdfWorkbook.CreateStyle();
        style.Font.Name = "DejaVu Sans";
        pdfWorkbook.DefaultStyle = style;

Thanks

@Isa_Mulia,

Please note, the fonts folder settings (in code) must be done before using any other Aspose.Cells APIs, so you may try to move the relevant lines at the start:
e.g
Sample code:

[.net]
        //Using Uploaded font
        MemoryFontSource sourceMemory = new MemoryFontSource(File.ReadAllBytes(@"app\Assets\DejaVuSans.ttf));
        //Using installed font at AmazonLinux
        FontConfigs.SetFontSources(new FontSourceBase[] { new FolderFontSource(@"\usr\share\fonts\dejavu", true), sourceMemory });
        pdfWorkbook = new Workbook();
        Style style = _pdfWorkbook.CreateStyle();
        style.Font.Name = "DejaVu Sans";
        pdfWorkbook.DefaultStyle = style;

If you still find any issue, let us know with more details, sample input and output files (you may zip the files prior attaching) and sample code, we will check it soon.