Skip to content

Saving to PDF 'Message' object has no attribute 'listdir' #291

@jordiyeh

Description

@jordiyeh

Bug Metadata

  • Version of extract_msg: 0.36.2
  • Your python version: Python 3.10.5
  • How did you launch extract_msg?
    • [X ] My command line or
    • [ X] I used the extract_msg package

Describe the bug
I am following #102 and it results in

msg.save(pdf = True, wkOptions = ['-O', 'Portrait'])

'Message' object has no attribute 'listdir'

[ If applicable ]
**What code did you use or can we use to reproduce this error?

extract_msg --pdf test.msg 

Is there a message.msg file you want to share to help us reproduce this?

  • Uploaded message (drag and drop on this window)
  • Emailed message as an attachment to admins: [Enter Subject Line Here]

Traceback

Error with file "test.msg": Traceback (most recent call last):
  File "/.venv/lib/python3.10/site-packages/extract_msg/message_base.py", line 863, in save
    f.write(self.getSavePdfBody(**kwargs))
  File "/.venv/lib/python3.10/site-packages/extract_msg/message_base.py", line 402, in getSavePdfBody
    raise WKError(output[1].decode('utf-8'))
extract_msg.exceptions.WKError: You need to specify at least one input file, and exactly one output file
Use - for stdin or stdout

Name:
  wkhtmltopdf 0.12.6 (with patched qt)

Synopsis:
  wkhtmltopdf [GLOBAL OPTION]... [OBJECT]... <output file>
  
Document objects:
  wkhtmltopdf is able to put several objects into the output file, an object is
  either a single webpage, a cover webpage or a table of contents.  The objects
  are put into the output document in the order they are specified on the
  command line, options can be specified on a per object basis or in the global
  options area. Options from the Global Options section can only be placed in
  the global options area.

  A page objects puts the content of a single webpage into the output document.

  (page)? <input url/file name> [PAGE OPTION]...
  Options for the page object can be placed in the global options and the page
  options areas. The applicable options can be found in the Page Options and 
  Headers And Footer Options sections.

  A cover objects puts the content of a single webpage into the output document,
  the page does not appear in the table of contents, and does not have headers
  and footers.

  cover <input url/file name> [PAGE OPTION]...
  All options that can be specified for a page object can also be specified for
  a cover.

  A table of contents object inserts a table of contents into the output
  document.

  toc [TOC OPTION]...
  All options that can be specified for a page object can also be specified for
  a toc, further more the options from the TOC Options section can also be
  applied. The table of contents is generated via XSLT which means that it can
  be styled to look however you want it to look. To get an idea of how to do
  this you can dump the default xslt document by supplying the
  --dump-default-toc-xsl, and the outline it works on by supplying
  --dump-outline, see the Outline Options section.

Description:
  Converts one or more HTML pages into a PDF document, using wkhtmltopdf patched
  qt.

Global Options:
      --collate                       Collate when printing multiple copies                                      (default)
      --no-collate                    Do not collate when printing multiple                                      copies
      --copies <number>               Number of copies to print into the pdf                                      file (default 1)
  -H, --extended-help                 Display more extensive help, detailing                                      less common command switches
  -g, --grayscale                     PDF will be generated in grayscale
  -h, --help                          Display help
      --license                       Output license information and exit
      --log-level <level>             Set log level to: none, error, warn or                                      info (default info)
  -l, --lowquality                    Generates lower quality pdf/ps. Useful to                                      shrink the result document space
  -O, --orientation <orientation>     Set orientation to Landscape or Portrait                                      (default Portrait)
  -s, --page-size <Size>              Set paper size to: A4, Letter, etc.                                      (default A4)
  -q, --quiet                         Be less verbose, maintained for backwards                                      compatibility; Same as using --log-level                                      none
      --read-args-from-stdin          Read command line arguments from stdin
      --title <text>                  The title of the generated pdf file (The                                      title of the first document is used if not                                      specified)
  -V, --version                       Output version information and exit
Page Options:
      --print-media-type              Use print media-type instead of screen
      --no-print-media-type           Do not use print media-type instead of                                      screen (default)
Contact:
  If you experience bugs or want to request new features please visit 
  <https://wkhtmltopdf.org/support.html>



During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.venv/lib/python3.10/site-packages/extract_msg/__main__.py", line 112, in main
    msg.save(**kwargs)
  File "/.venv/lib/python3.10/site-packages/extract_msg/message_base.py", line 871, in save
    self.saveRaw(path)
  File "/.venv/lib/python3.10/site-packages/extract_msg/msg.py", line 526, in saveRaw
    for dir_ in self.listdir():
AttributeError: 'Message' object has no attribute 'listdir'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions