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

Free Support Forum - aspose.com

com.aspose.words.VerticalAlignment values swapped?

I’m seeing behavior that suggests the integer values defined by com.aspose.words.VerticalAlignment are not matching with the correct behavior. Specifically:

com.aspose.words.VerticalAlignment.BOTTOM actually produces “TOP” alignment
com.aspose.words.VerticalAlignment.TOP actually produces “CENTER” alignment
com.aspose.words.VerticalAlignment.CENTER actually produces “BOTTOM” alignment

We’re using the latest version of Aspose.Words for Java as of summer 2010 (sorry I can’t find an actual version number).

Dear Customer,

Thank you for your request.

I have created simple code to try to reproduce the issue described by you with the latest release Aspose.Words for Java 4.0.3 from 10/14/2010. The issue has not been reproduced.

May I ask you to provide me with the following information:

  1. the version of jdk you use
  2. code fragment where you use VerticalAligment without success

Thank you for cooperation.

Thank you for your troubleshooting efforts. Hopefully some additional info will help. I have attached 3 screenshots taken from the resulting Word document that show the cell formatting in question.

Also, here is the section of code that writes the white-background cells:

private void writeDataCell(DocumentBuilder builder, String data) throws Exception
{
    Cell cell = builder.insertCell();
    cell.clearCellAttrs();
    CellFormat format = cell.getCellFormat();
    format.setWidth(42);
    // format.setVerticalAlignment(VerticalAlignment.TOP);
    // format.setVerticalAlignment(VerticalAlignment.CENTER);
    format.setVerticalAlignment(VerticalAlignment.BOTTOM);
    format.setWrapText(false);
    format.setTopPadding(1);
    format.setBottomPadding(1);
    format.setLeftPadding(2);
    format.setRightPadding(2);
    BorderCollection border = format.getBorders();
    border.getTop().setLineWidth(1);
    border.getBottom().setLineWidth(1);
    border.getLeft().setLineWidth(1);
    border.getRight().setLineWidth(1);
    builder.getFont().setBold(false);
    builder.getFont().setSize(8);
    builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
    builder.write(data);
}

The commented-out lines were used to generate the attached screenshots. (the image filename indicates which alignment value was used to generate it) I also stepped through the code with a debugger a noted the following values in case this is helpful information:

com.aspose.words.VerticalAlignment.TOP == 1
com.aspose.words.VerticalAlignment.CENTER == 2
com.aspose.words.VerticalAlignment.BOTTOM == 3

We are using jdk1.6.0_21.

Please let me know if you find an answer, even if the answer is that I’m doing something stupid.

Thanks,
Mike

Hi
Thank you for additional information. You should just use CellVerticalAlignment instead of VerticalAlignment:
https://reference.aspose.com/words/java/com.aspose.words/cellformat#VerticalAlignment
VerticalAlignment specifies vertical alignment of a floating shape, text frame or a floating table, but not vertical alignment in table cell.
Best regards,

Thanks so much. That was indeed my problem!