admin管理员组

文章数量:1291383

I am trying to convert HTML content into PowerPoint slides using the XHTMLtoPPTX library, but I am encountering this issue:

Table properties such as colspan and rowspan are not being applied and tables without any other properties are coming with correct data.

private void createPPT(String text) throws Exception {
    // Setup target pptx
    PresentationMLPackage presentationMLPackage = getPkg();
    SlidePart slidePart = (SlidePart) presentationMLPackage.getParts().get(new    PartName("/ppt/slides/slide1.xml"));

    StringBuilder content = new StringBuilder();
    content.append("<html><body>");
    content.append(text);
    content.append("</body></html>");

    // Convert HTML to PowerPoint
    XHTMLtoPPTX converter = new XHTMLtoPPTX(presentationMLPackage, slidePart, content.toString(), "");
    List<Object> results = converter.convertSingleSlide();    slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().addAll(results);

    // Save the presentation
    String outputFilePath = "/Users/sunith/Documents/new_presentation2.pptx";
    presentationMLPackage.save(new java.io.File(outputFilePath));

    System.out.println("Done! Saved to " + outputFilePath);
}

public static PresentationMLPackage getPkg() throws Exception {
    // Create package and add slide
    PresentationMLPackage presentationMLPackage = PresentationMLPackage.createPackage();
    MainPresentationPart pp = (MainPresentationPart) presentationMLPackage.getParts().getParts().get(new PartName("/ppt/presentation.xml"));
    SlideLayoutPart layoutPart = (SlideLayoutPart) presentationMLPackage.getParts().getParts().get(new PartName("/ppt/slideLayouts/slideLayout1.xml"));

    // Create a new slide and add layout
    SlidePart slidePart = new SlidePart(new PartName("/ppt/slides/slide1.xml"));
    slidePart.setContents(SlidePart.createSld());
    pp.addSlide(0, slidePart);
    slidePart.addTargetPart(layoutPart);

    return presentationMLPackage;
}

Is it possible to convert HTML to PowerPoint in this way, or are there other approaches that might work better?

本文标签: Issue with colspanrowspan Converting HTML to PowerPoint using XHTMLtoPPTXStack Overflow