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

Free Support Forum - aspose.com

New feature request

We are looking to buy OEM license for Java version of Aspose.Word and looked at the Tiral version.
A few features are missing. Could you please let us know if there are plans to support the following features in future releases ?

  • Inserting and updating Table of Contents
  • Inserting and updating Table of Figures
  • Inserting watermark
  • Inserting caption

Hi
Thank you for your interest in Aspose.Words for java.

  1. TOC updating is not yet supported by .NET and Java versions of Java. We plan to support this feature in one of the future releases of .NET version. Afterward, this feature will be ported to Java version. I cannot promise anything at this stage. Hopefully, TOC updating will be supported Aspose.Words for Java in the end of this year.
  2. Same for TOF
  3. You can insert watermark into the document using Aspose.Words. just insert image into the header of the document (as MS Word does). See the following code for instance:
/// 
/// Inserts watermark into the document
/// 
/// Input document
/// Text of waermark
private static void InsertWatermarkText(Document doc, String watermarkText) throws Exception
{
    // Create whatermark shape
    // This will be WordArt shape. You are free to use any type of shape as watermark
    Shape watermark = new Shape(doc, ShapeType.TEXT_PLAIN_TEXT);
    // This will be text of watermark
    watermark.getTextPath().setText(watermarkText);
    watermark.getTextPath().setFontFamily("Times New Roman");
    watermark.setWidth(600);
    watermark.setHeight(100);
    // Text dirrection will be from bottom-left corner to top-right
    watermark.setRotation(-45);
    // Uncomment the following line if you need solid black text
    watermark.getFill().setColor(Color.GRAY);
    watermark.setStrokeColor(Color.GRAY);
    // Set position of watermark
    // Watermark should be placed on the center of page
    watermark.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
    watermark.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
    watermark.setWrapType(WrapType.NONE);
    watermark.setVerticalAlignment(VerticalAlignment.CENTER);
    watermark.setHorizontalAlignment(HorizontalAlignment.CENTER);
    // Create new paragraph and append watermark to this paragraph
    Paragraph watermarkPar = new Paragraph(doc);
    watermarkPar.appendChild(watermark);
    int[] hfTypes = { HeaderFooterType.HEADER_PRIMARY, HeaderFooterType.HEADER_FIRST, HeaderFooterType.HEADER_EVEN };
    // Now we should insert watermark into the header of each section of document
    for (Section sect : doc.getSections())
    {
        for (int hftype : hfTypes)
        {
            if (sect.getHeadersFooters().getByHeaderFooterType(hftype) == null)
            {
                // If there is no header of the specified type in the current section we should create new header
                if (hftype == HeaderFooterType.HEADER_PRIMARY ||
                hftype == HeaderFooterType.HEADER_FIRST && sect.getPageSetup().getDifferentFirstPageHeaderFooter() ||
                hftype == HeaderFooterType.HEADER_EVEN && sect.getPageSetup().getOddAndEvenPagesHeaderFooter())
                {
                    HeaderFooter hf = new HeaderFooter(doc, hftype);
                    // Insert clone of watermarkPar into the header
                    hf.appendChild(watermarkPar.deepClone(true));
                    sect.getHeadersFooters().add(hf);
                }
            }
            else
            {
                // If the header of specified type exists then just insert watermark
                sect.getHeadersFooters().getByHeaderFooterType(hftype).appendChild(watermarkPar.deepClone(true));
            }
        }
    }
}
  1. Captions in MS Word are represented as “Lable” + “SEQ field”. You can use DocumentBuilder for inserting captions. For example see the following code:
Document doc = new Document("C:\\Temp\\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Get collection of shapes inthe document
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
// Loop through all shpes
for (int shapeIdx = 0; shapeIdx < shapes.getCount(); shapeIdx++)
{
    Shape shape = (Shape)shapes.get(shapeIdx);
    if (shape.getShapeType() == ShapeType.IMAGE)
    {
        // Move DocumentBuilder cursor to shape
        // Cursor will be placed after shape
        if (shape.getNextSibling() != null)
            builder.moveTo(shape.getNextSibling());
        else
            builder.moveTo(shape.getParentParagraph());
        // Insert paragraph break
        builder.writeln();
        // Insert lable
        builder.write("Picture");
        // Insert SEQ field
        builder.insertField("SEQ Picture \\* ARABIC", "");
    }
}
// Save result document
doc.save("C:\\Temp\\out.doc");

However, note that Aspose.Words does not evaluate SEQ fields. So you should update fields inside the document manually (ctrl+A and F9). In addition, you can use macro to update fields. See the following link to learn more.
https://support.microsoft.com/en-us/topic/the-filename-field-does-not-automatically-update-when-you-open-a-document-in-word-de2bfb95-d990-1ced-a618-5ac0a2ec1be4
Hope this helps.
Best regards.

TOC is a critical feature for us. Is there any workaround ?
Is it possible that we generate the TOC and that can be merged with the rest of the document ?

Hi
Thanks for your request. The main problem is that currently Aspose.Words cannot determine where particular paragraph is placed, so it is impossible to update page numbers in TOC. If page numbers are not critical for you, I think I can create workaround for you using bookmarks.
Best regards.

Hi,

Some time back it was mentioned that TOC generation will be part of year end release.See this mail thread above. Whether TOC generation feature will be included in the next release. if so, When next major release of Word for java will be available.

Hi

Thanks for your inquiry. Most likely update TOC feature will be supported in January 2010 release. You will be notified as soon as this feature is supported.
Best regards,

The issues you have found earlier (filed as 10380) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(18)