Aspose.Cells generates different PDFs when run on two machines with the same configuration

Hello,
we are generating a PDF from a CSV file from Aspose.Cells from two machines with the same Windows 10 version, font set and Java runtime. The generated PDF are different in size. Analyzing the PDF we discovered a difference in the following commands:
image.png (12.0 KB)
We would like to know what could cause this difference.
Attached the generated files from machine1 and machine2.
The Java code run is a very simple open/save with no specific save options; library used is Aspose.Cells 20.12.
Many thanks in advance for your support.
Machine1_PP-Performance-20080505.csv.cells.pdf (98.4 KB)
Machine2_PP-Performance-20080505.csv.cells.pdf (98.5 KB)

@gianfranco.dancelli,

The difference in the output PDF size is minor. I noticed only first two columns’ width is slightly different or the placement of the contents is different for first two columns. Everything else is same. Could you elaborate what is different when comparing machine1 PDF Vs machine2 PDF, please provide some screenshots to highlight the problematic areas in the output PDFs? Also zip your input CSV file and provide complete details about the two machines (e.g. JDK version, display settings of both machines (should be 100% scale of OS), etc.), we will evaluate it soon.

Yes the difference is minor, but we are wondering why on two machine that are exactly the same in configuration and software the result is different.
What we have noticed by graphically comparing the two PDFs is a shift of a space in the first data column; in one file the space is at the end of first column and the other is at the beginning:
image.png (29.8 KB)

The two machines are running:

  • Windows 10 Enterprise (both updated to service pack cumulative update 20H2)
  • all available windows updates have been installed on both
  • windows fonts directories are exactly the same
  • Java runtime version: 1.8.202, 64bit
  • OS screen scaling at 100%

Please notify me if you need further info.
Attached the zip file with the source cvs used for tests.
PP-Performance-20080505.zip (2.6 KB)

@gianfranco.dancelli,

I noticed your both generated PDFs are produced by “ISIS Information Systems” as PDF producer. So, could you share your sample code using Aspose.Cells APIs (only) on how you are rendering your attached CSV file to PDF file format. Also attach those PDF files (by Aspose.Cells v20.12) on both machines. Moreover, I noticed the default font is set different than your actual font’s data. Your input CSV file data is using Calibri font so the PDFs would be generated using Arial font. You may cope with it using the following sample code, I tested and it works same as MS Excel’s (manually) rendered PDF file:
e.g.
Sample code:

Workbook workbook = new Workbook("f:\\files\\PP-Performance-20080505.csv");

        Style style = workbook.getDefaultStyle();
        style.getFont().setName("Calibri");
        workbook.setDefaultStyle(style);
        workbook.save("f:\\files\\out1.pdf");

PS. I directly generated your input CSV file to PDF format by MS Excel (manually) and by Aspose.Cells (using above code) and got same output but it is different (regarding display of data) when comparing with your provided PDF file(s).

Hello,
please find attached here the small Java program we used to reproduce the issue on the two machines. The zip file contains the source csv, the common font used, the Java code and the two output PDFs produced on the different machines.
Used Aspose.Cells version 20.12.
Many thanks for checking.
Gianfranco

TestCsvToPdfAsposeCells.zip (163.1 KB)

@gianfranco.dancelli,

I tested using your sample code and template CSV file and found the same output as per your machine2 which is right. Still could not evaluate why it is slightly different for first two columns’ width in your output of machine1. For example, if you compare first two cells (A1 and A2) you will see data is is not in sync.
This sequence is same in all cells in the first column, so you should get same output of machine2 on all machines.

Anyways, you may provide complete details of machine1, we might check further. Please note, your data in the output of machine1 is ok, I do not think this is an issue. Could you also perform the tasks (as per your code) in MS Excel manually and finally render to PDF and provide us if you get different output. We will check it soon.

Hello,
and thanks for your support.
Yes we know that the difference is not big, but in any case the PDF are different and would be interesting for us to understand what is causing this.
I’ve already provided the machine1 details in my previous posts, but I copy them here again by adding also the hardware specs:

The two machines are both running:

  • Windows 10 Enterprise (both updated to service pack cumulative update 20H2)
  • all available windows updates have been installed
  • windows fonts directories are exactly the same
  • Java runtime version for both: 1.8.202, 64bit
  • OS screen scaling at 100%
  • Both are equipped with:
    * Intel® Core™ i7-9700F CPU @ 3.00GHz 3.00 GHz
    * 16.0 GB RAM
    * 64-bit operating system, x64-based processor
    * Windows 10 Enterprise 20H2
    * NVidia GeForce GT710 display Adapter
    * 500GB SSD Samsung.

If you need any further specific information on the two machines, just let me know.
Thanks,
Gianfranco

@gianfranco.dancelli,

Thanks for the details.

I now tested your scenario on another machine similar to your machine1 (not 100% though) using your sample code and template file on Windows10. Please find attached the output PDF file for your reference. I got the same output as per your machine2. Here is the complete details of current environment:

  • Windows 10 Pro (Version: 1709, OS Build: 16299.847)
  • I also re-installed your provided font
  • Java runtime version: 1.8.0_251
  • OS screen scaling at 100%
  • The machine is equipped with:
  • Intel® Core™ i5-3210M CPU @ 2.50GHz 2.50 GHz
  • 8.0 GB RAM
  • 64-bit operating system, x64-based processor

PP-Performance-20080505.out.pdf (109.1 KB)

@gianfranco.dancelli
The different Locale of your two machines may cause the output difference.
To validate it, you can set the same Locale in the code. e.g.

final TxtLoadOptions lopts = new TxtLoadOptions();
lopts.setPaperSize(PaperSizeType.PAPER_A_4);
lopts.setSeparator(' ');
lopts.setLocale(Locale.US);
...

If you get the same outputs of your two machines, then you can set your two machines with the same Locale.
By the way, the font name should be “ArialMT” instead of “Arial MT”.

...
defstyle.getFont().setName("ArialMT");
...
font.setName("ArialMT");

Helo,
thanks, the setLocale(Locale.US) solved the issue, now the PDF are the same on both machines.
BUT:
apparently both machines are already set to the same locale settings (en_US) as far as we can see from Windows; moreover if in the code we put the following:

// get Locale infos
final Locale currentLocale = Locale.getDefault();
if (currentLocale.equals(Locale.US))
System.out.println(“Locale is equal to US defaults.”);
else
System.out.println(“Locale is different from US defaults.”);

right before issuing the setLocale call in TxtLoadOptions, then we get that the current locale is already equal to US before setting it, so we can’t understand what could be different.
Many thanks,
Gianfranco

@gianfranco.dancelli,

Could you please try to use the following code to print default Locale on your end:
e.g.
Sample code:

final TxtLoadOptions lopts = new TxtLoadOptions();
lopts.setPaperSize(PaperSizeType.PAPER_A_4);
lopts.setSeparator(' ');

//print default Locale
Locale defaultLocal = Locale.getDefault(Locale.Category.FORMAT);
System.out.println("Locale.getDefault(Locale.Category.FORMAT): " + defaultLocal);
System.out.println("Locale.getDefault(): " + Locale.getDefault());

lopts.setLocale(Locale.US);
..

Please note, in our code base, if jdk version >= 1.7, we use Locale.getDefault(Locale.Category.FORMAT) to get default Locale otherwise, use Locale.getDefault()).

Hello,
yes, the problem was related to the Category.FORMAT, that on one machine was en_US and the other was set to IT.
Many many thanks for your support and hints, now we know that this setting is important to have the same output and we’ll place the locale setting in our code to stay on the safe side.
Have a nice day,
Regards
Gianfranco

@gianfranco.dancelli,

Good to know that the code segment works for your needs well. In the event of further queries or issue, feel free to contact us any time, we will be happy to assist you soon.