diff --git a/src/libprs500/ebooks/lrf/html/convert_from.py b/src/libprs500/ebooks/lrf/html/convert_from.py index f14edcb1c2..3858cbc4bd 100644 --- a/src/libprs500/ebooks/lrf/html/convert_from.py +++ b/src/libprs500/ebooks/lrf/html/convert_from.py @@ -1079,6 +1079,10 @@ class HTMLConverter(object): if 2*int(ans['sidemargin']) >= factor*int(self.current_block.blockStyle.attrs['blockwidth']): ans['sidemargin'] = int((factor*int(self.current_block.blockStyle.attrs['blockwidth']))/2.) + for prop in ('topskip', 'footskip', 'sidemargin'): + if ans[prop] < 0: + ans[prop] = 0 + return ans def font_properties(self, css): diff --git a/src/libprs500/ebooks/lrf/pylrs/pylrf.py b/src/libprs500/ebooks/lrf/pylrs/pylrf.py index 8cab70cbc3..d0dbd4a609 100644 --- a/src/libprs500/ebooks/lrf/pylrs/pylrf.py +++ b/src/libprs500/ebooks/lrf/pylrs/pylrf.py @@ -78,7 +78,10 @@ def writeByte(f, byte): def writeWord(f, word): if int(word) > 65535: raise LrfError('Cannot encode a number greater than 65535 in a word.') + if int(word) < 0: + raise LrfError('Cannot encode a number < 0 in a word: '+str(word)) f.write(struct.pack("