bbox = bbox.addPadding(getPaddingSize());
BufferedImage img = toolkit.renderToBufferedImage(page, bbox, viewSpec);
String imageFile = String.format("images/page%04d.%s", pn, formatExt);
- String filename = String.format("sample/page%06d.%s", pn, formatExt);
- File png = new File(filename);
+ File png = File.createTempFile("dvi2epub", "." + formatExt);
+ png.deleteOnExit();
ImageIO.write(img, formatName, png);
epubWriter.writeFile(imageFile, formatMime, png, false, false, false);
String docType = "<?xml version='1.0' encoding='UTF-8'?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
epubWriter.writeFile(String.format("page%04d.html", pn), "application/x-html",
String.format("%s<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='ja' lang='ja'><body>%s<img src='images/page%04d.%s' /></body></html>", docType, body, pn, formatExt)
, true, true, true);
+ png.delete();
}
epubWriter.close();
System.out.println();