Hello,
I’m writing you because today I’ve tested new aspose-cells 8.5.0 and observed strange result:
1) I’ve prepared document on my PC, applying fonts which are missed on Server.
2) Then I’ve uploaded the document on server and performed ‘conversion’.
Test-doc and result are attached
Best regards
Hi Akane,
- Operating system version & architecture of your server where conversion is taking place.
- JDK type & version installed on the server.
- Does your server has the following fonts installed and are your setting the font location using the CellsHelper.setFontDir method at the start of your application?
- Alexandra Script
- MS PGothic
- MS Gothic
- Please provide the above mentioned fonts from the machine where you have created the spreadsheet.
- To what format are your converting the spreadsheet?
- Please provide a PDF generated on the server so we could get a hint about the font substitution process on the server. You may save the spreadsheet in PDF format using the Workbook.save method while passing SaveFormat.Pdf as second parameter.
Hello,
1. Doc was created on Win7 64, the conversion was performed on Linux x86_64
(as before with earlier releases)
2. java version "1.7.0_67"
3. No
4. MS fonts are commonly exist on any Win syst I suppose. Moreover I saw that tables was created with Colibri font
5. to PNG:
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.setWarningCallback(exWCallback);
imgOptions.setImageFormat(format);
imgOptions.setHorizontalResolution(dpi_Resolution);
imgOptions.setVerticalResolution(dpi_Resolution);
imgOptions.setOnePagePerSheet(false);
imgOptions.setPrintingPage(PrintingPageType.IGNORE_BLANK);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SheetRender sheetRender = new SheetRender(sheet, imgOptions);
sheetRender.toImage(pgIx, baos);
6. I’m a little confused by result. There are correct table at least for pdf file
The main thing why I wrote here is that I didn’t see so strange result with 8.4.x releases.
And yes, I know about font substitution. There are no applied in the document fonts on server, but we have another ones and as you see for simple cells it works.
Would you know something else?
Best regards.
Hi Akane,
Hi Akane,
Hello,
I’ve tested several times.
1) There no one fonts applied in original document on server where conversion is performed.
List of available fonts:
Trebuchet
Bookman Old Style
Wingdings
Times New Roman
Arial Narrow WGL
FBBlueMingL
Comic Sans
Verdana
CSongGB18030C-Light
Century Gothic
Book Antiqua
Corsiva
Symbol
Webdings
Century Schoolbook
Arial
Georgia
Courier New
MotoyaExMincho
Wingdings 3
Sorts
Tahoma
Wingdings 2
MSung HK Light
Impact
Lucida Sans
Lucida Bright
Lucida Sans Typewriter
No one MS font.
2) You can find Alexandra Script font in the internet Alexandra Script - Поиск в Google I don’t think that the problem occurs due to this font.
3) I didn’t change code:
public boolean convert() throws ConversionServiceException {So the steps where:
prepare();//There the license is loaded
// Set conversion start time
synchronized (ExcelToPNGConverter.class) {
ArrayList paths = new ArrayList();
paths.add(getFontPath());
if (javaHome != null && !javaHome.isEmpty()) {
paths.add(javaHome + “/lib/fonts/”);
}
CellsHelper.setFontDirs(paths);
}
Workbook book = null;
int sheetCount = 0;
String uploadedFile = formatUploadedFile(inputFileName);
try {
synchronized (ExcelToPNGConverter.class) {
book = new Workbook(uploadedFile, loadOptions);
sheetCount = book.getWorksheets().getCount();
}
}
catch (CellsException e) {
}
catch (Exception e) {
}
if (book.getSettings().isProtected()) {
handleException(…);
}
if (sheetCount > getPageLimit()) {
handleException(…);
}
// Track page numbers independent of sheet no.
int filePgNo = 0;
com.aspose.cells.Font font;
ImageOrPrintOptions imgOptions = getImageOrPrintOptions();
try {
for (int i = 0; i < sheetCount; i++) {
if (imgOptions.getOnePagePerSheet()) {
imgOptions.setOnePagePerSheet(false);
}
Worksheet sheet = book.getWorksheets().get(i);
if (sheet != null) {
Cells cells = sheet.getCells();
if (cells != null) {
cells.setDefaultRowHeightMatched(true);
}
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setPaperSize(PaperSizeType.PAPER_LEDGER); // 17 in. x 11 in.
pageSetup.setPrintHeadings(true);
pageSetup.setPrintGridlines(true);
pageSetup.setOrientation(PageOrientationType.LANDSCAPE);
pageSetup.setFitToPagesWide(1);
pageSetup.setFitToPagesTall(0);
pageSetup.setTopMargin(0.5);
pageSetup.setLeftMargin(0.5);
SheetRender sheetRender = new SheetRender(sheet, imgOptions);
int pgCount = sheetRender.getPageCount();
if (pgCount == 1) {
imgOptions.setOnePagePerSheet(true);
sheetRender = new SheetRender(sheet, imgOptions);
}
// Check if there are more than one page per sheet
if (pgCount > 1) {
for (int p = 0; p < pgCount; p++) {
saveImageToFile(filePgNo, p, sheetRender);
filePgNo++;
}
}
else {
saveImageToFile(filePgNo, -1, sheetRender);
filePgNo++;
}
}
}
}
catch (Exception e) {
handleException(…);
}
…
return true;
}
private ImageOrPrintOptions getImageOrPrintOptions() {
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.setImageFormat(ImageFormat.getPng());
imgOptions.setHorizontalResolution(dpi_Resolution);
imgOptions.setVerticalResolution(dpi_Resolution);
imgOptions.setOnePagePerSheet(false);
imgOptions.setPrintingPage(PrintingPageType.IGNORE_BLANK);
return imgOptions;
}
private void saveImageToFile(int sheetIx, int pgIx, SheetRender sheetRender) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
if (pgIx > 0) {
sheetRender.toImage(pgIx, baos);
}
else {
sheetRender.toImage(0, baos);
}
baos.close();
byte[] pngImageInBytes = baos.toByteArray();
String processFileName = formatProcessFile(sheetIx, PNG_EXTENSION);
writeToFile(processFileName, pngImageInBytes);
}
protected void writeToFile(String processFileName, byte[] imageInBytes) throws IOException {
OutputStream fos = null;
try {
fos = new FileOutputStream(processFileName);
if (fos != null) {
fos.write(imageInBytes);
}
}
catch (IOException e) {
throw e;
}
finally {
if (fos != null) {
fos.close();
}
}
}
1) cells 8.4. Building the project, deploying on Server, Uploading documents and converting. Results attached.
2) cells 8.5. Building the project, deploying on Server, Uploading documents and converting. Results attached.
Only aspose-cell.jar was changed. Font Dir is the same, the rest is the same.
If you suppose that I made mistake using the libs could you please help me to find out the mistake?
Thank you in advance
Hi Akane,
Hello,
Unfortunately I see the same result for 8.5.0.4 as for 8.5.0
Monotype.rar contains all server fonts + Alexandra (that is unavailable on server)
Test4.pdf - result for 8.4.0
Test5.pdf - result for 8.5.0
Test0.pdf - result for 8.5.0.4
code:
CellsHelper.setFontDirs(paths);
loadOptions = new LoadOptions(LoadFormat.AUTO);
Workbook book = null;
try {
book = new Workbook(uploadedFile, loadOptions);
book.save("/var/mcp/media/TestX.pdf", SaveFormat.PDF);
}
catch (Exception e1) {
}
Hi Akane,
Hi again,
Thank you. Looking forward for further information
BestRegards
The issues you have found earlier (filed as CELLSJAVA-41411) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hello,
Sorry for delay.
The last release was tested, and I don’t observe the problem anymore.
Thank you.
Hi,