Aspose.Cells : Image and PDF generated by code deployed on server are having improper formattings

We created a POC for converting xlsx to image and pdf using aspose.cells free licence with watermark with our dot net solution. Our dot net application is deployed on EKS cloud. We are seeing that the image or pdf generated by the application deployed on server are having some distortions or improper formatting while the image or pdf generated when code is running locally dont have any such issues. Can you please suggest what is the reason behind this and how to resolve this issue.

@apoorvBaghel

Cause

The issue you’re experiencing with improper formatting of images and PDFs generated by your Aspose.Cells code on a server is likely due to differences in the environment settings between your local machine and the server. This can include variations in installed fonts, system configurations, or the execution method in a cloud environment like EKS.

Solution

To resolve this issue, please follow these steps:

  1. Font Availability: Ensure that all fonts used in your Excel files are installed on the server. If a font is missing, Aspose.Cells may substitute it with a default font, leading to formatting issues.

  2. Check Configuration: Review the configuration settings of your application on the server. Ensure that any necessary environment variables or configurations that affect rendering are consistent with your local setup.

  3. Use PdfSaveOptions: When saving to PDF, utilize the PdfSaveOptions class to set properties that can help maintain formatting. For example, specify the default font to use for rendering:

    PdfSaveOptions options = new PdfSaveOptions();
    options.DefaultFont = "Arial"; // Set a common font
    workbook.Save("output.pdf", options);
    
  4. Image Resampling: If images are involved, ensure that you set the desired PPI (pixels per inch) and JPEG quality when saving images:

    PdfSaveOptions pdfOptions = new PdfSaveOptions();
    pdfOptions.SetImageResample(96, 80); // Set desired PPI and JPEG quality
    workbook.Save("output.pdf", pdfOptions);
    
  5. Testing: After implementing these changes, test the output again on the server to confirm whether the formatting issues have been resolved.

Next Steps

If the problem persists after trying the above solutions, consult the Aspose.Cells documentation for known issues related to your specific version or environment. Additionally, reach out to Aspose support with detailed information about your setup and the specific issues you’re encountering.

Please let me know if you need further assistance!

@apoorvBaghel
Please ensure that all fonts used in the Excel file have been installed on the server. Of course, you can also download the fonts to the server and set custom font folders. Regarding how to set custom font folders, please refer to the following document.

If you still have questions, please provide your sample file, images and the PDF result file generated on the server, and we will check it soon.