mirror of
https://github.com/sismics/docs.git
synced 2024-11-17 03:37:56 +01:00
upgrade opensagres.xdocreport
This commit is contained in:
parent
9b1456e1a7
commit
156e67bc52
@ -140,12 +140,12 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>fr.opensagres.xdocreport</groupId>
|
||||
<artifactId>org.odftoolkit.odfdom.converter.pdf</artifactId>
|
||||
<artifactId>fr.opensagres.odfdom.converter.pdf</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>fr.opensagres.xdocreport</groupId>
|
||||
<artifactId>org.apache.poi.xwpf.converter.pdf</artifactId>
|
||||
<artifactId>fr.opensagres.poi.xwpf.converter.pdf</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ImageIO plugins -->
|
||||
|
@ -3,6 +3,8 @@ package com.sismics.docs.core.util.format;
|
||||
import com.google.common.io.Closer;
|
||||
import com.sismics.util.context.ThreadLocalContext;
|
||||
import com.sismics.util.mime.MimeType;
|
||||
import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
|
||||
import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions;
|
||||
import org.apache.pdfbox.io.MemoryUsageSetting;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
@ -60,8 +62,8 @@ public class DocxFormatHandler implements FormatHandler {
|
||||
try (InputStream inputStream = Files.newInputStream(file);
|
||||
OutputStream outputStream = Files.newOutputStream(temporaryPdfFile)) {
|
||||
XWPFDocument document = new XWPFDocument(inputStream);
|
||||
org.apache.poi.xwpf.converter.pdf.PdfOptions options = org.apache.poi.xwpf.converter.pdf.PdfOptions.create();
|
||||
org.apache.poi.xwpf.converter.pdf.PdfConverter.getInstance().convert(document, outputStream, options);
|
||||
PdfOptions options = PdfOptions.create();
|
||||
PdfConverter.getInstance().convert(document, outputStream, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,10 @@ package com.sismics.docs.core.util.format;
|
||||
import com.google.common.io.Closer;
|
||||
import com.sismics.util.context.ThreadLocalContext;
|
||||
import com.sismics.util.mime.MimeType;
|
||||
import fr.opensagres.odfdom.converter.pdf.PdfConverter;
|
||||
import fr.opensagres.odfdom.converter.pdf.PdfOptions;
|
||||
import org.apache.pdfbox.io.MemoryUsageSetting;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.odftoolkit.odfdom.converter.pdf.PdfConverter;
|
||||
import org.odftoolkit.odfdom.converter.pdf.PdfOptions;
|
||||
import org.odftoolkit.odfdom.doc.OdfTextDocument;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
@ -19,6 +19,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PPTX format handler.
|
||||
@ -39,7 +40,7 @@ public class PptxFormatHandler implements FormatHandler {
|
||||
@Override
|
||||
public BufferedImage generateThumbnail(Path file) throws Exception {
|
||||
XMLSlideShow pptx = loadPPtxFile(file);
|
||||
if (pptx.getSlides().length > 0) {
|
||||
if (pptx.getSlides().size() > 0) {
|
||||
return generateImageFromSlide(pptx, 0);
|
||||
}
|
||||
|
||||
@ -55,9 +56,9 @@ public class PptxFormatHandler implements FormatHandler {
|
||||
@Override
|
||||
public void appendToPdf(Path file, PDDocument doc, boolean fitImageToPage, int margin, MemoryUsageSetting memUsageSettings, Closer closer) throws Exception {
|
||||
XMLSlideShow pptx = loadPPtxFile(file);
|
||||
XSLFSlide[] slides = pptx.getSlides();
|
||||
List<XSLFSlide> slides = pptx.getSlides();
|
||||
Dimension pgsize = pptx.getPageSize();
|
||||
for (int slideIndex = 0; slideIndex < slides.length; slideIndex++) {
|
||||
for (int slideIndex = 0; slideIndex < slides.size(); slideIndex++) {
|
||||
// One PDF page per slide
|
||||
PDPage page = new PDPage(new PDRectangle(pgsize.width, pgsize.height));
|
||||
try (PDPageContentStream contentStream = new PDPageContentStream(doc, page)) {
|
||||
@ -91,7 +92,7 @@ public class PptxFormatHandler implements FormatHandler {
|
||||
Graphics2D graphics = img.createGraphics();
|
||||
graphics.setPaint(Color.white);
|
||||
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
|
||||
pptx.getSlides()[slideIndex].draw(graphics);
|
||||
pptx.getSlides().get(slideIndex).draw(graphics);
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
6
pom.xml
6
pom.xml
@ -38,7 +38,7 @@
|
||||
<joda-time.joda-time.version>2.9.2</joda-time.joda-time.version>
|
||||
<org.hibernate.hibernate.version>5.1.0.Final</org.hibernate.hibernate.version>
|
||||
<javax.servlet.javax.servlet-api.version>3.1.0</javax.servlet.javax.servlet-api.version>
|
||||
<fr.opensagres.xdocreport.version>1.0.5</fr.opensagres.xdocreport.version>
|
||||
<fr.opensagres.xdocreport.version>2.0.1</fr.opensagres.xdocreport.version>
|
||||
<net.java.dev.jna.jna.version>4.2.1</net.java.dev.jna.jna.version>
|
||||
<com.twelvemonkeys.imageio.version>3.3.2</com.twelvemonkeys.imageio.version>
|
||||
<com.levigo.jbig2.levigo-jbig2-imageio.version>1.6.5</com.levigo.jbig2.levigo-jbig2-imageio.version>
|
||||
@ -401,13 +401,13 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>fr.opensagres.xdocreport</groupId>
|
||||
<artifactId>org.odftoolkit.odfdom.converter.pdf</artifactId>
|
||||
<artifactId>fr.opensagres.odfdom.converter.pdf</artifactId>
|
||||
<version>${fr.opensagres.xdocreport.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>fr.opensagres.xdocreport</groupId>
|
||||
<artifactId>org.apache.poi.xwpf.converter.pdf</artifactId>
|
||||
<artifactId>fr.opensagres.poi.xwpf.converter.pdf</artifactId>
|
||||
<version>${fr.opensagres.xdocreport.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user