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

Free Support Forum - aspose.com

We need to convert csv file to pdf

we need to convert csv file to pdf.
There are french accent characters and chinese characters in csv file.
The output pdf is correct when csv is encoded in UTF-8.
But the output pdf is not correct when csv is encoded in other format.
I think I should set the decode format when I read the csv
Could you give the guide for using the function aspose.cells.Encoding.getEncoding(“ISO-8859-1”)?
Can I detect the encoding format of csv file?
So I can read the csv in appropriate format instead of hard coding the decode format.

Second issue, The pdf file can not show the right content when the application runs on Linux.
I think it is the problem of missing required font on Linux.
I want to user CellsHelper.setFontDirs(ArrayList) to set multiple font folders.
But I can not find any example for that.
My general question is where I can find the example code if I do not know to use certain function.

Hi,


Thanks for the template files and details.

1) See the following sample code segment for your reference, you may update it accordingly:
e.g
Sample code:

TxtLoadOptions options = new TxtLoadOptions(LoadFormat.CSV);
options.setSeparator(’,’);
options.setEncoding(Encoding.getEncoding(“ISO-8859-1”));
Workbook workbook = new Workbook(stringFilePath, options);


2) Please see the documents in the section for your reference:
http://www.aspose.com/docs/display/cellsjava/Aspose.Cells+Font+Usage

Hope, this helps a bit.

Thank you.

Thank you very much for your reply.
I need more details about Encoding.getEncoding(String encodingFormat)
How many option we have for the parameter encodingFormat?
Could you give me a list?
And is it possible to get encoding format by any method of Aspose.cells when we load an csv file?

The CellsHelper.setFontDirs method accepts an ArrayList so you may specify many font directories using this approach.


Could you give me the sample code for CellsHelper.setFontDirs method?
I need similar sample codes like these following.
The following sample code that I found another post for Aspose.word
// Retrieve the array of environment-dependent font sources that are searched by default.
// For example this will contain a “Windows\Fonts” source on a Windows machines.
// We add this array to a new ArrayList to make adding or removing font entries much easier.
ArrayList fontSources = new ArrayList(Arrays.asList(FontSettings.getFontsSources()));
// Add a new folder source which will instruct Aspose.Words to search the following folder for fonts.
com.aspose.words.FolderFontSource folderFontSource = new com.aspose.words.FolderFontSource(fontPath, true);
// Add the custom folder which contains our fonts to the list of existing font sources.
fontSources.add(folderFontSource);
// Convert the Arraylist of source back into a primitive array of FontSource objects.
com.aspose.words.FontSourceBase[] updatedFontSources = (com.aspose.words.FontSourceBase[])fontSources.toArray(new com.aspose.words.FontSourceBase[fontSources.size()]);
// Apply the new set of font sources to use.
FontSettings.setFontsSources(updatedFontSources);

Also need to have the sample code to set multiple font folder for Aspose.Slides , Aspose.Pdf

Hi again,

billzhang:
The CellsHelper.setFontDirs method accepts an ArrayList so you may specify many font directories using this approach.


Could you give me the sample code for CellsHelper.setFontDirs method?
I need similar sample codes like these following.
The following sample code that I found another post for Aspose.word
// Retrieve the array of environment-dependent font sources that are searched by default.
// For example this will contain a "Windows\Fonts\" source on a Windows machines.
// We add this array to a new ArrayList to make adding or removing font entries much easier.
ArrayList fontSources = new ArrayList(Arrays.asList(FontSettings.getFontsSources()));
// Add a new folder source which will instruct Aspose.Words to search the following folder for fonts.
com.aspose.words.FolderFontSource folderFontSource = new com.aspose.words.FolderFontSource(fontPath, true);
// Add the custom folder which contains our fonts to the list of existing font sources.
fontSources.add(folderFontSource);
// Convert the Arraylist of source back into a primitive array of FontSource objects.
com.aspose.words.FontSourceBase[] updatedFontSources = (com.aspose.words.FontSourceBase[])fontSources.toArray(new com.aspose.words.FontSourceBase[fontSources.size()]);
// Apply the new set of font sources to use.
FontSettings.setFontsSources(updatedFontSources);


Please check the following piece of code demonstrating the usage of CellsHelper.setFontDir & CellsHelper.setFontDirs methods.

Java

//Add one directory containing fonts of type TTC & TTF
CellsHelper.setFontDir("D:/FontDir");
//Add multiple directories containing fonts of type TTC & TTF
ArrayList dirs = new ArrayList();
dirs.add("D:/FontDir1");
dirs.add("D:/FontDir2");
CellsHelper.setFontDirs(dirs);

Please note, the Aspose.Cells for Java API will still check the operating system's default directories for the required fonts. If you wish to restrict the API not to check operating system's default font directories then use the JVM arguments as -DAspose.Cells.FontDirExc="YourFontDir" or set the same in code using the System.setProperty as System.setProperty("Aspose.Cells.FontDirExc", "FontDirSet")
Hi,

billzhang:
Thank you very much for your reply.
I need more details about Encoding.getEncoding(String encodingFormat)
How many option we have for the parameter encodingFormat?
Could you give me a list?

We are checking if we can provide a list of all supported encoding charsets. Once we have further updates in this regard, we will let you know here.

billzhang:

And is it possible to get encoding format by any method of Aspose.cells when we load an csv file?

I am afraid, it is not possible to auto detect the encoding of a CSV therefore you have to explicitly set the encoding using the TxtLoadOptions class as demonstrated earlier in this thread.
Hi,

billzhang:
Also need to have the sample code to set multiple font folder for Aspose.Slides , Aspose.Pdf

I have created a post in Aspose.Total support forum on your behalf. You may follow-up on this thread for your concerns as quoted above. Please note, we have separate support forum for each Aspose product therefore it is advised to post the concerns in relevant forums for timely responses. However, if an inquiry involves more than one Aspose product, it should be posted in Aspose.Total support forum for broader coverage.