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() {
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,
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() {
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,
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));
}
}
Thx for all!