thanks for the input, jason.
i tried the altChunk strategy and had excellent results. here's a snippet of the code I use to do it:
there was some trial and error as far as getting the proper content type and getting the part names right, but once I got that right, it's been working perfectly since.
for others' readability sake, altChunkCount is just a static int I use to avoid duplicate names, and the factory is just the standard ObjectFactory
- Code: Select all
public static void insertHtml(MainDocumentPart main, String html) {
try {
html = html.trim();
if (!html.startsWith("<html>")) {
html = "<html>" + html;
}
if (!html.endsWith("</html>")) {
html = html + "</html>";
}
AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(new PartName("/test" + altChunkCount++ + ".html"));
afiPart.setContentType(new ContentType("text/html"));
afiPart.setBinaryData(html.getBytes());
Relationship altChunkRel = main.addTargetPart(afiPart);
CTAltChunk chunk = factory.createCTAltChunk();
chunk.setId(altChunkRel.getId());
main.addObject(chunk);
}
catch (Exception e) {
e.printStackTrace();
}
}