org.pptx4j.samples.XHTMLFragmentToSlide Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docx4j-ImportXHTML-samples Show documentation
Show all versions of docx4j-ImportXHTML-samples Show documentation
docx4j-ImportXHTML converts XHTML to OpenXML WordML (docx) using docx4j
The newest version!
package org.pptx4j.samples;
import java.util.List;
import org.docx4j.openpackaging.packages.PresentationMLPackage;
import org.docx4j.openpackaging.parts.PartName;
import org.docx4j.openpackaging.parts.PresentationML.MainPresentationPart;
import org.docx4j.openpackaging.parts.PresentationML.SlideLayoutPart;
import org.docx4j.openpackaging.parts.PresentationML.SlidePart;
import org.pptx4j.convert.in.xhtml.XHTMLtoPPTX;
public class XHTMLFragmentToSlide {
public static void main(String[] args) throws Exception {
// Where will we save our new .ppxt?
String outputfilepath = System.getProperty("user.dir") + "/OUT_XHTMLFragmentToSlide.pptx";
String content = ""
+ "- bullet1
"
+ "- bullet2
"
+ "- bullet3
"
+ "- bullet4
"
+ "
";
String baseUrl = "file:///C:/Users/jharrop/git/docx4j-ImportXHTML/";
String TXBODY_SHAPE_TEMPLATE =
"" +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" " +
" ";
// Setup target pptx
PresentationMLPackage presentationMLPackage = getPkg();
SlidePart slidePart =(SlidePart) presentationMLPackage.getParts().get(new PartName("/ppt/slides/slide1.xml"));
// TODO - add a convenience method to get slide by slide number!
// Process XHTML
XHTMLtoPPTX converter = new XHTMLtoPPTX(presentationMLPackage, slidePart, content, baseUrl);
converter.setTxBodyShapeTemplate(TXBODY_SHAPE_TEMPLATE);
List