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

Free Support Forum - aspose.com

Cyrillic symbols problem on building jar with dependencies

Hello,

I am using the latest version of Aspose.Words and assemble the jar with your library included.

Here is the JAVA code:

package ru.mail.jira.plugins.asposemaventest;
import com.aspose.words.*;
public class AsposeMavenTest
{
	public static void main(String[] args) throws Exception
	{
		Document document = new Document();
		Body body = document.getLastSection().getBody();
		body.appendParagraph("Русский текст").getParagraphFormat();
		document.save("/Users/amolchanov/Downloads/out.docx", SaveFormat.DOCX);
    }
}

And here is my pom.xml:

<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>ru.mail.jira.plugins</groupId>
	<artifactId>aspose-maven-test</artifactId>
	<packaging>jar</packaging>
	<version>1.0</version>
	<organization>
		<name>Andrey Molchanov | Mail.Ru Group</name>
		<url>http://corp.mail.ru/en</url>
	</organization>
	<name>aspose-maven-test</name>
	<dependencies>
		<dependency>
			<groupId>com.aspose</groupId>
			<artifactId>aspose-words-jdk16</artifactId>
			<version>13.10.0</version>
			<scope>compile</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<configuration>
					<archive>
						<manifest>
							<mainClass>ru.mail.jira.plugins.asposemaventest.AsposeMavenTest</mainClass>
						</manifest>
					</archive>
					<descriptorRefs>
						<descriptorRef>jar-with-dependencies</descriptorRef>
					</descriptorRefs>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>	

First I add the library jar to the local Maven repository:
/usr/share/atlassian-plugin-sdk-4.1.6/apache-maven/bin/mvn install:install-file -Dfile=/Users/amolchanov/Downloads/Aspose/lib/Aspose.Words.jdk16.jar -DgroupId=com.aspose -DartifactId=aspose-words-jdk16 -Dversion=13.10.0 -Dpackaging=jar

And then assembly it using Maven:
/usr/share/atlassian-plugin-sdk-4.1.6/apache-maven/bin/mvn clean package assembly:single

The problem is that output file contains strange symbols instead of cyrillic label - so it is some kind of encoding problem. I encounter it only when package to maven, but there is no other way, because we need Aspose.Words to work with out Atlassian JIRA plugins, that requires Maven packaging. I attached the JAR file.

We are looking forward for your help. Thank you!

Hi Andrey,

Thanks for your inquiry. I have tested the code example shared by you while using latest version of Aspose.Words for Java 13.10.0 and have not found any issue in output Docx.

For Maven packaging, It would be great if you please share the necessary steps to reproduce this issue at our end. Are you facing this issue with specific text or with any other text as well? Please share the Maven version. I will investigate the issue on my side and provide you more information.

Hi,

Thank you for your answer.

I attached source directory.

  1. Add Aspose.Words jar to Maven local repository: mvn install:install-file -Dfile=/Users/amolchanov/Downloads/Aspose/lib/Aspose.Words.jdk16.jar -DgroupId=com.aspose -DartifactId=aspose-words-jdk16 -Dversion=13.10.0 -Dpackaging=jar

  2. Assemble package using Maven: mvn clean package assembly:single

  3. Execute the jar: java -jar target/aspose-maven-test-1.0-jar-with-dependencies.jar

  4. See the file with encoding problems (also attached)

And I have problems with any Cyrillic text, not just that specific one.

Hello,


Any ideas?

Hi Andrey,

Thanks for sharing the detail. I think, It might be localization problem or encryption problem. Aspose.Words for Java (jar file) works fine with shared code/Cyrillic symbols. It seems that Maven local repository change the names of files inside folder asposewobfuscated and com\aspose\words of Aspose.Words Jar. Please extract the Aspose.Words.jdk16.jar file and check the file names.

I have logged a new Task in our issue tracking system as WORDSJAVA-814 to investigate the shared issue. We will investigate your issue at our end and will post the results here for
your kind reference asap.


Thank you for your patience and understanding.

Hi Andrey,

Thanks for your patience. I have tested the scenario and have not found the shared issue. Aspose.Words Jar file works in your scenario after repacking by using Maven.

I have attached the Jar file and Maven Project with this post for your kind reference.

The AsposeTestMaven-AsposeTestMaven-jar-with-dependencies.jar creates output file at C:\outMaven.docx

The output docx is also attached with this post. Please let us know if you have any more queries.

Hi,


It works nice with precompiled JAR.

The encoding problem reproduces when I compile your example myself and then execute the result. I attached the compiled JAR.

What Maven commands do you use to add dependency file to the repository and compile project? What version of the Aspose Words JAR do you add to the repository?

Hi Andrey,

Thanks for your inquiry. I have used the latest version of Aspose.Words for Java 13.10.0 to test your scenario. I followed the following steps you generate the Jar file.

  1. I used following command to create the Maven project.
    mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

  2. Imported this project in Eclipse

  3. Added Aspose.Words jar in Maven Dependencies

  4. Used Maven Install command from (file->run as->Maven install). Please check the attached image.

Hello,


I don’t have Eclipse installed on my computer, so I used Idea. Anyway, it compiles and works without the problem from IDE. But I still can’t make it work from command line.

Maven version is the same in both cases.

What could be the reason? Some specific argument that IDE passes to Maven?

Hi Andrey,

Thanks for your inquiry. I am afraid, I am not much familiar with maven commands. However, I tested Aspose.Words with Maven and it works fine. Please see my reply here. I suggest you please read following link for your kind reference. Hope this helps you.

http://maven.apache.org/general.html

Hi,


Anyway we need it working from command line. What can we do?

OK, guys. Problem is solved now. Thank you anyway!

Hi Andrey,

Thanks for your feedback. It is nice to hear from you that your problem has been solved.

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

@a.molchanov,

The issues you have found earlier (filed as WORDSJAVA-814) have been fixed in this Aspose.Words for .NET 17.7 update and this Aspose.Words for Java 17.7 update.