Skip to content

docx to PDF using reportlab #1249

@vonyang

Description

@vonyang

Is there a way to convert a .docx to .pdf using reportlab?
I have this code but I don't find a way to achieve the addition of each page to canvas.Canvas(), to convert to a pdf without using an external application. I want to add into the canvas each page of the document, like a copy paste or like a screenshot to convert to an image and add it to the canvas.

documentStream = Document(BytesIO(WordStream.getvalue()))
seccion = documentStream.sections[0]
height = seccion.page_height
width = seccion.page_width

application = BytesIO()
documentStream.save(application)
application.seek(0)
canva = canvas.Canvas(application)
canva.setPageSize((round(width.pt), round(height.pt)))

canva.showPage()
canva.save()
application.seek(0)

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