I want to output from Japanese vertical ePub file to jpeg files and text, and I tried to use Aspose.pdf Java version 22.2. And I used sample data downloaded from here. https://www.naigai-net.co.jp/ebook/sample.html
However, the output image was shredded and not as expected. Probably, the page was not acquired correctly. Please suggest how to output from vertical ePub file to jpeg files and text correctly.
Sample code:
public static void main(String[] args) {
try (InputStream input = new FileInputStream("input.epub");) {
InputStream input = new FileInputStream("input.epub");
EpubLoadOptions options = new EpubLoadOptions();
Document epubDocument = new Document(input, options);
PageCollection epubPages = epubDocument.getPages();
if (epubPages == null) {
return;
}
int size = epubPages.size();
for (int i=1; i<=size; i++) {
// Image output
Page epubPage = Optional.of(epubPages.get_Item(i)).orElseThrow();
try (OutputStream imageStream = new FileOutputStream("output_" + i + ".jpg")) {
JpegDevice jpegDevice = new JpegDevice();
jpegDevice.process(epubPage, imageStream);
}
// Text output
try (BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"))) {
if (bw != null) {
TextFragmentAbsorber textAbsorber = new TextFragmentAbsorber();
epubPage.accept(textAbsorber);
String extractedText = textAbsorber.getText();
bw.write(extractedText);
bw.newLine();
}
}
}
}
}
epub.zip (1.0 MB)