diff --git a/src/calibre/ebooks/metadata/rtf.py b/src/calibre/ebooks/metadata/rtf.py index 0eae93a8d3..770d770909 100644 --- a/src/calibre/ebooks/metadata/rtf.py +++ b/src/calibre/ebooks/metadata/rtf.py @@ -6,6 +6,7 @@ Edit metadata in RTF files. """ import re, cStringIO, codecs +from calibre import force_unicode from calibre.ebooks.metadata import MetaInformation, string_to_authors title_pat = re.compile(r'\{\\info.*?\{\\title(.*?)(? 1: md.append('}') @@ -165,7 +171,7 @@ def set_metadata(stream, options): index = src.rindex('}') return src[:index] + r'{\ '[:-1] + name + ' ' + val + '}}' src, pos = get_document_info(stream) - if src is not None: + if src is None: create_metadata(stream, options) else: olen = len(src) @@ -173,7 +179,7 @@ def set_metadata(stream, options): base_pat = r'\{\\name(.*?)(?