@ -363,24 +363,29 @@ function BookInfoManager:extractBookInfo(filepath, cover_specs)
-- Proceed with extracting info
local document = DocumentRegistry : openDocument ( filepath )
local loaded = true
if document then
local pages
if document.loadDocument then -- needed for crengine
-- Setting a default font before loading document
-- actually do prevent some crashes
document : setFontFace ( document.default_font )
document : loadDocument ( )
-- Not needed for getting props:
-- document:render()
-- It would be needed to get nb of pages, but the nb obtained
-- by simply calling here document:getPageCount() is wrong,
-- often 2 to 3 times the nb of pages we see when opening
-- the document (may be some other cre settings should be applied
-- before calling render() ?)
if not document : loadDocument ( ) then
-- failed loading, calling other methods would segfault
loaded = false
end
-- For CreDocument, we would need to call document:render()
-- to get nb of pages, but the nb obtained by simply calling
-- here document:getPageCount() is wrong, often 2 to 3 times
-- the nb of pages we see when opening the document (may be
-- some other cre settings should be applied before calling
-- render() ?)
else
-- for all others than crengine, we seem to get an accurate nb of pages
local pages = document : getPageCount ( )
dbrow.pages = pages
pages = document : getPageCount ( )
end
if loaded then
dbrow.pages = pages
local props = document : getProps ( )
if next ( props ) then -- there's at least one item
dbrow.has_meta = ' Y '
@ -433,8 +438,10 @@ function BookInfoManager:extractBookInfo(filepath, cover_specs)
logger.dbg ( " cover for " , filename , " scaled by " , scale_factor , " => " , cbb_w , " x " , cbb_h , " (compressed from " , dbrow.cover_datalen , " to " , cover_dataz : len ( ) )
end
end
end
DocumentRegistry : closeDocument ( filepath )
else
end
if not loaded then
dbrow.unsupported = _ ( " not readable by engine " )
dbrow.cover_fetched = ' Y ' -- so we don't try again if we're called later if cover_specs
end