Convert Microsoft Excel Spreadsheet to PDF in Java using Aspose.Cells Rest API has text paragraphs formatting issue

Hi all,

I have converted Excel to Pdf as following sample :
https://docs.aspose.cloud/display/cellscloud/Convert+Excel+Workbook+to+Different+File+Formats

In the pdf result, the paragraphs are spreading out but do not appear like that in excel template. I don’t understand why. Please show me how to fix it.

Thanks,
Chien

Hi Chien,

Thank you for contacting Aspose support.

We have evaluated your presented scenario by converting the provided spreadsheet with Aspose for Cloud service and Microsoft Excel application. We are not able to notice any problem with the Aspose’s generated PDF, moreover, the two PDF files (attached) look very similar. Due to this comparison, I think that the result produced by Aspose for Cloud service is correct. Please note, I have used the Aspose for Cloud Java SDK with following XML to evaluate this scenario. Please share the XML (preferably executable code segment) to look further into this matter.

XML


String xml = “” +
true” +
true” +
“Pdf” +
“”;

Hi Babar,

Thank you for your response. I’m using the PdfSaveOptions in Aspose for Cloud as following:


true
true
false
None
400
95
false
Pdf

And I have the result pdf as above (the spacing between paragraphs are not same as in original excel file). Please tell me what wrong with it.

Here is the extraction of my code (using Java + Aspose Cloud) :
+ Step 1 : Upload Excel file :

byte[] inputExcel = …

String uploadURI = Product.getBaseProductUri() + “/storage/file/”
+ uploadFileName;
String signUploadURI = com.saaspose.common.Utils.Sign(uploadURI);
String resultUpload = uploadFile(inputExcel, signUploadURI);


+ Step 2 : Save excel file into PDF on Aspose’s Server
StringBuilder xmlPdfOptions = new StringBuilder();
xmlPdfOptions .append("\n “);
xmlPdfOptions .append(”\n true");
xmlPdfOptions .append("\n true");
xmlPdfOptions .append("\n false");
xmlPdfOptions .append("\n None");

String strURIPdf = Product.getBaseProductUri() + “/cells/”
+ uploadFileName + “/saveAs?newfilename=” + pdfFileName;
String signedURISavePdf = com.saaspose.common.Utils.Sign(strURIPdf);
InputStream responseSave = com.saaspose.common.Utils.ProcessCommand(signedURISavePdf, “POST”, xmlPdfOptions .toString(),
“xml”);


+ Step 3 : Download result convert pdf

Thanks,
Chien

Hi Chien,


Thank you for sharing the XML settings for the PdfSaveOptions. I have reevaluated the scenario using your XML string, unfortunately, I am still not able to observe the problem. Please check the attachment for the resultant PDF. Please allow me some time to further investigate the scenario, and get back to you with updates in this regard.

Hi again,

We have evaluated the presented scenario again on two different machines with following piece of code, and were not able to replicate the problem so far. Could you please try the case with this code snippet on your side? Please note, the code is using some methods from the Aspose Cloud for Java SDK so you may give it a try in a new project and share the resultant PDF. We hope to isolate the difference in statements/configurations with this test therefore we request you to download the sample spreadsheet from this thread, upload it to the cloud storage manually (using Aspose for Cloud GUI) and execute the conversion.

Java

String infilename = “Calc-text.xlsx”;
String outfilename = “calc-text(JavaSDK).pdf”;

StringBuilder xmlPdfOptions = new StringBuilder();
xmlPdfOptions .append("\n “);
xmlPdfOptions .append(”\n true");
xmlPdfOptions .append("\n true");
xmlPdfOptions .append("\n false");
xmlPdfOptions .append("\n None");
xmlPdfOptions .append("\n 400");
xmlPdfOptions .append("\n 95");
xmlPdfOptions .append("\n false");
xmlPdfOptions .append("\n Pdf");
xmlPdfOptions .append("\n ");

String strURI = “http:[//api.aspose.com/v1.1/cells/"+infilename+"/saveAs?newfilename=](https://api.aspose.com/v1.1/cells/%22+infilename+%22/saveAs?newfilename=)” + outfilename;
String signedURI = Utils.sign(strURI);
Utils.processCommand(signedURI, “POST”, xmlPdfOptions.toString(), “xml”);
strURI = “http:[//api.aspose.com/v1.1/storage/file/](https://api.aspose.com/v1.1/storage/file/)” + outfilename;
signedURI = Utils.sign(strURI);
InputStream responseStream = Utils.processCommand(signedURI, “GET”);
Folder.saveStreamToFile(“D:/” + outfilename, responseStream);
responseStream.close();
System.out.println(“Done”);

Hi Chien,


I have tested the scenario in licensed mode as well in order to eliminate this possibility. Attached is the resultant PDF that shows the paragraph spacing correctly. Please give a try to the code shared in my previous response. In case you find the result correct with my provided snippet and not with yours then it would be appropriate that you should share a sample executable application along with its dependencies/libraries to look further into this matter.

Hi Babar,

Thank you for your help. I have tested it again and I realized that the result pdf would be wrong when I use the parameter &isAutoFitRows=true in converting PDF file from excel template (in Step 2) as following :

+ Step 2 : Save excel file into PDF on Aspose’s Server
StringBuilder xmlPdfOptions = new StringBuilder();
xmlPdfOptions .append("\n “);
xmlPdfOptions .append(”\n true");
xmlPdfOptions .append("\n true");
xmlPdfOptions .append("\n false");
xmlPdfOptions .append("\n None");

String strURIPdf = Product.getBaseProductUri() + “/cells/”
+ uploadFileName + “/saveAs?newfilename=” + pdfFileName;
strURIPdf += “&isAutoFitRows=true”;

String signedURISavePdf = com.saaspose.common.Utils.Sign(strURIPdf);

InputStream responseSave =
com.saaspose.common.Utils.ProcessCommand(signedURISavePdf, “POST”,
xmlPdfOptions .toString(),
“xml”);


Thanks,
Chien

Hi Chien,


Thank you for highlighting the difference in statements. You are right, I am able to replicate the problem while passing the isAutoFitRows as true. Please allow me some time to further check the case.

Hi again,


This is to update you that we have tried to workaround the presented scenario however, it seems to the problem of Aspose.Cells for Cloud service therefore a ticket with Id SAASCELLS-119 has been logged for correction purposes. Please allow us some time to further investigate the matter, and to provide the fix at earliest possible. In the meanwhile, we will keep you posted with updates in this regard.

We are sorry for the inconvenience.

Hi Chien,

This is to inform you that we have fixed the problem logged earlier as SAASCELLS-119. Please give this scenario another try on your side and let us know of your feedback.

Java

StringBuilder xmlPdfOptions = new StringBuilder();
xmlPdfOptions .append("\n “);
xmlPdfOptions .append(”\n true");
xmlPdfOptions .append("\n true");
xmlPdfOptions .append("\n false");
xmlPdfOptions .append("\n None");
xmlPdfOptions .append("\n 400");
xmlPdfOptions .append("\n 95");
xmlPdfOptions .append("\n false");
xmlPdfOptions .append("\n Pdf");
xmlPdfOptions .append("\n ");

//Convert the spreadsheet on storage
String strURI = “http:[//api.aspose.com/v1.1/cells/"+infilename+"/saveAs?newfilename=](https://api.aspose.com/v1.1/cells/%22+infilename+%22/saveAs?newfilename=)” + outfilename + “&isAutoFitRows=true”;
String signedURI = Utils.sign(strURI);
Utils.processCommand(signedURI, “POST”, xmlPdfOptions.toString(), “xml”);
//Download the converted file
strURI = “http:[//api.aspose.com/v1.1/storage/file/](https://api.aspose.com/v1.1/storage/file/)” + outfilename;
signedURI = Utils.sign(strURI);
InputStream responseStream = Utils.processCommand(signedURI, “GET”);
Folder.saveStreamToFile(“D:/” + outfilename, responseStream);
responseStream.close();

Hi Babar,

Thank you very much. I have tested it again and it’s OK now.

Best Regards,
Chien

Hi,


Thanks for your feedback.

Good to know that your issue is sorted out now. Feel free to write back if you have further comments and questions, we will be happy to assist you soon.

Thank you.

The issues you have found earlier (filed as SAASCELLS-119) have been fixed in this update and deployed to live service.


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