Aspose.Java supported features

Dear Aspose Support:

These are some features we current use in a existing VBA applciation to manipulation a MS Word file but I can not find similiar features in your Aspose java version:

Selection.PasteAndFormat
PageSetup.TwoPageOnOne
PageSetup.BookFoldPrinting
PageSetup.BookFoldRevPrinting
PageSetup.BookFoldPrintingSheets
ActiveDocument.PrintOut
ActiveDocument.SelectAllEditableRanges
Rows.AllowBreakAcrossPages
ActiveDocument.Fields.Unlink
Selection.Editors
ActiveDocument.ShowRevisions(is it "acceptAllRevisions" ?)ActiveDocument.ActiveWindow.View.ShowHiddenText

I can find some of them supported in your .Net version. Can you tell me whether you support these features in java and if you don’t, are you planning to do so in near feature? Thanks a lot.

Hi

Thanks for your inquiry. It is not very good way to just translate code, which uses Word Automation to Aspose.Words line by line. Could you please describe your requirements? I will provide you a solution or more information about each requirement.

As I can see, you print your document using Word Automation. At the moment printing is not supported in Aspose.Words for Java. This feature is supported only in .NET version of Aspose.Words. I linked your request to the appropriate issue; you will be notified as soon as printing is supported in Java (hopefully within 2-3 months).

Waiting for your inputs.

Best regards.

Hi Alexey,

Thank you for the reply.

These are all standard methods in VBA for MS Word and currently used in our production programs. I copied some sample code below from MSDN.

I found many standard methods we used already covered by your Aspose java, most of them are line to line match, like PageSetup.BottomMargin, PageSetup.SectionStart, Selection.ParagraphFormat.TabStops, etc. That’s great. But I can’t find the following methods in your java version, at least not obvious.

  1. Selection.PasteAndFormat:
    Pastes the selected table cells and formats them as specified.

This example pastes a selected Microsoft Excel chart as a picture. This example assumes that the Clipboard contains an Excel chart.

Sub PasteChart()
    Selection.**PasteAndFormat** Type:=wdChartPicture
End Sub
PageSetup.TwoPagesOnOne
PageSetup.BookFoldPrinting
PageSetup.BookFoldRevPrinting
PageSetup.BookFoldPrintingSheets

These are all different print options and self-explained.

  1. SelectAllEditableRanges

Selects all ranges for which the specified user or group of users has permission to modify.

The following example selects all ranges for which the current user has permission to modify.

ActiveDocument.SelectAllEditableRanges wdEditorCurrent

  1. AllowBreakAcrossPages

True if the text in a table row or rows are allowed to split across a page break. Can be True, False or wdUndefined (only some of the specified text is allowed to split). Read/write Long.

This example creates a new document with a 5x5 table and prevents the third row of the table from being split during pagination.

Dim docNew As Document
Dim tableNew As Table
Set docNew = Documents.Add
Set tableNew = docNew.Tables.Add(Range:=Selection.Range, _
NumRows:=5, NumColumns:=5)
tableNew.Rows(3).**AllowBreakAcrossPages** = False
  1. Fields.Unlink
    Replaces all the fields in the Fields collection with their most recent results.

  2. Selection.Editors
    Returns a Editors object that represents all the users authorized to modify a selection within a document.

  3. ActiveDocument.ShowRevisions

True if tracked changes in the specified document are shown on the screen. Read/write **Boolean.**This example sets the active document so that it tracks changes and makes them visible on the screen.

With ActiveDocument
    .TrackRevisions = True
    .ShowRevisions = True
End With
  1. ActiveDocument.ActiveWindow.View.ShowHiddenText

True if text formatted as hidden text is displayed. Read/write Boolean

This example hides text formatted as hidden text in each window.

For Each myWindow In Windows
    myWindow.View.ShowHiddenText = False
Next myWindow

It is possible that we may find more methods with questions later on.

I appreciate if you can let me know whether you support them, if not, are you going to do so in the near future. Thanks again.

Hi

Thank you for additional information.

  1. Aspose.Words does not support inserting content from clipboard. However, you can use DocuemntBuidler to insert images into Word documents. Please see the following link for more information:
    https://docs.aspose.com/words/net/programming-with-documents/

  2. Since Aspose.Words for Java does not support printing at the moment, so there is no way to specify these options.

  3. Aspose.Words does not support editable regions. However, using Aspose.Words you can edit whole document, even if it is protected.

  4. You can find this option in RowFormat:
    https://reference.aspose.com/words/net/aspose.words.tables/rowformat/allowbreakacrosspages/

  5. There is no built-in method to unlink field in the document. however, you can create your own method to achieve this. For example you can try using the following code:

public static void UnlinkFields(Document doc) throws Exception
{
    //Get collection of FieldStart nodes
    NodeCollection fieldStarts = doc.getChildNodes(NodeType.FIELD_START, true);
    //Get collection of FieldSeparator nodes
    NodeCollection fieldSeparators = doc.getChildNodes(NodeType.FIELD_SEPARATOR, true);
    //And get collection of FieldEnd nodes
    NodeCollection fieldEnds = doc.getChildNodes(NodeType.FIELD_END, true);
    //Loop through all FieldStart nodes
    for (int i = 0; i<fieldStarts.getCount(); i++)
    {
        FieldStart start = (FieldStart)fieldStarts.get(i);
        //Search for FieldSeparator node. it is needed to remove field code from the document
        Node curNode = start;
        while (curNode.getNodeType() != NodeType.FIELD_SEPARATOR && curNode.getNodeType() != NodeType.FIELD_END)
        {
            curNode = curNode.nextPreOrder(doc);
            if (curNode == null)
                break;
        }
        //Remove all nodes between Fieldstart and FieldSeparator (of FieldEnd, depending from field type)
        if (curNode != null)
            RemoveSequence(start, curNode);
    }
    //Now we can remove FieldStart, FieldSeparator and FieldEnd nodes
    fieldStarts.clear();
    fieldSeparators.clear();
    fieldEnds.clear();
}

/**
    * Remove all nodes between start and end nodes, except start and end nodes
    * @param start The start node
    * @param end The end node
    * @throws Exception
    */
public static void RemoveSequence(Node start, Node end) throws Exception
{
    Node curNode = start.nextPreOrder(start.getDocument());
    while (curNode != null && !curNode.equals(end))
    {
        //Move to next node
        Node nextNode = curNode.nextPreOrder(start.getDocument());
        //Check whether current contains end node
        if (curNode.isComposite())
        {
            CompositeNode curComposite = (CompositeNode)curNode;
            if (!curComposite.getChildNodes(NodeType.ANY, true).contains(end) &&
                    !curComposite.getChildNodes(NodeType.ANY, true).contains(start))
            {
                nextNode = curNode.getNextSibling();
                curNode.remove();
            }
        }
        else
        {
            curNode.remove();
        }
        curNode = nextNode;
    }
}
  1. The same answer as #3.

  2. ShowRevisions is not an option of a document, it is option of MS Word so it is not stored in a document. Since Aspose.Words works only with documents, you cannot specify this option.

  3. The same answer as #7.

Hope this information could be useful for you.

Best regards.

Hi Alexey,

For the item 5 to unlink fields, your code works great for all DOCVARIABLE. But for fields like {PAGE} and {NUMPAGES}, the results are something like this “Page XXX of XXX” (instead of “Page 3 of 5”). Is there anyway you can leave these two fields untouched in your unlink procedure? Another field that we need to leave it alone is ‘AUTOTEXT’. Since you don’t support autotext, we would like to leave it untouched and replace it later by using functions like serach and replace. Thank you very much for your support.

Hi

Thanks for your inquiry. Yes, of course you can skip fields. I modified the code. Please try using the following method:

public static void UnlinkFields(Document doc) throws Exception
{
    //Get collection of FieldStart nodes
    Node[] fieldStarts = doc.getChildNodes(NodeType.FIELD_START, true).toArray();
    //Loop through all FieldStart nodes
    for (int i = 0; i<fieldStarts.length; i++)
    {
        FieldStart start = (FieldStart)fieldStarts[i];
        // Skip PAGE and AUTOTEXT fields.
        if(start.getFieldType() == FieldType.FIELD_PAGE || start.getFieldType() == FieldType.FIELD_AUTO_TEXT)
            continue;
        Node separator = null;
        Node end = null;
        //Search for FieldSeparator node. it is needed to remove field code from the document
        Node curNode = start;
        while (curNode.getNodeType() != NodeType.FIELD_SEPARATOR && curNode.getNodeType() != NodeType.FIELD_END)
        {
            curNode = curNode.nextPreOrder(doc);
            if (curNode == null)
                break;
        }
        //Remove all nodes between Fieldstart and FieldSeparator (of FieldEnd, depending from field type)
        if (curNode != null)
            RemoveSequence(start, curNode);
        if(curNode.getNodeType() == NodeType.FIELD_SEPARATOR)
        {
            separator = curNode;
            // Search for field end.
            while (curNode.getNodeType() != NodeType.FIELD_END)
            {
                curNode = curNode.nextPreOrder(doc);
                if (curNode == null)
                    break;
            }
            end = curNode;
        }
        // Remove field start, field separator and field end.
        if(start != null)
            start.remove();
        if(separator != null)
            separator.remove();
        if(end != null)
            end.remove();
    }
}

Hope this helps.

Best regards.

It’s working now. Thanks a lot.

The issues you have found earlier (filed as WORDSJAVA-2) have been fixed in this .NET update and in this Java update.


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

The issues you have found earlier (filed as WORDSNET-1067) have been fixed in this .NET update and this Java update.


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