I am trying to create a java action that can take in a .xlsx FileDocument, convert it to a string in .csv format (uses commas and\n for the cells and rows) and then convert this string to a .pdf.
// Input the .xlsx FileDocument object
InputStream inputStream = Core.getFileDocumentContent(getContext(), __XLSXDocumentToClone);
// This extra method just reads the .xlsx and puts it into a .csv format string.
String inputString = readXLSXFile(inputStream);
// Write the string to a stream
InputStream testStream = new ByteArrayInputStream(inputString.getBytes("UTF-8"));
// Aspose.cells way of creating a workbook and its options
TxtLoadOptions options = new TxtLoadOptions(LoadFormat.CSV);
options.setSeparator(',');
// Create the workbook using the stream and the options given
Workbook workbook = new Workbook(testStream, options);
// Try to change the format to .pdf through saving options
ByteArrayOutputStream stream = new ByteArrayOutputStream();
workbook.save(stream,SaveFormat.PDF);
// Save the new .pdf stream to another FileDocument object
Core.storeFileDocumentContent(getContext(), this.EmailAttachmentParameter1.getMendixObject(), new ByteArrayInputStream(stream.toByteArray()));
return true;
this works to an extent, but the .pdf file that is saved will then only be in XML format, pdf readers for some reason can't understand it.
Any help would be great.*