metebalci / pdftitle

a utility to extract the title from a PDF file
GNU General Public License v3.0
131 stars 21 forks source link

feat: pass args via run #34

Open dwahdany opened 1 year ago

dwahdany commented 1 year ago

Fixes #33

This should be the most minimal-invasive way of passing arguments to pdftitle when calling it from another python module. It allows the module to be used in conjunction with contextlib as shown in the following example

import pdftitle
from contextlib import redirect_stdout
import io
with redirect_stdout(io.StringIO()) as s:
    pdftitle.run(['-p', file_path, '-a', 'max2'])
title = s.getvalue()
metebalci commented 1 year ago

Actually I didnt plan pdftitle to be embedded or used as a library, it is a command line utility, so none of such uses are considered. However, it seems there is an interest in this but I probably have to change more.