EpubWriter.write fails

182 views
Skip to first unread message

René Kirchmann

unread,
Nov 21, 2011, 2:22:07 PM11/21/11
to epublib
When I try to execute the sample create epub, I get a
NullPointerException at the write mehtod on EpubWriter:

Exception in thread "main" java.lang.NullPointerException
at org.kxml2.io.KXmlSerializer.attribute(Unknown Source)
at
nl.siegmann.epublib.epub.PackageDocumentMetadataWriter.writeMetaData(PackageDocumentMetadataWriter.java:
93)
at
nl.siegmann.epublib.epub.PackageDocumentWriter.write(PackageDocumentWriter.java:
45)
at
nl.siegmann.epublib.epub.EpubWriter.writePackageDocument(EpubWriter.java:
112)
at nl.siegmann.epublib.epub.EpubWriter.write(EpubWriter.java:53)
...

Do you have any idea what I have made wrong? I have build the core
library with Apacke Maven 3.0.3 and included the generated epublib-
core-3.0-SNAPSHOT-complete.jar in my Eclise project.

BR René

Kevin Gaudin

unread,
Jan 21, 2012, 7:35:14 PM1/21/12
to epu...@googlegroups.com
I have the same issue here.
Actually, I've been able to create nice epubs. But now that I try to include a cover, it fails with the same error.
If I remove the cover, it works.

Kevin

Paul Siegmann

unread,
Feb 5, 2012, 4:40:58 PM2/5/12
to epublib
hmm, it should work just fine.

Can you copy-paste the code you're using ?

regards,
Paul

Heinrik Honculada

unread,
Feb 7, 2012, 9:31:53 AM2/7/12
to epu...@googlegroups.com
For trying to grab images I am trying to do book.getCoverPage or book.getCoverImage. However on book.getCoverPage or book.getCoverImage which then returns a l.siegman type "Resource" which then I try to get the actual image using book.getCoverImage.getData() which returns a byte[].

I tried doing this

 byte[] data = bookLoaded().getCoverPage().getData();
        Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
        image_view.setImageBitmap(bmp); //No output.

I even tried treating it  as a  folder and tried to get the image out of it.
        try{
            AssetManager am;
            String fileLoc = bookLoaded().getCoverPage().getHref();
            String fileComplete = bookName + "/" + fileLoc;
            Log.i("Text Location Details: ", fileComplete);
            TextView tv = (TextView)findViewById(R.id.tv);
            tv.setText(fileComplete);
            Bitmap bmp = BitmapFactory.decodeFile(fileComplete);
            image_view.setImageBitmap(bmp);
        }catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }//Doesn't work since epubs are technically zip files which has a bunch of html pages.

I also tried different things: "http://stackoverflow.com/questions/9163627/loading-resource-to-bitmap-which-resource-is-taken-from-an-nl-siegmann-epublib"

I still am doing more researching.



    public Book bookLoaded(){
        AssetManager am = getAssets();
        try{
            InputStream is = am.open(bookName5);
            book = (new EpubReader()).readEpub(is);
        }catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return book;

Paul Siegmann

unread,
Feb 7, 2012, 9:38:48 AM2/7/12
to epu...@googlegroups.com
Have a look at http://www.pageturner-reader.org/ for some example code.

--
paul

Heinrik Honculada

unread,
Feb 7, 2012, 12:14:35 PM2/7/12
to epu...@googlegroups.com
Oh man thanks a lot. I found out it was simply because of an xml issue. The basic textview item has somehow overlapping my imageview item. The pageturner apk is really well done.
My version is using textview to implement text to speech. Thanks a lot you really helped me out a lot.

Fahad Anjum

unread,
Mar 11, 2014, 6:10:38 AM3/11/14
to epu...@googlegroups.com
Hello,

Could you give me an example of how to show text and image together
with android (code).
I can show only the text in a webview but the style css and images are
not being displayed.


I read the FAQ section and could not get to override the load (url) of
the WebView to show the pictures along with text.

Could you give an example?

Thanks a lot for your help,



Reply all
Reply to author
Forward
0 new messages