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

Free Support Forum - aspose.com

URGENT : Issue reported by one of our customers: Words appear to be concatenated in PDF/Image output of excel chart

URGENT : Issue reported by one of our customers

Hi,
I am using Aspose.cells v8.5.2.4
On converting an Excel chart to PDF/image the space between words decreases & words appear concatenated.
For example, in the attached excel doc, for charts 'Chart 1' & 'Chart 2' in the title, two words consumption and of appear to be concatenated in PDF & image outputs .It seems space between "consumption" and "of " has decreased in outputs.


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


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 1");
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 1.png", imageOrPrintOptions);
}

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);
}




--Jaspreet

Hi Jaspreet,

Thanks for your posting and considering Aspose.Cells.

We have checked your images and the output pdfs and did not find any spacing issue between the words two words consumption and of.

Please highlight your issues with red circles so that we could see it precisely and replicate it at our end. We will look into it and help you asap.

Hi,

I have attached the screenshot of space comparison between “comparison” & “of” w.r.t. excel doc & PDF output of Chart 2.

–Jaspreet

Hi,

Thanks for your screenshot and using Aspose.Cells.

We were able to see this issue but it is very minute and unnoticeable. However, we will look into it and see if it can be improved. We have therefore logged this issue in our database for investigation. Once, the issue is fixed or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-41494 - Words appear to be concatenated in PDF/Image output of excel chart

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,

The ticket attached to this thread is currently unresolved. As soon as we receive any updates regarding the aforementioned ticket, we will post here for your reference so you could keep checking this thread for updates. However, we strongly suggest you to create a new thread with problem description and supporting documents so we could evaluate the problem separately and log separate ticket(s), 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-41494) 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 after using chart.toPdf() method. The words consumption and of appear concatenated.

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.

Can you please analyse this issue.

Hi Jaspreet,


Thank you for the screenshot highlighting the problematic area.

We believe there is very small difference in terms of the space between the two words when compared the Aspose.Cells for Java 8.6.2.4 generated PDF with original chart. Anyway, we have reopened the ticket CELLSJAVA-41494 and have requested the concerned member of the product team to review this scenario. As soon as we receive further updates, we will post here for your kind reference.

Hi,

Thanks for using Aspose.Cells.

We have fixed the issue CELLSJAVA-41494.

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

Hello,


Thanks for your reply.

I am using Aspose.Cells v8.6.3 to generate the PDF and Image outputs of Chart 1 and Chart 2 in the attached Excel file.

The issue is resolved for PDF output, but for Images, the Issue still exists. The words consumption and of appear concatenated in the Image output.

I have attached the PNGs for Chart 1 and Chart 2. I have attached screenshots comparing the PNGs with the actual Charts.

Can you please analyse this issue.

Thanks,
Jaspreet

Hi,


Thanks for the screen shots and some details.

I have evaluated your scenario/ case with our latest version v8.6.3 using your template file (you provided in the first post in the thread) and following sample code, it works fine and I could not find your mentioned issue in the output images. The output images (attached) for both charts are rendered fine.
e.g
Sample code:

Workbook workbook = new Workbook(“72272_bad_looking_chart±+Copy.xlsx”);
WorksheetCollection ws = workbook.getWorksheets();
Chart chart = ws.get(0).getCharts().get(“Chart 1”);
//Chart chart = ws.get(0).getCharts().get(“Chart 2”);
chart.toImage(“out1Chart1.png”);

Please see the output images for the charts and let us know if you still have any concerns.

Thank you.

Hi,


I have tested this again with 8.7.0.4. However, the said spacing difference is easily observable.
Attached here is the PNG and PDF of the chart generated using Aspose.
In PDF, it is correct however in PNG the spacing between the words “consumption” and “of” is less than in the actual chart or its PDF.
You will easily be able to observe it after opening both (PDF & PNG) and have side by side view of both.

Attached here are the PDF and PNG files generated using Aspose for your reference.

Thanks,
Neha

Hi,


Thanks for the screenshot and details.

I have evaluated your scenario/ case with our latest version v8.7.0.4 using your template file (you provided in the first post in the thread) and following sample code, it works fine on my end and I could not find your mentioned issue in the output images. The output images (attached) for both charts are rendered fine.
e.g
Sample code:

Workbook workbook = new Workbook(“72272_bad_looking_chart±+Copy.xlsx”);
WorksheetCollection ws = workbook.getWorksheets();
Chart chart = ws.get(0).getCharts().get(“Chart 1”);
//Chart chart = ws.get(0).getCharts().get(“Chart 2”);
chart.toImage(“out1Chart1_new.png”);

Please see the output images for the charts and let us know if you still have any concerns. Also, try the code segment above to get the results as per my attached screenshots.

If you still find the issue, kindly do paste your sample code (runnable) to reproduce the issue, we will check it soon.

Thank you.