-
Notifications
You must be signed in to change notification settings - Fork 940
Closed
Labels
Description
Expected it to work. Actual is it won't do anything
Using Windows 10 & 11
Python 3.9 - 3.11
To make the convert_from_path() work I have had to make 2 changes to the library EVERY release.
Let me know if there is a better way to get this to work every release so I don't need to hack the code
First need to change the call to:
args = _build_command(
["-r", str(dpi)],
pdf_path,
output_folder,
Then replace the _build_command() in its entirety as its easier then making a bunch of changes
def _build_command(
args,
pdf_path,
output_folder,
first_page,
last_page,
fmt,
jpegopt,
output_file,
userpw,
use_cropbox,
transparent,
single_file,
grayscale,
size,
hide_annotations,
):
if use_cropbox:
args.append("-cropbox")
if hide_annotations:
args.append("-hide-annotations")
if transparent and fmt in TRANSPARENT_FILE_TYPES:
args.append("-transp")
if first_page is not None:
args.extend(["-f", str(first_page)])
if last_page is not None:
args.extend(["-l", str(last_page)])
if fmt not in ["pgm", "ppm"]:
args.append("-" + fmt)
if fmt in ["jpeg", "jpg"] and jpegopt:
args.extend(["-jpegopt", _parse_jpegopt(jpegopt)])
if single_file:
args.append("-singlefile")
args.append(pdf_path)
if output_folder is not None:
args.append(os.path.join(output_folder, output_file))
if userpw is not None:
args.extend(["-upw", userpw])
if grayscale:
args.append("-gray")
if size is None:
pass
elif isinstance(size, tuple) and len(size) == 2:
if size[0] is not None:
args.extend(["-scale-to-x", str(int(size[0]))])
else:
args.extend(["-scale-to-x", str(-1)])
if size[1] is not None:
args.extend(["-scale-to-y", str(int(size[1]))])
else:
args.extend(["-scale-to-y", str(-1)])
elif isinstance(size, tuple) and len(size) == 1:
args.extend(["-scale-to", str(int(size[0]))])
elif isinstance(size, int) or isinstance(size, float):
args.extend(["-scale-to", str(int(size))])
else:
raise ValueError("Size {} is not a tuple or an integer")
return args