Using Cells for Text to PDF conversion

It seems that since we updated our version of Cells to the latest, we can no longer use cells to do text to pdf conversion. Is this a known issue?

Hi,

Kindly post your text file here, we will check your issue soon.

Thank you.

Hi,

Please try the attached latest version v5.1.4.5. I have tested with it and it works fine.

Here is my sample code:
Workbook wb = new Workbook(“e:\test\test.csv”);
wb.Save(“e:\test\out__test.pdf”);


I have also attached the output PDF file here.

Thank you.

I get “Cannot find central directory”

Hi,

Please use the latest version/fix v5.1.4.5 that I attached in my last reply. I have already tested with my sample code (pasted in my previous reply), it works absolutely fine as you can see my attached file “out__test.pdf”.

Thank you.

Works when the new workbook is created from a file. Not when it is created from a Stream.

I just tested with the 5.1.2.0 dll I was using and the same thing is true. Works with a string to a file path, not with a stream.

Hi,

Please try the following sample code, it works fine:

MemoryStream ms = new MemoryStream(File.ReadAllBytes(“e:\test\test.csv”));
LoadOptions loadOptions = new LoadOptions(LoadFormat.CSV);
Workbook wb = new Workbook(ms,loadOptions);
wb.Save(“e:\test\out__test.pdf”);


Thank you.

Yes, I discovered that already. But we never had to specify a load format before from a stream. What happened?

Hi,

I am afraid, we cannot support: Workbook workbook = new Workbook(stream) for CSV/TEXT files to load a csv/text file from stream without specifying LoadOptions (with format type). I try to explain you the reason here. Suppose if we support it, then how could we come to know that data in the file i.e. “test,test…” is spiltted by ‘,’ and not by ‘t’ character. This is just an example, we cannot detect the separators accurately in the csv or text files, so logically it is not possible to load it from streams without knowing its format type or other attributes etc. I think you may use CellsHelper.DetectLoadFormat (static) method, and if it returns “Unknown”, then surely it is either a csv or text file. Cosequently you have to provide a specific format for it.

Here is an example:
MemoryStream ms = new MemoryStream(File.ReadAllBytes(“e:\test\test.csv”));
LoadFormat lf = CellsHelper.DetectLoadFormat(ms);
Workbook workbook = null;
if(lf.ToString() == “Unknown”)
{

LoadOptions loadOptions = new LoadOptions(LoadFormat.CSV);
workbook = new Workbook(ms,loadOptions);
}
else{

workbook = new Workbook(ms);
}

workbook.Save(“e:\test\output.pdf”);


Thanks for your understanding!