Free Support Forum -

Supporting the pdf and excel template using Aspose Product

We have the license for Aspose.cell (java) and we are using it in our project to create the excel files programmatically. Application is in uat and results are impressive so far.

Now we have a new requirement where we need to be able to define the templates in Excel and Pdf. Module should be able to take the template and the data (name/value pair) as parameter and do the simple replacement. All code is java based. We have tried the followign so far:

Create the simple xls file with place holder $Variable1$, $Variable2$ and at runtime take the xls and replace place holders with values coming in. It seems to work for the Excel. Initial idea was to just do it for Excel and use the Aspose.pdf ( to converted the generated Excel to Pdf. Pdf coming out is no where close to what we were expecting, as excel is pretty complex with images and lot of formatting. We would like to create the separate template for both pdf and excel, and modify them using the Aspose.pdf and Aspose.cell. We have the following questions.

1. Is this approach reasonable or it is totally off base.

2. Is it the appropriate use of Aspose product or we should be looking at something else. I f Aspose can support it, which product we need.

3. How do I create the pdf template in first place to be manipulated using the Aspose.pdf

4. Runtime environment is linux, template can be created on pc using the excel etc.

If you need more information please let us know.

We would appreciate any ideas.


Thank you for considering Aspose.

Since you have already created your application based on Aspose.Cells, I think the best way is to convert the xsl into pdf using Aspose.Cells + Aspose.Pdf. Currently Xsl2Pdf java version is not mature enough and we are still working on it. We planed to publish a new version of Aspose.Pdf for Java late this month or early next month. Can you please provide the xsl and let us test it?

Thanks for the quick reply. We tried to convert the xsl to pdf, but results were not acceptable. We have very precise requirnment about formating. I am attaching the xsl and the converted pdf, as you can see that pdf generated is not a tall useful. I have change the logos and images, but you will get the idea. I think best way to do it would be to create the separate template for pdf, may be painful but that way we will get very precise result.

I can’t find your attachment.

I have attached the files, I just removed the logo from the aspose generated excel file. If I replace the logo, pdf generation throws the exception.

com.aspose.pdf.exception.AsposeBaseException: error in section
at com.aspose.pdf.elements.Section.a(Unknown Source)
at com.aspose.pdf.elements.Pdf.a(Unknown Source)
at com.aspose.pdf.elements.Pdf.a(Unknown Source)
at Source)
at com.lehman.cvm.sts.util.ExcelToPdf.process(

Anyway, I see the following issues.

1. Images/Logo do not move over to the pdf file.

2. Formatting is messed up.

3. Part of the row moves over to the next page.

Looks like, I can attach only one file, so excel file is here.

Can any other user, give some ideas how they are doing templating in pdf.

We need some time to check your files. As for Pdf templating, basically you need to write the template xml by hand. Currtly the Word2Pdf (.Net version) feature is relative mature so you can also write a Word document and get the Xml using Aspose.Words:

Document doc = new Document(“template.doc”);

Ususlly you also need to adjust the resulting xml by hand.

Thanks for the quick reply. Couple of questions:

1. We have to use java, as application runs on linux. Template can be created on pc using words, but applications has to user Aspose.word for java.

2. When I import word doc to xml what happens to the images and other embedded objects.


1. You can create your template once at your PC and use it in your Java application later. I assume your template is static and you don’t need to create it frequently.

2. When importing word doc to xml, the images will be saved into the disk.

I downloaded the Aspose.Words for Java ( to try it out, using the simple program

String directory = "H:\\work\\stmtGen\\word\\";
String inputFile = directory + "input.doc";
String xmlFile = directory + "input.xml";
String outputFile=directory + "output.xml";
InputStream in = new BufferedInputStream(new FileInputStream(inputFile));
Document doc = new Document(in);, FileFormatType.ASPOSE_PDF);
Pdf pdf = Pdf.bindXML(new FileInputStream(xmlFile));
//Create the PDF document by calling its Save method FileOutputStream(outputFile));

it fails with the following exceptions while executing the

java.lang.UnsupportedOperationException: Unsupported SaveFormat: 9
at Source)

Is this feature supported in the java versions, I am looking at the url

Am I using the correct version of, is the support for FileFormatType.ASPOSE_PDF, expected shortly in java version. One solution could be to use Word.Net to get the xml file, but it will not be possible on our end, as we cannot run any .Net code.

Is there any pur java solution possible after generating the doc file ?


Please try to create the XML template for PDF manualy. Or if you want you can create the template in Word and give us the file and we will run it through Aspose.Words for .NET and give you the XML that you can use.


Thanks for the quick response.

Actually we have quite a few templates (50-70) and they are routinely added. We need support staff to be able to add them using word and start using them automatically.

Could you give us some advice how to do it automatically, even if we have to use some other product in between.

Word2Pdf is not supported in Java version currently. It is only supported in .Net version. If your templates are routinely added, I have no good idea to generate them automatically. You can only use Aspose.Cells for Java to generate the Xml and modify it by hand.

Could you tell us when support for Word2Pdf will be added to the java version. If there are no dates, just let us know whenever it is added.

Thanks for your help.

Word2Pdf will be supported by Aspose.Words in Java version. Aspose.Words will save the document into Pdf directly and will not use Xml.

BTW, we tested your xsl with the current version of Aspose.Pdf (which will be published in one or two weeks). The resulting Pdf is attached. We will soon modify the table border to make it have no border as default.

We have modified the code to make table has no border as default. Please see the new PDF generated.