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

Free Support Forum - aspose.com

Evaluation: Solicit information to ASPOS FOR java

Hi,


We are looking to develop very domain specific Document Assembly/Merging service specifically DOCX template merging with JSON data and we plan to evaluate DOCX4J also. In long run we also want to implement template support for conditional expression, repeating element etc.

I would like to start conversation with technical/product manager,
Please advise on next steps

Hi,


Thanks for your interest and yes you can meet these requirements by using Aspose.Words for Java. Please refer to the following section of documentation.

Mail Merge and Reporting

Best regards,

Thanks Hafeez.


Appreciate your prompt reply.

I have following not technical questions, followed by technical questions,
  • What is your licensing and support model ?

Technical questions :

  • Do you have sample code in Java showing following features ?
  1. Conditional replacement of content based on passed data Data passed is JSON formatted
  2. Repeating and nested data structure ( Read table within table)
  3. Why ASPOS for Java is better that DOX4J ?
  4. Some performance of conversion…
Rajan

Hi Hafeez,


I would also like to add if template is created with with out Mail Merge feature, e.g I create a document in docx and simply specify

following syntax

<< Text to be replaced >> ASPOS for java should be able to handle it using “search and replace” is that correct ?

If you have sample, please provide pointer to it showing above mentioned example.
Thanks,

Rajan
Hi Rajan,

Thanks for your inquiry.
rajanbhatt:
I would also like to add if template is created with with out Mail Merge feature, e.g I create a document in docx and simply specify

following syntax

<> ASPOS for java should be able to handle it using "search and replace" is that correct ?

If you have sample, please provide pointer to it showing above mentioned example.
Thanks,

Please try using the following code (before executing mail merge) to replace plain tags such as <> with real merge fields using Aspose.Words for Java. .
String templateText = "Some text: <>";
ByteArrayInputStream bais = new ByteArrayInputStream(templateText.getBytes());
Document doc = new Document(bais);
bais.close();

doc.getRange().replace(Pattern.compile("<>"), new ReplaceEvaluatorFindAndInsertMergefield(), false);

doc.save("D:\\temp\\out.docx");

static class ReplaceEvaluatorFindAndInsertMergefield implements IReplacingCallback {

public int replacing(ReplacingArgs e) throws Exception {
Node currentNode = e.getMatchNode();

// The first (and may be the only) run can contain text before the match,
// in this case it is necessary to split the run.
if (e.getMatchOffset() > 0)
currentNode = SplitRun((Run) currentNode, e.getMatchOffset());

// This array is used to store all nodes of the match for further removing.
ArrayList runs = new ArrayList();

// Find all runs that contain parts of the match string.
int remainingLength = e.getMatch().group(0).length();
while (
(remainingLength > 0) &&
(currentNode != null) &&
(currentNode.getText().length() <= remainingLength)) {
runs.add(currentNode);
remainingLength = remainingLength - currentNode.getText().length();

// Select the next Run node.
// Have to loop because there could be other nodes such as BookmarkStart etc.
do {
currentNode = currentNode.getNextSibling();
}
while ((currentNode != null) && (currentNode.getNodeType() != NodeType.RUN));
}

// Split the last run that contains the match if there is any text left.
if ((currentNode != null) && (remainingLength > 0)) {
SplitRun((Run) currentNode, remainingLength);
runs.add(currentNode);
}


DocumentBuilder builder = new DocumentBuilder((Document) e.getMatchNode().getDocument());
builder.moveTo((Run) runs.get(runs.size() - 1));
builder.insertField("MERGEFIELD \"" +
e.getMatch().group(0).replace("<<", "").replace(">>","").trim() +
"\"", null);

//Now remove all runs in the sequence.
for (Run run : (Iterable) runs)
run.remove();

return ReplaceAction.SKIP;
}
}

private static Run SplitRun(Run run, int position) throws Exception {
Run afterRun = (Run) run.deepClone(true);
afterRun.setText(run.getText().substring(position));
run.setText(run.getText().substring(0, position));
run.getParentNode().insertAfter(afterRun, run);
return afterRun;
}

Hope, this helps.

Best regards,
Hi Rajan,

Thanks for your inquiry.
rajanbhatt:
I have following not technical questions, followed by technical questions,
  • What is your licensing and support model ?
Please contact our sales team via Aspose.Purchase forum.

rajanbhatt:
Technical questions :
  • Do you have sample code in Java showing following features ?
  1. Conditional replacement of content based on passed data Data passed is JSON formatted
  2. Repeating and nested data structure ( Read table within table)
  3. Why ASPOS for Java is better that DOX4J ?
  4. Some performance of conversion..

1 - Please check: How to Apply Custom Formatting during Mail Merge and Insert Checkboxes, HTML or Images During Mail Merge

2 - Please check: Nested Mail Merge Regions

3 - You might get an idea from Why not Automation article

4 - Generally, the processing time and memory usage fully depend on your documents and their complexity. Please note that the process of converting Word document to fixed-page formats such as PDF/XPS or images is not linear; it may take a minute to render one page and may take a few seconds to render 100 pages. Please also note that there is no size limit of document you can generate using Aspose.Words. The only limit is the amount of RAM available on your side.

Hope, this helps.

Best regards,