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

Free Support Forum - aspose.com

Save as Pdf rendering issue

Hi, by chance I had exactly the same issue at the same time (I was about to ask the question myself when I saw this thread). I found hints to the solution elsewhere in your forum and documentation and coded exactly this fix into our product yesterday. It works as expected but I do find a secondary problem. Depending on the width of the cell and the length of the text, there is sometimes an extra blank row. I have attached two copies of a test file, one processed with Aspose and one processed with VSTO. As you can see the version processed with Aspose has an extra blank row compared to the vsto version. I know that some of our users will be upset about this as they don’t like to see any change at all. Is this something that you know about and we just have to live with or is there a possibility of this being fixed please?

test.pdf (17.8 KB)
test_vsto.pdf (59.7 KB)

By the way, fairly recently we have migrated the whole of our spreadsheet based reporting product to work with Aspose rather than VSTO and I have to say that I have been amazed by how good (complete/bug free) the Aspose product is. We have encountered exceedingly few issues. :slight_smile:

@TangoGolf27,

Please zip your input Excel file and provide us. Also paste your sample code that you are using, we will check it soon.

Thanks for response. Here is a zip file containing the test1.xlsx and an exceedingly simple program file that recreates the problem.

    static void Main(string[] args)
    {
        Workbook wb = new Workbook(args[0]);
        foreach (Worksheet ws in wb.Worksheets)
            ws.AutoFitRows(true);
        wb.Save(args[1]);
    }

WordWrapIssue.zip (11.7 KB)

@TangoGolf27,

Thanks for the template file and code segment.

Well, it is not an issue with Aspose.Cells APIs by any means as it renders to PDF the same way as MS Excel does (manually). In fact it renders based on the what is shown in the print preview (taken in MS Excel) for different sheets. I have save as PDF using your template file in MS Excel and got the same output as Aspose.Cells generates. See the attached file for your reference.
test1_Ms Excel.pdf (104.5 KB)

Thanks for response.

Unfortunately I cannot download your pdf (because I am not topic owner). But I have taken another close look and saved the pdf directly from Excel as well as via Aspose.Cells as per attached zip. Unless there is something really strange specific to my machine you will see that in “test1.pdf” there is an extra blank line (before the “3”) that is not there in “test1_excel.pdf”. Do you not see the same?

WordWrap2.zip (90.5 KB)

@TangoGolf27,

Since you are not the owner of the thread, so you cannot download the attachments. Let me split the thread so you could download the attachments.

I have also checked your output PDFs, you are using Office 365 for rendering. Please use MS Excel (e.g 2013/2016 or earlier versions) to check the print previews of the sheets and then render to PDF file format, you will get the same output produced by Aspose.Cells.

Phew… I thought I was going crazy for a moment there. So it seems that MS Excel has been improved / fixed in this respect but Aspose.Cells still behaves as the older unimproved MS Excel. I don’t suppose it can really be regarded as a high priority issue but it would be nice to see the improvement reflected in Aspose. I know that our users would appreciate this.

Thanks very much for your help.

@TangoGolf27,

We can check if we can improve on it. Please do open the file into MS Excel (e.g 2013, 2016, etc.) manually, save to “PDF” and attach the file.

@TangoGolf27,

We have evaluated your issue further. We also tried the conversion on our local office 365 application and we got the same output as per Aspose.Cells generated output, see the attached output PDF by Office 365.

It looks like your display settings (OS) is not 100% on your end before re-saving the file to PDF in MS Excel/Office 365. Please make sure that the DPI setting on your environment is 100% before rendering.
test1_office365.pdf (48.4 KB)

Yes, it seems to relate to both the display settings and the version of MS Excel. I had scale set to 125%.

In the attached zip you will find pdf files created with excel 365 (click-once installation) and with excel 2007 with both scale = 100% and scale = 125%. Only the excel 365 / 125% gives the desirable result without the blank row. Aspose always gives the blank row.

Given this situation I am happy with the consistent result from Aspose. I would not like to see the result from Aspose depend on screen settings as it is running on a server and we are creating the pdf from the xlsx without any UI.

If, of course, it were possible to get rid of the blank row in a future release of Aspose without regard to the display settings or whatever MS Excel might do then that would be a nice enhancement.

Thanks very much for your help.

WordWrap3.zip (544.3 KB)

@TangoGolf27,

Thanks for the files.

Well, generally, Aspose.Cells works the same way as you get by 100% display settings.
We will further check and may get back to you with more details on it.

Well, you may set it in the code (by using the following line of code) at the beginning to get consistent results, e.g., set it after setting license.

CellsHelper.DPI = 96;

Thank you! I did not realize that it was possible to do this.

@TangoGolf27,

You are welcome and good to know that you are up and running again.