Free Support Forum - aspose.com

Conversion of docx and xlsx files into pdf

I tried to convert the docx and xlsx files into pdf using ASPOSE + SNOWBOUND.

Results with docx:

With one page document it worked fine

With multi page document, in the resultant pdf I am getting only the first page, remaining all are missing.

Results with xlsx:

Its not working for any of the files. Not even getting the output pdf file.

Kindly let me know how to resolve this issue.

Attacing the source code that we had used to convert:

import Snow.Snowbnd;
import Snow.Defines;

public class SimpleConvert
{
public static void Convert( String input , String output, String extension,
int format , boolean doSplit )
{
try{
Snowbnd s = new Snowbnd();

int totalPageCount = 0;
String absoluteOutput = null;

/* used to check return values from library */
int stat = ErrorCodes.OUT_OF_MEMORY;

/* use Snowbound to determine how many pages exist in input file */
/* FIXME: this should be wrapped in try/catch */
totalPageCount = s.IMGLOW_get_pages(input);
/* print out some setup information before processing */
System.out.println("Processing File: " + input);
System.out.println("Processing format: " + format);
System.out.println("Converting To: " + FormatHash.getFormatName(format));
System.out.println("Total page: "+totalPageCount);
totalPageCount=2;

if( doSplit ) {
System.out.println("Splitting out individual pages");
}
else if( totalPageCount > 1 )
{
System.out.println("Saving as multipage document");
if( !FormatHash.isValidFormatMultipage(format)) {
System.out.println("WARNING: " +
FormatHash.getFormatName(format) +
" may not be a valid multipage format!");
}
}

for( int currentPage = 0 ; currentPage < totalPageCount ; currentPage++ ) {
System.out.println("Processing Page: " + currentPage);

stat = s.IMG_decompress_bitmap(input, currentPage);

/* verify no errors occured while decompressing */
if( stat > ErrorCodes.OUT_OF_MEMORY ) {
System.out.println(" IMG_decompress_bitmap(): " + stat);

if( doSplit ) {
/* create unique file name based on page number */
absoluteOutput = output + "_" + currentPage + "_" + extension;
} else {
/* if format is a valid multipage format, Snowbound will append to existing data */
/* if format is a single page format, Snowbound will overwrite existing data */





absoluteOutput = output + extension;
}




//Surendar
// int dpi = s.getXdpi();
// int width = s.getWidth();
// int height = s.getHeight();
//
// int x_pt_size;
// int y_pt_size;
// System.out.println("dpi"+dpi);
// System.out.println("width"+width);
// System.out.println("height"+height);
// x_pt_size = width * 72 / 100;
// y_pt_size = height * 92 / 100;

Snowbnd sb2 = new Snowbnd(s.getWidth(), (int) (s.getWidth() * 11 / 8.5), 1);
stat = sb2.IMG_merge_block(s,0,0,0);
stat = sb2.IMG_save_bitmap(absoluteOutput, format);
//stat=s.IMGLOW_set_pdf_output(x_pt_size,y_pt_size);
//stat=s.IMG_save_bitmap(absoluteOutput, format);

//Surendar



//stat = s.IMG_save_bitmap(absoluteOutput, format); //Surendar

if( stat == ErrorCodes.PIXEL_DEPTH_UNSUPPORTED ) {
System.out.println(" IMG_save_bitmap(): " + stat);
System.out.println(" IMG_save_bitmap(): " + ErrorCodes.getErrorMessage(stat));
System.out.println(" Dropping pixel depth.");
stat = s.IMG_diffusion_mono();
System.out.println(" IMG_diffusion_mono(): " + stat);
stat = s.IMG_save_bitmap(absoluteOutput, format);
}

/* If successful, IMG_save_bitmap() returns the cumulative number of bytes written out */
System.out.println(" IMG_save_bitmap(): " + stat);
}
/* error on decompression, display message */
else {
System.out.println(" IMG_decompress_bitmap(): " + stat);
System.out.println(" IMG_save_bitmap(): " + ErrorCodes.getErrorMessage(stat));
}
}
}catch(Exception e){
e.printStackTrace();

}
}

public static void main( String args[] ) {
boolean errorParsing = false;

/* hashtable represents formats supported for writing */
FormatHash.init();

/* these defaults can be overriden by user input */
//int formatValue = Defines.TIFF_JPEG;
//String formatExtension = null;
//String formatExtension = FormatHash.getFormatExtension(formatValue);
String input = null;
String output = null;
boolean doSplit = false;

/* parse the input arguments */

/* do the actual conversion if the arguments are valid */
//C:\poller\Backup of failed files
String path = "C:\\Documents and Settings\\adcxn2j\\Desktop\\Performance Files\\2page_plain_txt.docx";
//String path = "C:\\Documents and Settings\\adcxn2j\\Desktop\\2009-11-24\\bart\\a";
String out = "C:\\Documents and Settings\\adcxn2j\\Desktop\\Performance Files\\2page_plain_txt";
if( !errorParsing )
Convert( path, out, ".pdf", 59, false);

}


}

Attaching the file that I had used to test:

I had added the snowbound jar and the aspose jar in the location where it required.

Hi,

surendar:
Results with xlsx:

Its not working for any of the files. Not even getting the output pdf file.

Kindly let me know how to resolve this issue.


I am from Aspose.Cells for Java team.

Please see the document on how to convert Excel file to PDF document using the API for your reference:
http://www.aspose.com/documentation/java-components/aspose.cells-for-java/converting-to-pdf-files.html

Make sure that you are using the latest versions of Aspose.Cells for Java and Aspose.Pdf for Java. Please try the conversion and let us know about it.

If yous still find the issue, kindly post your input excel and output pdf files here, we will check your issue soon.


Thank you.