Skip to content

Unable to use path in output_path #6

Description

@terminalkitten

When using multiple urls, if given a path instead of filename, will result in error

 await pdfgen.from_url(['http://example.com/1', 'http://example.com/2'], 'files/example.pdf', options=options)

 [Errno 2] No such file or directory: '/var/folders/rj/ckmfygyj6sgc_4qd3mg0pq_c0000gn/T/files/example.pdf-0-0wca2ipo.pdf'

The prefix set on NamedTemporaryFile is incorrect and wil result in file not found error.

def _get_output_path(self, path, i, count):
    if count > 1:
        return NamedTemporaryFile(prefix=f'{path}-{i}-', suffix='.pdf', delete=False).name
    else:
        return path

So I think the NamedTemporaryFile should use tail of the path as prefix and suffix.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions