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

Free Support Forum - aspose.com

Issue reported by one of our customer : Long hyphens don't display appropriately in PDF/Image output of excel chart

Issue reported by one of our customer !

Hi,
I am using Aspose cells v8.5.2.4
On converting excel chart 'Chart 2' to PDF/Image the long hypens in title are not rendered as per their position & size in original excel.

For reference, here's the sample code & attached excel doc & sample outputs.

private static void chartToPDF() throws Exception {
Workbook workbook = new Workbook("D:\\Customer_documents\\IHS\\Chart issues\\72272_bad_looking_chart - Copy.xlsx");
WorksheetCollection ws = workbook.getWorksheets();
Chart chart = workbook.getWorksheets().get(0).getCharts().get("Chart 2");
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();
boolean defaultApproach = true;
if (chartWidthInInches > 18 || chartHeightInInches > 5) {
// The approach being followed here is to iterate as many columns as colwidth in pixels & set each column width equal = 1 pixel.
// Similarly for chart height, iterate through as many rows as row height & set each row height = 1 pixel.
// This is being done to fit in large charts that have height & width beyond maximum row/col dimensions & white spaces around
// the chart.

double chartWidthInPixels = chart.getChartObject().getWidth();
double chartHeightInPixels = chart.getChartObject().getHeight();
// Deliberately including one more column because Aspose considers the last column adjacent to chart which leads to white space
// on right of chart
for (int i = 0; i <= chartWidthInPixels; i++) {
worksheet.getCells().setColumnWidthPixel(i, 1);
}

// Deliberately including one more row because Aspose considers the last row adjacent to chart which leads to white space
// below the chart.
for (int i = 0; i <= chartHeightInPixels; i++) {
worksheet.getCells().setRowHeightPixel(i, 1);
}
defaultApproach = false;
} else {
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 Second 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);
//Setting Print area to first cell only as the chart is contained in the first cell (A1:A1)
if (defaultApproach) {
worksheet.getPageSetup().setPrintArea("A1:A1");
}
// Save the workbook
workbook.save("d:\\temp\\Chart 2.pdf", pdfSaveOptions);
}


private static void chartToImage() throws Exception {
Workbook workbook = new Workbook("D:\\Customer_documents\\IHS\\Chart issues\\72272_bad_looking_chart - Copy.xlsx");
WorksheetCollection ws = workbook.getWorksheets();
Chart chart = workbook.getWorksheets().get(0).getCharts().get("Chart 2");
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();
imageOrPrintOptions.setImageFormat(ImageFormat.getPng());
imageOrPrintOptions.setHorizontalResolution(600);
imageOrPrintOptions.setVerticalResolution(600);
imageOrPrintOptions.setOnePagePerSheet(true);
imageOrPrintOptions.setOnlyArea(true);
chart.toImage("D:/temp/Chart 2.png", imageOrPrintOptions);
}



Thanks,
Jaspreet

Hi,

Thanks for your posting and using Aspose.Cells.

We were able to replicate this issue by executing the following sample code with the latest version: Aspose.Cells
for Java v8.6.0.2
. Long hyphens don’t display appropriately in PDF/Image output of excel chart.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-41493 - Long hyphens don’t display appropriately in PDF/Image output of excel chart

I have attached the output pdf generated with the following code for a reference.

Java
String filePath = “D:\Downloads\72272_bad_looking_chart±+Copy.xlsx”;

Workbook workbook = new Workbook(filePath);

PdfSaveOptions opts = new PdfSaveOptions();
opts.setOnePagePerSheet(true);

workbook.save(filePath + “.out.pdf”, opts);

Hello.

At IHS we also have Aspose.cells license and we have encountered this problem too.

Fixing it is important for us, because our users face it in everyday work.

Regards,
Tomek

Hi Tomek,


Thank you for contacting Aspose support.

Please note, the ticket attached to this thread is currently in analysis phase therefore it is too early to say when the fix will be available. That said, we strongly suggest you to create a new thread with problem description and supporting documents so we could evaluate it separately and log separate ticket, if applicable.

Hi,

Thanks for using Aspose.Cells for Java.

Please download and try this fix: Aspose.Cells for Java v8.6.0.6 and let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-41493) have been fixed in

Aspose.Cells for Java (Download | Maven)

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hello,

I am using chart.toPdf() method of Aspose.Cells v8.6.2.4 to generate the PDF. Unfortunately, the issue has re-emerged (for Chart 1) after using chart.toPdf() method. Long hyphens in title are not rendered as per their position & size in original excel. In PDF output, the long hyphen is overlapping with the text.

I am attaching a screenshot comparing actual chart with chart's PDF generated using Aspose.Cells v8.6.2.4. I have also attached the PDF for your reference.

Please note that in the excel provided, the issue was originally reported for Chart 2. For Chart 2 the issue is resolved but it now reappears for Chart 1 in the same excel file.

Can you please analyse this issue.

Hi,


Thanks for providing us output PDF file and screen shot.

I was able to notice this minor difference and I replicated it with following lines of code.

[Java]
String dir = “f:\files\”;
Workbook workbook = new Workbook(dir + “72272_bad_looking_chart±+Copy.xlsx”);

WorksheetCollection ws = workbook.getWorksheets();

Chart chart = ws.get(0).getCharts().get(“Chart 1”);

chart.toPdf(dir + “out172272chart1.pdf”);

Here is the screen shot of the output chart in PDF:
http://prntscr.com/9ecp3b
Although this is subtle difference but we will check if we could enhance the Chart to Image/PDF rendering further. I have logged a separate ticket with an id “CELLSJAVA-41640” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,

Thanks for using Aspose.Cells.

We have fixed the issue CELLSJAVA-41640.

Please download and try the latest fix: Aspose.Cells for Java v8.6.2.6 and let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-41640) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hello,


Thanks for your reply.

I have tested this issue with the latest version of Aspsoe.Cells - v8.6.3. Although there is considerable improvement, but there is still some difference in the position of Long-Hyphens. If you compare Aspose-Generated PDF with Excel-Generated PDF, you will see that the position of Long-Hyphens in both is not same. Moreover, the long-hyphens are overlapping with the text.

I have attached screenshots comparing Aspose-Generated PDF with Excel-Generated PDF for both Chart 1 and Chart 2 in the attached Excel file.

This is a customer reported issue and they are not satisfied with the PDF & Image output, so we need to address this.

This issue exists for both PDF output as well as PNG output, although PNG output is much better than PDF output. I have attached both PDF and PNG for Chart 1 and Chart 2.

Can you please look into this.


Thanks,
Jaspreet

Hi Jaspreet,


Thank you for sharing your feedback.

We have reopened the ticket (CELLSJAVA-41640) based on your recent comments and have requested the concerned member of the product team to review the scenario for further improvements. We will keep you posted with updates in this regard.

Hello,


Is there any update on this issue?

Thanks,
Neha
Hi Neha,

I am afraid, we haven't yet received any updates regarding the issue logged earlier as CELLSJAVA-41640. However, we have requested the concerned member of the product team to share an ETA for it. As soon as we get any updates in this regard, we will share here for your kind reference.
Hello,

Is there any update on this issue?

Thanks,
Neha

Hi,

Thanks for your posting and using Aspose.Cells.

We are
afraid, there is no update for you regarding this issue at this moment.
However, we have logged your comment in our database against this issue
and again requested the product team to provide some fix or ETA for this
issue. Once there is some news for you, we will let you know asap.

Hi,

Thanks for your using Aspose.Cells.

We have fixed the issue CELLSJAVA-41640.

Please download and try the latest fix: Aspose.Cells for Java v8.8.0.2 and let us know your feedback.

Hello,

I am currently using Aspose.Cells v17.8.
We are still facing rendering issues in Long-Hyphens in PDF and PNG outputs of Chart 1 and Chart 2. The long-hyphens should render exactly as they are in Excel Chart. Currently the position of long-hyphens is not the same as in Excel chart.

I have attached the PDF/PNG output of Chart 1 and Chart 2 along with the Excel file. I have also attached the screenshots for the issues. attachments.zip (711.9 KB)

Can you please analyse this.

Thanks,
Neha

@Neha_Gautam

We need some more time to look into this issue. We will update you asap.

@Neha_Gautam

We have logged this issue in our database for improvement. We will investigate it and improve the chart output more if possible. Once, the issue is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-42372 - Position of Long-Hyphens is not same as Microsoft Excel