El principio es convertir PPT en PDF y luego usar imágenes para producir PDF. y se puede resolver simplemente buscando el sufijo PPT. Algunas cajas chinas.
Baidu y Google han estado buscando mucho tiempo, y algunas personas dijeron que algunas personas dijeron que era un error en el sitio web oficial de Apache, pero respondieron que era un problema de fuentes. Este problema por sí mismo, y lea la fuente original y la establece en la fuente actual, pero el rendimiento debería haber mucho consumo. Casi no hay soluciones listas en Internet. También intenté paso a paso y finalmente encontré la solución.
El PPTX antes del problema se convierte en una imagen:
Después de la resolución, el PPTX se convierte en una imagen:
Solución:
Lea cada forma y convierta el texto en una fuente unificada.
para (xslfshape shape: slide [i] .getShapes ()) {if (shape instanceo de xslftextshape) {xslftextshape txshape = (xslftextshape) shap + txshape.getShapeName ()); ; El código completo es el siguiente (excepto la solución propia anterior, la mayor parte es el código en StackOverflow):
public static void ConverpptToPDF (String SourcePath, String DestinationPath, String fileType) Lanza la excepción {FileInputStream InputStream = newInputStreA M (SourcePath) PDFDocument = nuevo documento (); SlideImage = NULL; ppt .getSlides (); = 0; k]. ; (PGSI ZE. Altura * Zoom), BufferedImage.Type_int_Rgb); , 0, PGSize. verdadero)); setPageSe (nuevo rectángulo ((float) pgSize.getWidth (), (float) pgsize.getheight ()); i ++) {for (xslfs hape shape: slide [i] .getShapes ()) {if (shapever de xslftextshape) {xslftextshape txshape = (xslftextshape) shape; ) + ":" + txshape. textrunlist = textpara.gettextruns (); ) Math.Ceil (PGSize.Height * Zoom), BufferedImage.type_int_rgb); Float (0, 0, PGSize.Width, PGSize.Height)); ; / Javax. }} PDF Document.Add (Tabla); Configuración maven:
<Spendency> <MoupRoMID> org.apache.poi </groupid> <artifactId> poi </arfactid> <!-<versión> 3.13 </versión>-> <versión> 3.9 </versión> </dependiendo y > <Spendency> <MoupRoid> org.apache.poi </groupid> <artifactid> poi-ooxml </artifactid> <!-<versión> 3.10-fininal </versión>-> <versión> 3.9 </versi en> </pendency> <pepertency> <uproupid> com.ithoutpdf </groupid> <artifactid> ithextpdf </arfactid> <versers> 5.5.7 </versión> </pendency> <ependency> <grupoD> com.itextpdf .Tool </groupid> <artifactid> xmlworker </artifactid> <versión> 5.5.7 </versión> </pendency> <pendency> <proupid> org.apache.poi </proupid> <artif ctid> poi-scratchpad </artifactid> <!-<versión> 3.12 </versever>-> <versión> 3.9 </ververy> </dependence>
Lo anterior es la solución al problema de los chinos confusos en Java para implementar PPT a PDF que ocurre en Java.