Convert Excel to PDF, the border width of table is too wide

Hi, when convert excel to pdf, I want to the border with of table to be more thin. In excel, the cellbordertype has set to thin. Can I customize the table border width? Or after converting to PDF, read the file through aspose.pdf to set the table width, and then save it again.
border-width.png (4.0 KB)

@xhaixia,

Thanks for the screenshot.

If you have already set the CellBorderType.THIN, don’t you get expected results in the rendered PDF file by Aspose.Cells for Java? You may choose your desired field (option) for CellBorderType | Aspose.Cells for Java API Reference to be set in code and before rendering the spreadsheet to PDF. Please note, these are the only border types available and we can set for Excel worksheet cells. In case, you still find any issue, kindly provide your input Excel file and output PDF file (by Aspose.Cells). Also, share your sample (runnable) code snippet that you are using. Moreover, please share your expected PDF file having borders for the data table (with your desired width for border lines). We will check and assist you accordingly.

The code is as follows

 Workbook workbook = new Workbook("excel1.xlsx");
 workbook.save("test1.pdf");

The expected result is like border-width2 picture.
excel1.zip (103.8 KB)

@xhaixia
By testing on the latest version of v25.4 using sample files and code, the test results were compared with the pdf saved by Excel. The PDF file generated by Cells code yielded results that were closer to the original Excel file. The border size is consistent, but the results generated by Excel may even have different border sizes. Please refer to the attachment. result.zip (22.0 KB)

Additionally, the subtle differences observed by the eyes may be due to the presentation of Excel and PDF software.

@xhaixia
We try to match the width in Excel as much as possible.
Do you want a custom width?

Yes, I’d like a custom width of 0.5

@xhaixia
At present, Aspose.Cells does not support setting custom border width when saving file to pdf.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-46403

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@xhaixia
If you accept 0.5 as the width of the border, please set border type as CellBorderType.HAIR.

@xhaixia ,

We are pleased to inform you that your issue has been resolved, and the fixed functionality will be included in the upcoming release (Aspose.Cells v25.6), scheduled for the next week of June 2025.

We will add new API: PdfSaveOptions.setCustomRenderSettings(CustomRenderSettings value).
Code:

Workbook wb = new Workbook("excel1.xlsx");
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

//Set custom setting for rendering.
pdfSaveOptions.setCustomRenderSettings(new MyCustomRenderSettings());

wb.save("output.pdf", pdfSaveOptions);

Class MyCustomRenderSettings:

import com.aspose.cells.CellBorderType;
import com.aspose.cells.CustomRenderSettings;

public class MyCustomRenderSettings extends CustomRenderSettings
{
	@Override
	public float getCellBorderWidth(/*CellBorderType*/int borderType)
	{
		switch (borderType)
		{
			//Set custom width according to border type for your requirements.
			case CellBorderType.THIN:
				return 0.5f;

			default:
				return super.getCellBorderWidth(borderType);
		}
	}
}

The issues you have found earlier (filed as CELLSJAVA-46403) have been fixed in Aspose.Cells for Java 25.6.