Bug Aspose Words since 11.11.0 version

Hi,


Following code does not work with 11.11.0 and 13.14.0 versions.
when It inserts another cell (for iteration) there is an exception (null pointer). It’s caused by red colored code.

If I comment/delete it, it’s ok. It runs.

This code used to work with 11.09.0 and previous AsposeWords versions.

for (int n = 0; n < cuantasEtiquetas; ++n) {

Cell celda = builder.insertCell();
builder.getCellFormat().setWidth(formatoEtiqueta.getAncho().divide(FACTOR_PUNTO_MM, 2, BigDecimal.ROUND_HALF_DOWN).doubleValue());
builder.getCellFormat().setLeftPadding(cero);
builder.getCellFormat().setRightPadding(cero);
builder.getCellFormat().setTopPadding(cero);
builder.getCellFormat().setBottomPadding(cero);
builder.getCellFormat().getBorders().setLineWidth(cero);
builder.getCellFormat().getBorders().setLineStyle(LineStyle.NONE);
celda.getChildNodes().get(0).getRange().delete();
for (Iterator it3 = docEtiqueta.getFirstSection().getBody().getChildNodes().iterator(); it3.hasNext():wink: {
Node nodo = it3.next();
celda.getChildNodes().add(documento.importNode(nodo, true));
}
}

I have to delete range because generating a cell it leaves a BELL character that add space/“line separator” like before nodes insertion.

Please help it’s urgent because I need to use last version of AsposeWords!!!

Hi Jerome,

Thanks for your inquiry.

Please create a simple application (for example a Java Console Application Project) that helps us reproduce the same exception on our end and attach it here for testing. Unfortunately, it is difficult to say what the problem is without the Document(s) and simplified application. We need your Document(s) and Simple Project to reproduce the problem. As soon as you get these pieces of information to us we'll start our investigation into your issue.

Best regards,

Hi,

File attachment is template DOCX:

Code:
try {
Document documento = new Document();
DocumentBuilder builder = new DocumentBuilder(documento);
builder.getPageSetup().setPaperSize(PaperSize.A4);
builder.startTable();
File f = new File(“template.docx”);
Document docEtiqueta = new Document(new FileInputStream(f));
for (int n = 0; n < 2; ++n) {
Cell celda = builder.insertCell();
celda.getChildNodes().get(0).getRange().delete();
for (Iterator it3 = docEtiqueta.getFirstSection().getBody().getChildNodes().iterator(); it3.hasNext():wink: {
Node nodo = it3.next();
celda.getChildNodes().add(documento.importNode(nodo, true));
}
}
builder.endRow();
builder.endTable();
File f2 = File.createTempFile(“ejemplo”, “.pdf”);
FileOutputStream fos = new FileOutputStream(f2);
PdfSaveOptions pso = new PdfSaveOptions();
pso.setSaveFormat(SaveFormat.PDF);
pso.setEmbedFullFonts(true);
pso.setJpegQuality(100);
documento.save(fos, pso);
} catch (Exception ex) {
ex.printStackTrace();
}

Next time I insert a cell, I get a NULL exception with builder.insertCell();
It works with 11.9.0 AsposeWords version. But I need 13.14.0 version!!!

Please help!

Hi Jerome,


Thanks for the additional information. In your case, you just need to move the DocumentBuilder cursor to a valid position in DOM before inserting a new Cell. Please see the following change.
for (int n = 0; n < 2; ++n)
{
builder.moveToDocumentEnd();
Cell celda = builder.insertCell();
celda.getChildNodes().get(0).getRange().delete();
for (Iterator<Node> it3 = docEtiqueta.getFirstSection().getBody().getChildNodes().iterator(); it3.hasNext(); )
{
Node nodo = it3.next();
celda.getChildNodes().add(documento.importNode(nodo, true));
}
}
I hope, this helps.

Best regards,

Thx for all!