PPTX to PDF error using iText and PdfGraphics2D
up vote
0
down vote
favorite
I am trying to convert a pptx file to an Image and then create a PDF from it using apache poi and iText.
Dimension pgsize = ppt.getPageSize();
XSLFSlide slide = ppt.getSlides()[0];
PdfWriter pdfWriter = null;
Document document = new Document()
pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(targetPath));
document.setPageSize(new Rectangle((float) pgsize.getWidth(), (float) pgsize.getHeight()));
document.open();
PdfGraphics2D graphics = (PdfGraphics2D) pdfWriter.getDirectContent().createGraphics((float) pgsize.getWidth(),
(float) pgsize.getHeight());
slide.draw(graphics);
graphics.dispose();
document.close();
But I get the error:
java.lang.AbstractMethodError: org.apache.poi.xslf.usermodel.XSLFTextRun.getFontInfo(Lorg/apache/poi/common/usermodel/fonts/FontGroup;)Lorg/apache/poi/common/usermodel/fonts/FontInfo;
at org.apache.poi.sl.draw.DrawTextParagraph.getAttributedString(DrawTextParagraph.java:584) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextParagraph.breakText(DrawTextParagraph.java:259) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextShape.drawParagraphs(DrawTextShape.java:156) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextShape.drawContent(DrawTextShape.java:125) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:97) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:71) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:41) ~[poi-3.17.jar:3.17]
at org.apache.poi.xslf.usermodel.XSLFSlide.draw(XSLFSlide.java:307) ~[tika-server-1.16.jar:1.16]
java apache itext apache-poi apache-tika
add a comment |
up vote
0
down vote
favorite
I am trying to convert a pptx file to an Image and then create a PDF from it using apache poi and iText.
Dimension pgsize = ppt.getPageSize();
XSLFSlide slide = ppt.getSlides()[0];
PdfWriter pdfWriter = null;
Document document = new Document()
pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(targetPath));
document.setPageSize(new Rectangle((float) pgsize.getWidth(), (float) pgsize.getHeight()));
document.open();
PdfGraphics2D graphics = (PdfGraphics2D) pdfWriter.getDirectContent().createGraphics((float) pgsize.getWidth(),
(float) pgsize.getHeight());
slide.draw(graphics);
graphics.dispose();
document.close();
But I get the error:
java.lang.AbstractMethodError: org.apache.poi.xslf.usermodel.XSLFTextRun.getFontInfo(Lorg/apache/poi/common/usermodel/fonts/FontGroup;)Lorg/apache/poi/common/usermodel/fonts/FontInfo;
at org.apache.poi.sl.draw.DrawTextParagraph.getAttributedString(DrawTextParagraph.java:584) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextParagraph.breakText(DrawTextParagraph.java:259) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextShape.drawParagraphs(DrawTextShape.java:156) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextShape.drawContent(DrawTextShape.java:125) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:97) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:71) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:41) ~[poi-3.17.jar:3.17]
at org.apache.poi.xslf.usermodel.XSLFSlide.draw(XSLFSlide.java:307) ~[tika-server-1.16.jar:1.16]
java apache itext apache-poi apache-tika
1
Don't mix POI versions! Either only use the one bundled in Apache Tika, or only use POI directly, don't combine
– Gagravarr
Nov 21 at 18:26
@Gagravarr thanks that solved it
– Lez
Nov 22 at 13:48
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to convert a pptx file to an Image and then create a PDF from it using apache poi and iText.
Dimension pgsize = ppt.getPageSize();
XSLFSlide slide = ppt.getSlides()[0];
PdfWriter pdfWriter = null;
Document document = new Document()
pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(targetPath));
document.setPageSize(new Rectangle((float) pgsize.getWidth(), (float) pgsize.getHeight()));
document.open();
PdfGraphics2D graphics = (PdfGraphics2D) pdfWriter.getDirectContent().createGraphics((float) pgsize.getWidth(),
(float) pgsize.getHeight());
slide.draw(graphics);
graphics.dispose();
document.close();
But I get the error:
java.lang.AbstractMethodError: org.apache.poi.xslf.usermodel.XSLFTextRun.getFontInfo(Lorg/apache/poi/common/usermodel/fonts/FontGroup;)Lorg/apache/poi/common/usermodel/fonts/FontInfo;
at org.apache.poi.sl.draw.DrawTextParagraph.getAttributedString(DrawTextParagraph.java:584) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextParagraph.breakText(DrawTextParagraph.java:259) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextShape.drawParagraphs(DrawTextShape.java:156) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextShape.drawContent(DrawTextShape.java:125) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:97) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:71) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:41) ~[poi-3.17.jar:3.17]
at org.apache.poi.xslf.usermodel.XSLFSlide.draw(XSLFSlide.java:307) ~[tika-server-1.16.jar:1.16]
java apache itext apache-poi apache-tika
I am trying to convert a pptx file to an Image and then create a PDF from it using apache poi and iText.
Dimension pgsize = ppt.getPageSize();
XSLFSlide slide = ppt.getSlides()[0];
PdfWriter pdfWriter = null;
Document document = new Document()
pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(targetPath));
document.setPageSize(new Rectangle((float) pgsize.getWidth(), (float) pgsize.getHeight()));
document.open();
PdfGraphics2D graphics = (PdfGraphics2D) pdfWriter.getDirectContent().createGraphics((float) pgsize.getWidth(),
(float) pgsize.getHeight());
slide.draw(graphics);
graphics.dispose();
document.close();
But I get the error:
java.lang.AbstractMethodError: org.apache.poi.xslf.usermodel.XSLFTextRun.getFontInfo(Lorg/apache/poi/common/usermodel/fonts/FontGroup;)Lorg/apache/poi/common/usermodel/fonts/FontInfo;
at org.apache.poi.sl.draw.DrawTextParagraph.getAttributedString(DrawTextParagraph.java:584) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextParagraph.breakText(DrawTextParagraph.java:259) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextShape.drawParagraphs(DrawTextShape.java:156) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawTextShape.drawContent(DrawTextShape.java:125) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:97) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:71) ~[poi-3.17.jar:3.17]
at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:41) ~[poi-3.17.jar:3.17]
at org.apache.poi.xslf.usermodel.XSLFSlide.draw(XSLFSlide.java:307) ~[tika-server-1.16.jar:1.16]
java apache itext apache-poi apache-tika
java apache itext apache-poi apache-tika
edited Nov 22 at 17:47
mkl
52.3k1165143
52.3k1165143
asked Nov 21 at 15:40
Lez
397
397
1
Don't mix POI versions! Either only use the one bundled in Apache Tika, or only use POI directly, don't combine
– Gagravarr
Nov 21 at 18:26
@Gagravarr thanks that solved it
– Lez
Nov 22 at 13:48
add a comment |
1
Don't mix POI versions! Either only use the one bundled in Apache Tika, or only use POI directly, don't combine
– Gagravarr
Nov 21 at 18:26
@Gagravarr thanks that solved it
– Lez
Nov 22 at 13:48
1
1
Don't mix POI versions! Either only use the one bundled in Apache Tika, or only use POI directly, don't combine
– Gagravarr
Nov 21 at 18:26
Don't mix POI versions! Either only use the one bundled in Apache Tika, or only use POI directly, don't combine
– Gagravarr
Nov 21 at 18:26
@Gagravarr thanks that solved it
– Lez
Nov 22 at 13:48
@Gagravarr thanks that solved it
– Lez
Nov 22 at 13:48
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Solution was to not mix POI versions. Apache Tika already had POI in it
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Solution was to not mix POI versions. Apache Tika already had POI in it
add a comment |
up vote
1
down vote
accepted
Solution was to not mix POI versions. Apache Tika already had POI in it
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Solution was to not mix POI versions. Apache Tika already had POI in it
Solution was to not mix POI versions. Apache Tika already had POI in it
answered Nov 22 at 13:48
Lez
397
397
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415615%2fpptx-to-pdf-error-using-itext-and-pdfgraphics2d%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Don't mix POI versions! Either only use the one bundled in Apache Tika, or only use POI directly, don't combine
– Gagravarr
Nov 21 at 18:26
@Gagravarr thanks that solved it
– Lez
Nov 22 at 13:48