Page 1 of 1

Unable to show page numbers in table of Content

PostPosted: Tue Jan 30, 2018 11:15 pm
by lazvegas
Hello,
When I try to
Code: Select all
tocGenerator.generateToc( 0,    "TOC \\o \"1-3\" \\h \\z \\u ", false);


I am gettting the error . Could you help me about that ? Regards
Code: Select all
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
   at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
   at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:966)
   at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)
   at org.docx4j.services.client.ConverterHttp.convert(ConverterHttp.java:182)
   at org.docx4j.toc.TocGenerator.getPageNumbersMapViaService(TocGenerator.java:701)
   at org.docx4j.toc.TocGenerator.getPageNumbersMap(TocGenerator.java:663)
   at org.docx4j.toc.TocGenerator.populateToc(TocGenerator.java:438)
   at org.docx4j.toc.TocGenerator.generateToc(TocGenerator.java:303)
   at org.docx4j.toc.TocGenerator.generateToc(TocGenerator.java:231)
   at org.docx4j.toc.TocGenerator.generateToc(TocGenerator.java:191)
   at com.sap.tap4s.rest.PdfGenerateService.getDocx(PdfGenerateService.java:212)
   at com.sap.tap4s.rest.PdfGenerateService.main(PdfGenerateService.java:887)

Re: Unable to show page numbers in table of Content

PostPosted: Wed Jan 31, 2018 3:53 pm
by jason
To update page numbers, the document needs to be layed out on pages.

For page layout, an instance of Plutext's PDF Converter is used.

From the stack trace, you are using an SSL connection to connect to the PDF Converter.

https://stackoverflow.com/questions/327 ... r-instance says that error is typically caused by conflicting versions of httpcore jar. i.e., an older version of httpcore on your classpath. If not that, then httpclient?

If you continue to have problems, you could first confirm that a plain http connection works.

The URL is configured in docx4j.properties using key com.plutext.converter.URL

DEBUG level logging for org.docx4j.services.client.ConverterHttp will also tell you that.

Re: Unable to show page numbers in table of Content

PostPosted: Wed Feb 07, 2018 1:18 am
by lazvegas
Hello Jason
But I am generation Word Document not PDF

Re: Unable to show page numbers in table of Content

PostPosted: Wed Feb 07, 2018 6:04 am
by jason
I understand that.

Even so, it is the PDF Converter which returns the page number information, since it is the PDF Converter which knows where the page breaks fall.

That page number information is then included in the ToC in the docx.

Re: Unable to show page numbers in table of Content

PostPosted: Wed Feb 07, 2018 8:14 pm
by lazvegas
Hello,
So in order to show page numbers in Table OF Contents, we need to install additional plugin ?

Regards.

Re: Unable to show page numbers in table of Content

PostPosted: Wed Feb 07, 2018 8:52 pm
by jason
For eval purposes you can use the instance of the PDF Converter which is hosted at https://converter-eval.plutext.com/

In production, you should install/use your own instance.

To address the issue you raised in this thread, you'll need to fix the conflicting versions of httpcore and/or httpclient jars on your classpath.