import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.net.URL;
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.bundles.StringId;
class Text extends BasicOutput {
protected BufferedWriter writer;
protected File targetDir;
+ private boolean nextParaIsCover = true;
@Override
public File process(Story story, File targetDir, String targetName)
throws IOException {
String targetNameOrig = targetName;
- targetName += getDefaultExtension();
+ targetName += getDefaultExtension(false);
this.targetDir = targetDir;
}
@Override
- public String getDefaultExtension() {
+ public String getDefaultExtension(boolean readerTarget) {
return ".txt";
}
protected void writeParagraphHeader(Paragraph para) throws IOException {
if (para.getType() == ParagraphType.IMAGE) {
File file = new File(targetDir, getCurrentImageBestName(true));
- Instance.getCache().saveAsImage(new URL(para.getContent()), file);
+ try {
+ Instance.getCache().saveAsImage(para.getContentImage(), file,
+ nextParaIsCover);
+ } catch (IOException e) {
+ Instance.getTraceHandler().error(
+ new IOException("Cannot save an image", e));
+ }
}
+
+ nextParaIsCover = false;
}
@Override