Hi,
I am using aspose-cells-8.5.2.4.
While rendering charts to PDF, border of the chart area is incorrectly rendered in the PDF. For your reference I have attached two excel files containing charts with which the issue is clearly reproducible along with PDFs being generated by Aspose .
Following is the code snippet being used:
Chart chart = worksheet.getCharts().get("Chart 1");
WorksheetCollection ws = workbook.getWorksheets();
Chart chart = ws.get("wo cons charts").getCharts().get("Chart 1");
ChartShape cshape = chart.getChartObject();
int sheetIndex = ws.add();
com.aspose.cells.Worksheet worksheet = ws.get(sheetIndex);
chart.calculate();
double chartWidthInInches = chart.getChartObject().getWidthInch();
double chartHeightInInches = chart.getChartObject().getHeightInch();
worksheet.getCells().setColumnWidthInch(0, chartWidthInInches);
worksheet.getCells().setRowHeightInch(0, chartHeightInInches);
//Setting the name of the newly added worksheet
String transientSheetName = "TransientWorksheet";
worksheet.setName(transientSheetName);
//Copy the Chart to target Worksheet
worksheet.getShapes().addCopy(cshape, 0, 0, 0, 0);
//Get the new chart and set its height and width accordingly
com.aspose.cells.Chart chart1 = worksheet.getCharts().get(0);
chart1.getChartObject().setHeightInch(chartHeightInInches);
chart1.getChartObject().setWidthInch(chartWidthInInches);
//Make remaining worksheets invisible so that they are not part of the output pdf
for (int i = 0; i < ws.getCount(); i++) {
String sheetName = ws.get(i).getName();
if(!transientSheetName.equalsIgnoreCase(sheetName)){
ws.get(i).setVisible(false);
}
}
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setOnePagePerSheet(true);
worksheet.getPageSetup().setTopMargin(0);
worksheet.getPageSetup().setBottomMargin(0);
worksheet.getPageSetup().setRightMargin(0);
worksheet.getPageSetup().setLeftMargin(0);
worksheet.getPageSetup().setPrintArea("A1:A1");
workbook.save("c:/temp/out-1.pdf", pdfSaveOptions);
Thanks,
Neeraj