Skip to content

Saving PDFs with buffered writer leads to corruption #40

Description

@treigerm

Saving PDFs with the snippet

with outfile.open("wb") as f:
    plt.savefig(f, dpi=300)

leads to corrupted PDFs. The code executes perfectly fine but the files cannot be opened (see below for error when trying to open the file with Preview on Mac OS 15.4.1).

Image

Using the approach

plt.savefig(outfile, dpi=300)

leads to uncorrupted files.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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