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

Free Support Forum - aspose.com

Aspose Words performance

Hi,

We have bougth Aspose Words since 3 month now and we have found that Aspose Words merge mail has bad performance with word template with pictures.

Can you take a look please ?

Regards,

Julien

What do you need to try to resolve this issue ?

Hi Julien,

Thanks for your inquiry and sorry for the delayed response. Could you please attach your input Word document and complete code to reproduce the same problem on my side here for testing? I will investigate the issue on my side and provide you more information.

Best regards,

Hi

Thanks

You’ll find in attachment the template and the data source.

Here is the test code

public class Test {

    public static void main(String[] args){
        try{
            File licenseFile = new File("D:/projets/novanet/novanet/WEB-INF/licences/Aspose.Words.lic");
            License license = new License();
            license.setLicense(licenseFile.getAbsolutePath());
            //FontSettings.setFontsFolder("/usr/share/fonts/truetype", true);
            //Document lettreType
            Document lettreType = new Document("D:/cp_myauto.doc");
            //Document de fusion
            String documentFusionName = "D:/output.doc";
            //Création du dossier parent
            File parentFolder = new File(documentFusionName).getParentFile();
            if(!parentFolder.exists()) {
                parentFolder.mkdirs();
            }
            //Fusion du document
            Document dstDoc = (Document) lettreType.deepClone(true);
            File sdd = new File("D:/cp_myauto.txt");
            if(sdd.exists()){
                BufferedReader bufferedReader = new BufferedReader(new FileReader(sdd));
                String entetes = bufferedReader.readLine();
                String[] tabEntetes = entetes.split("","");
                tabEntetes[0] = tabEntetes[0].substring(1,tabEntetes[0].length());
                tabEntetes[tabEntetes.length-1] = tabEntetes[tabEntetes.length-1].substring(0,tabEntetes[tabEntetes.length-1].length()-1);
                String valeurs = bufferedReader.readLine();
                String[] tabValeurs = valeurs.split("","");
                tabValeurs[0] = tabValeurs[0].substring(1,tabValeurs[0].length());
                tabValeurs[tabValeurs.length-1] = tabValeurs[tabValeurs.length-1].substring(0,tabValeurs[tabValeurs.length-1].length()-1);
                java.sql.ResultSet resultSet = createCachedRowSet(tabEntetes);
                addRow(resultSet, tabValeurs);
                com.aspose.words.DataTable table = new com.aspose.words.DataTable(resultSet, "Test");
                bufferedReader.close();
                dstDoc.getMailMerge().execute(table);
                dstDoc.save(documentFusionName);
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    private static ResultSet createCachedRowSet(String[] columnNames) throws Exception
    {
        RowSetMetaDataImpl metaData = new RowSetMetaDataImpl();
        metaData.setColumnCount(columnNames.length);
        for (int i = 0; i < columnNames.length; i++)
        {
            metaData.setColumnName(i + 1, columnNames[i]);
            // metaData.setColumnType(i + 1, java.sql.Types.VARCHAR);
        }
        CachedRowSetImpl rowSet = new CachedRowSetImpl();
        rowSet.setMetaData(metaData);
        return rowSet;
    }

    private static void addRow(ResultSet resultSet, String[] values) throws Exception
    {
        resultSet.moveToInsertRow();
        for (int i = 0; i < values.length; i++)
            resultSet.updateString(i + 1, values[i]);
        resultSet.insertRow();
        resultSet.moveToCurrentRow();
        resultSet.last();
    }
}

Hi Julien,

Thanks for the additional information.

The presence of PAGE field in your template document causes Aspose.Words to build page layout of the document. The MailMerge.Execute method internally calls UpdateFields method which in turn updates all the fields in the mail-merged document including the PAGE field. However, please note that Aspose.Words needs to format a document into pages to be able to calculate the values for page number related fields. This up-to-date page layout information is also required for a correct rendering of the document to fixed-page formats. The process of rebuilding the page layout of the document takes an additional amount of time. This seems to be an expected behaviour. If we can help you with anything else, please feel free to ask.

Best regards,

Thanks for you answer but i can’t understand, what is the PAGE field ? This is the cause of long time processing ?

Regards,

Julien

Hi Julien,

Thanks for your inquiry. You can find an occurrence of PAGE field at the bottom of first page inside the footer area. This PAGE field is used to insert the number of the current page. The PAGE and NUMPAGES fields are page-layout related fields which cause Aspose.Words to build the document layout. Depending on the complexity of document, the process of building the document layout may take an additional amount of time. Please let me know if I can be of any further assistance.

Best regards,

Ok all clear !

But my question is, do Aspose will be perform this kind of mail merge quicly one day ?

Regards,

Julien

Hi Julien,

Thanks for your inquiry. We always strive to fix some performance issues in cases that are suggested considerably slow. Most of our customers are happy with performance of Aspose.Words for Java and those very slow cases are rare. Please let me know if I can be of any further assistance.

Best regards,