Search code examples
asp.net-coreasposeaspose-cells

Aspose Cell .net core: Some text is cut off on linux host


I got an issue when develop an export feature using aspose on .net core platform. The issue is that some of the rows data exported as PDF is being cut-off.

I tried on my local environment (windows) there are no issue. The result is as good as I expected.

But when I publish the code into host environment (linux) the result seems off.

My local result (windows)

enter image description here

My hosted result (linux)

enter image description here

Here is piece of code that I am using to generate the file

public FileData ExportToFile(DataTable data, string format, string query)
    {
        var workbook = new Workbook();
        var style = workbook.CreateStyle();
        workbook.DefaultStyle = style;

        var sheet = workbook.Worksheets[0];

        AutoFitterOptions oAutoFitterOptions = new AutoFitterOptions { AutoFitMergedCells = true, OnlyAuto = true };

        data = _RemoveFormat(data); // Parse all data to String
        
        /**/
        
        sheet.PageSetup.Orientation = PageOrientationType.Landscape;
        
        PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
        pdfSaveOptions.AllColumnsInOnePagePerSheet = true;
        sheet.AutoFitRows(oAutoFitterOptions);
        sheet.AutoFitColumns(oAutoFitterOptions);
        
        workbook.Save(stream, pdfSaveOptions);
        
        /**/
    }

Solution

  • After discussing with Aspose support. I found out that the differences caused by that missing font from my Hosted Server (linux). So I need to install it on the server to get both document have the same style.

    In my case, the my app was hosted in kubernetes cluster, so I need to add this line of commands in the dockerfile

    RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
    
    RUN apt-get update \
        && apt-get install -y --allow-unauthenticated \
            fontconfig \
            ttf-mscorefonts-installer