Create Table of Contents TOC Field in Word DOCX Document & Generate <TOC> Tags in PDF using Java | PDF/UA 508 Compliant

Hi Awais,

We tried using opts.ExportDocumentStructure = true; but still “P” tags are created and not “TOC” tags for table of contents. Please let us know if we are missing some code that needs to be added.

The issues you have found earlier (filed as WORDSNET-17843) have been fixed in this Aspose.Words for .NET 19.5 update and this Aspose.Words for Java 19.5 update.

@awais.hafeez Can you please help us on this

@cvsformulary,

But, I can see TOC tags in this Aspose.Words for Java 19.5 generated PDF:
awjava-19.5.pdf (60.1 KB)

I used the following code to generate above PDF:

Document doc = new Document("e:\\toc\\toc.docx");

PdfSaveOptions opts = new PdfSaveOptions();
opts.setExportDocumentStructure(true);

doc.save("e:\\toc\\awjava-19.5.pdf", opts);

Thanks @awais.hafeez…It worked for us too.

Just one more question regarding this new jar 19.5 is there any change in the way Aspose licence is being instantiated .
We used to instantiate the license every time before using Aspose API’s and it has been working fine so far

License license = new License();
license.setLicense(“Aspose.Words.lic”);

but with this new jar it has started giving following null pointer exception for every second document that is run.

Caused by: java.lang.NullPointerException
at com.aspose.words.zzYR8.zzYDu(Unknown Source)
at com.aspose.words.zzZL8.zzW(Unknown Source)
at com.aspose.words.zzZL8.zzX(Unknown Source)
at com.aspose.words.License.setLicense(Unknown Source)

Please let us know if something has been changed regarding this and if there is any correct approach to instantiate/initialize the licence in the code.

Thanks

@cvsformulary,

You only need to instantiate License once before creating the Document object.

Please post your license file via private message. In order to send a private message with attachments, please click on my name and find “Message” button. (see steps). We will then investigate the issue with the license file on our end by using latest version of Aspose.Words and provide you more information. Please do not share your license file publicly in forum threads.

Also, please provide runnable simplified code snippet that helps us to reproduce this exception on our end.

@awais.hafeez

We instantiate the license every time before we create a document object like below code.

License license = new License();
license.setLicense(“Aspose.Words.lic”);
Document doc = new Document(\test.docx);
PdfSaveOptions options = new PdfSaveOptions();
options.setExportDocumentStructure(true);
doc.save(/test.pdf );

Issue : : When two processes are running parallel, we are getting a null pointer exception (see below for exception trace) from set licence code. We don’t see this issue if only one process is trying to execute the code. This behavior is only with the new version 19.5 and don’t see an issue with older version 17.6 . We tested this with in the Java/J2EE web application deployed on web sphere.application server…

Caused by:java.lang.NullPointerException
at com.aspose.words.zzYR8.zzYDu(Unknown Source)
at com.aspose.words.zzZL8.zzW(Unknown Source)
at com.aspose.words.zzZL8.zzX(Unknown Source)
at com.aspose.words.License.setLicense(Unknown Source)

We believe that this might be an issue with synchronization between the two processes in set licence code. Also this behavior will impact most of the customers and not only us.

We also posted licence in private message.

@cvsformulary,

Yes, we have received your license file. Please also create a simplified standalone Java application (source code without compilation errors) that helps us to reproduce your current problem with License on our end and attach it here for testing. Please do not include Aspose.Words JAR files in it to reduce the file size. Thanks for your cooperation.

@awais.hafeez

Please use below code. Thank you.

public class FileUtilTest extends Thread {

	public void run() {

		 try {

			License license = new License();

			license.setLicense("Aspose.Words.lic");

			Document dstDoc = new Document("xxx.docx");

			PdfSaveOptions options = new PdfSaveOptions();

			options.setExportDocumentStructure(true);

			dstDoc.save("xxx.pdf", options);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		for (int i = 0; i < 4; i++) {
			FileUtilTest object = new FileUtilTest();
			object.start();
		}
	}
}

@cvsformulary,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSJAVA-2089. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Sure. Did something changed in new version(19.5), because we don’t have this issue with earlier version(17.6) . Also can you please help to verify and confirm that no other method or functionality is impacted because of similar type of code change. Thank you.

@cvsformulary,

This issue (WORDSJAVA-2089) is currently pending for analysis and is in the queue. We will inform you via this thread as soon as this issue is resolved or any further updates are available. We apologize for any inconvenience.

Please also check release notes of Aspose.Words for Java.

P.S. Generally, we exercise unit testing and all of our unit tests are properly structured. Therefore, upgrading to the latest version of Aspose.Words for Java is safe and the latest version should cause no undesired behavior. Since all Aspose.Words functionality is unit tested so everything in the previous versions shall still be working in the newer versions.

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