Code used is almost same as the sample code in your web site. Only change is the constructor for the FileSpecification. Instead of using setDescription() method to set the file type, it is done in the FileSpecification constructor itself.
This runs successfully and creates the portfolio document. When I open the portfolio using Adobe Reader, all the files are listed in there with the correct sizes as well. However, I am not able to open some of the files in the portfolio. If I change the order in which files are added to the collection, I am not able to open a different set of files.
Note that if I use the setDescription() method, I could open none of the files.
Appreciate your response on this issue as soon as possible as we won't be licensing this product if this feature does not work.
Code used:
import com.aspose.pdf.*;
public class PdfPortfolio
{
public static void main(String[] args) throws Exception
{
try
{
//read the input file
String inFile1 = "input1.pdf";
String inFile2 = "Netsuite licensing breakdown.xls";
String inFile3 = "IEEE Reference Architecture.doc";
String inFile4 = "EA Mind Map.jpg";
String outFile = "Portfolio_output.pdf";
//Instantiate Document Object
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
//Instantiate document Collection object
doc.setCollection(new com.aspose.pdf.Collection());
//Get Files to add to Portfolio
com.aspose.pdf.FileSpecification pdf1 = new com.aspose.pdf.FileSpecification(inFile1, "PDF File");
com.aspose.pdf.FileSpecification pdf2 = new com.aspose.pdf.FileSpecification(inFile2, "Excel File");
com.aspose.pdf.FileSpecification pdf3 = new com.aspose.pdf.FileSpecification(inFile3, "Word File");
com.aspose.pdf.FileSpecification pdf4 = new com.aspose.pdf.FileSpecification(inFile4, "Image File");
//Provide description of the files
//pdf1.setDescription("PDF File");
//pdf2.setDescription("Excel File");
//pdf3.setDescription("Word File");
//pdf4.setDescription("Image File");
//Add files to document collection
doc.getCollection().add(pdf1);
doc.getCollection().add(pdf2);
doc.getCollection().add(pdf3);
doc.getCollection().add(pdf4);
//Save Portfolio document
doc.save(outFile);
// Display result.
System.out.println("PDF portfolio created successfully!");
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
}
}