Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert word to pdf #3261

Closed
sunblog3 opened this issue Mar 13, 2024 · 1 comment
Closed

Convert word to pdf #3261

sunblog3 opened this issue Mar 13, 2024 · 1 comment

Comments

@sunblog3
Copy link

Description of the bug

Example:

import fitz

doc = fitz.open("demo.docx")
pdfbytes = doc.convert_to_pdf()

pdf = fitz.open("pdf", pdfbytes)
pdf.save("some.pdf")

demo.docx

How to reproduce the bug

Result error:

Traceback (most recent call last):
  File "E:\dr\venv\Lib\site-packages\fitz\__init__.py", line 2659, in __init__
    self.this = extra.Document_init( filename, stream, filetype, rect, width, height, fontsize)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\dr\venv\Lib\site-packages\fitz\extra.py", line 153, in Document_init
    return _extra.Document_init(filename, stream, filetype, rect, width, height, fontsize)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: code=2: cannot find fixed document sequence start part

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "E:\dr\html_to_pdf.py", line 3, in <module>
    doc = fitz.open("demo.docx")
          ^^^^^^^^^^^^^^^^^^^^^^
  File "E:\dr\venv\Lib\site-packages\fitz\__init__.py", line 2666, in __init__
    raise FileDataError( MSG_BAD_DOCUMENT) from e
fitz.FileDataError: cannot open broken document

PyMuPDF version

1.23.26

Operating system

Linux

Python version

3.11

@julian-smith-artifex-com
Copy link
Collaborator

.docx files are not supported. Please see: https://pymupdf.readthedocs.io/en/latest/how-to-open-a-file.html#supported-file-types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants