We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Vertical ePub convert to jpg and text

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)

@Yusuke_Kitamura

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFJAVA-41501. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.