Hello!
I have installed the Maven plugin for Aspose.Words Java, created a new Aspose.Words project, and also selected to download the code examples.
Now I bring up the wizard called Aspose.Words Code Example.
Unfortunately, the tree view only contains the node Aspose.Words with no sub-node, so I cannot select an example category. The “Next” button is inactive, probably because it expects an example category to be selected.
What do I need to do to populate the tree with the actual example categories?
Best,
Felix Grützmacher
When I try to import the code examples project from GitHub I get a load of warnings about types that cannot be resolved. Is there a straightforward guide on how to get started with this API using Eclipse?
We suggest you please read the following articles about installing Aspose.Words for Java and run the examples using Eclipse. Hope this helps you.
Installing Aspose.Words for Java from Maven Repository
How to Run the Examples using Eclipse
I tried that! I am getting errors as follows:
Description | Resource | Path | Location | Type |
---|---|---|---|---|
AppendwithImportFormatOptions cannot be resolved to a type | FieldDisplayResult.java | /words-java-examples/src/main/java/com/aspose/words/examples/programming_documents/fields | line 13 | Java Problem |
ApplyBordersAndShading cannot be resolved to a type | ExtractContentBasedOnStyles.java | /words-java-examples/src/main/java/com/aspose/words/examples/programming_documents/styles | line 14 | Java Problem |
AsposeWordsPrintDocument cannot be resolved to a type | DocumentPreviewAndPrint.java | /words-java-examples/src/main/java/com/aspose/words/examples/rendering_printing | line 33 | Java Problem |
AsposeWordsPrintDocument cannot be resolved to a type | DocumentPreviewAndPrint.java | /words-java-examples/src/main/java/com/aspose/words/examples/rendering_printing | line 33 | Java Problem |
AutoFitBehavior cannot be resolved to a variable | ApplyAutoFitSettingsToATable.java | /words-java-examples/src/main/java/com/aspose/words/examples/programming_documents/tables/ColumnsAndRows | line 33 | Java Problem |
AutoFitBehavior cannot be resolved to a variable | ApplyAutoFitSettingsToATable.java | /words-java-examples/src/main/java/com/aspose/words/examples/programming_documents/tables/ColumnsAndRows | line 47 | Java Problem |
AutoFitBehavior cannot be resolved to a variable | ApplyAutoFitSettingsToATable.java | /words-java-examples/src/main/java/com/aspose/words/examples/programming_documents/tables/ColumnsAndRows | line 61 | Java Problem |
AutoFitBehavior cannot be resolved to a variable | DocumentBuilderBuildTable.java | /words-java-examples/src/main/java/com/aspose/words/examples/programming_documents/document | line 20 | Java Problem |
AutoFitBehavior cannot be resolved to a variable | InsertTableDirectlyIntoDOM.java | /words-java-examples/src/main/java/com/aspose/words/examples/programming_documents/tables/creation | line 34 | Java Problem |
AutoFitBehavior cannot be resolved to a variable | TableStyles.java | /words-java-examples/src/main/java/com/aspose/words/examples/programming_documents/tables/ApplyFormatting | line 35 | Java Problem |
…
I used the pom.xml that came with the repo.
And I installed the Maven plugin for aspose.words.
Could you please share your environment detail e.g. Java version, Eclipse version, and operating system etc.? We will investee this issue and provide you more information on it.
Sure, here goes:
I downloaded the examples project from: https://github.com/aspose-words/Aspose.words-for-Java/archive/master.zip
Java is: JDK 15.0.1
OS is: Windows 7
Eclipse is: Version: 2020-09 (4.17.0)
Steps are as follows:
- File / Import / Existing Maven projects
- Choose /pom.xml com.aspose:words-java-examples:1.0-SNAPSHOT:jar
I am assuming the pom.xml would instruct Eclipse to download dependencies as needed.
Unfortunately the errors still occur.
Best regards,
Felix Grützmacher
We are working over your query and will get back to you soon.
Could you please share your requirement? We will then share the articles and code examples with you.
Hello,
that sounds like a reasonable if somewhat generic approach. Let me try to provide a bit of background for our project and how Aspose.Words may factor into it.
We are essentially in the process of developing an editor for various document formats, including pdf, docx, and of course txt. Our requirement is that this editor will retain most if not all formatting when a document is loaded, modified, then saved.
Our current idea is to develop the editor in such a way that it operates directly on the Aspose.Words data structure, either through DocumentBuilder or directly with the DOM. Our initial testing with DocumentBuilder was positive in that formatting was retained when we inserted new text into the document.
Our editor will of course have the concept of a cursor which can be moved by character, line, sentence, paragraph, etc. Text can also be selected and then formatting operations can be applied to the selection.
What we want to avoid, at pretty much all cost, is having to transcode the Aspose DOM to some internal data structure and then having the user navigate that internal structure through our user interface. This would lose much of the formatting information in translation unless we replicated a lot of what Aspose.Words does, but why use the library when you’re essentially replicating it anyway …
Can you point me to some example code illustrating how the Aspose.Words DOM could be at the root of a very simple word processor, or text editor? The more minimalistic the better, I’d like to get a feel for how a cursor or selection or text insertion or clipboard concept would map to Aspose.Words method calls.
Thank you in advance!
Best wishes,
Felix Grützmacher
Aspose.Words for Java is a class library that provides APIs to perform document processing tasks. DocumentBuilder has an internal cursor and you can move it to any location in the document and insert your desired content. Please do not match or compare it with cursor of editor that you want to build. You can use Aspose.Words to import document e.g. DOCX, PDF, RTF etc. into its DOM, save the document to HTML, load it into your editor. The formatting of text will be done by your editor. Once your document is final, save the editor content (HTML) into your desired format using Document.Save method.
Moreover, we suggest you read Programming with Documents.
Hello,
thank you for your detailed response!
I understood from your message that the design of Aspose.Words is optimized for automated document processing but not for in-situ editing, so we might have trouble implementing editor commands directly on the Aspose data structures. You suggested that we transcode the Word document to HTML, implement editing functionality based on HTML, then back-transcode the editing result to a Word document.
Two questions present themselves:
- There are objects that can exist within Word documents which cannot be unambiguously represented in HTML. Are we going to lose them in translation, or does Aspose.Words save them as meta-information, for instance, in an HTML comment?
- Your suggestion is shifting the burden from in-situ editing of the Aspose DOM to in-situ editing of the HTML DOM. What API do you suggest for mapping editor operations to HTML processing?
Best regards,
Felix Grützmacher
We have tested the scenario at the same environment and have not found any issue. Please check the attached image for detail. Example Test Eclipse.png (123.3 KB)
Please note that Aspose.Words mimics the behavior of MS Word. If you convert your document to HTML using MS Word and import/display it in text editor, you will get the same output.
We suggest you please check free online document editor. The source code is available in .NET. If you are happy with this editor, we will log your requirement in our issue tracking system for Java. Hope this helps you.