添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
怕老婆的皮带  ·  Standalone Mode and ...·  1 月前    · 
暗恋学妹的饼干  ·  7. Song Meter ...·  1 月前    · 
很拉风的沙滩裤  ·  第 101 ...·  1 月前    · 
小眼睛的大象  ·  Revolutionizing ...·  3 月前    · 

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account
What steps will reproduce the problem?
1. I have a word document, after
2. With POI I replace some text with other text and as specific tag for an 
image, after
3. is generate a word document with new text and image
4. but when I convert the document to pdf type i got error:
org.apache.poi.xwpf.converter.core.XWPFConverterException: 
java.lang.IllegalStateException: Expecting one Styles document part, but found 0
    at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:59)
    at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:37)
    at org.apache.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:45)
    at poi38.ooxmlToPDF.createPDF(ooxmlToPDF.java:53)
    at poi38.ooxmlToPDF.main(ooxmlToPDF.java:18)
Caused by: java.lang.IllegalStateException: Expecting one Styles document part, 
but found 0
    at org.apache.poi.xwpf.usermodel.XWPFDocument.getStyle(XWPFDocument.java:441)
    at org.apache.poi.xwpf.converter.core.styles.XWPFStylesDocument.<init>(XWPFStylesDocument.java:192)
    at org.apache.poi.xwpf.converter.core.styles.XWPFStylesDocument.<init>(XWPFStylesDocument.java:186)
    at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.createStylesDocument(XWPFDocumentVisitor.java:161)
    at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.<init>(XWPFDocumentVisitor.java:154)
    at org.apache.poi.xwpf.converter.pdf.internal.PdfMapper.<init>(PdfMapper.java:149)
    at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:54)
    ... 4 more
Process exited with exit code 0.
What is the expected output? What do you see instead?
 - A pdf file
What version of the product are you using? On what operating system?
  - POI 3.8, xdocreport-1.0.4.jar, itext2.1.7.jar
Please provide any additional information below.
Although POI is modifying doc, I think that process poi is adding some wrong, 
because I try convert to PDF i catch error.
If I open the document with microsoft office and remove image and insert the 
same image and save, after the process run fine.
          

This is a very old post. But still in 2020 i faced the same issue and i struggled to find a single answer.
Hence thought of posting so that someone might get benefit.

I did a reverse engineer by going into the 3rd party jar where this error was occurring and added the "food" in respective Word document generator code that solved the pdf converter's hunger. :-)

Surprisingly, this issue was shown only to the word document that was created using Apache POI...!
If you try to use a word document that was created using MS Office, there wont be any issue.. :-)

So, while we create table in a word document via POI, we need to add a line immediately after the createTable() statement

XWPFTable table = outputDoc.createTable();
table.getCTTbl().addNewTblGrid();

I am facing the same issue. But in my case I am using only paragraphs and images. Were you able to find the solution in those cases.

fr.opensagres.poi.xwpf.converter.core.XWPFConverterException: java.lang.IllegalStateException: Expecting one Styles document part, but found 0
at fr.opensagres.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:71)
at fr.opensagres.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:39)
at fr.opensagres.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:46)
at utility.PDFHandle.generatePDF(PDFHandle.java:35)
at utility.Reporter.saveReport(Reporter.java:83)
at tests.TC001_ApplicationLogInAndInitiateSIP_Temp.resetConfig(TC001_ApplicationLogInAndInitiateSIP_Temp.java:55)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:637)
at org.testng.TestRunner.afterRun(TestRunner.java:877)
at org.testng.TestRunner.run(TestRunner.java:599)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.IllegalStateException: Expecting one Styles document part, but found 0
at org.apache.poi.xwpf.usermodel.XWPFDocument.getStyle(XWPFDocument.java:547)
at fr.opensagres.poi.xwpf.converter.core.styles.XWPFStylesDocument.(XWPFStylesDocument.java:196)
at fr.opensagres.poi.xwpf.converter.core.styles.XWPFStylesDocument.(XWPFStylesDocument.java:190)
at fr.opensagres.poi.xwpf.converter.core.XWPFDocumentVisitor.createStylesDocument(XWPFDocumentVisitor.java:182)
at fr.opensagres.poi.xwpf.converter.core.XWPFDocumentVisitor.(XWPFDocumentVisitor.java:175)
at fr.opensagres.poi.xwpf.converter.pdf.internal.PdfMapper.(PdfMapper.java:155)
at fr.opensagres.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:56)
... 29 more

This is the complete error I am getting