Skip to content

Messed downloaded filename #23

@bobonov

Description

@bobonov

python 3.12.7 in windows 11

Executing a task (tested with compress and unlock) and then downloading the file, result in messed name when saved on the disk.
the script is the following:


from pylovepdf.ilovepdf import ILovePdf

project_key = 'project_public_123mykey456'

pdf_file_path = "C:\\path\\to\\the\\file\\my_pdf.pdf"
download_dir = "C:\\download\\dir\\path\\"

ilovepdf = ILovePdf(project_key, verify_ssl=True)

task_compress = ilovepdf.new_task('compress')
task_compress.add_file(pdf_file_path)
task_compress.set_output_folder(download_dir)
task_compress.execute()
task_compress.download()
task_compress.delete_current_task()

task_unlock = ilovepdf.new_task('unlock')
task_unlock.add_file(pdf_file_path)
task_unlock.set_output_folder(download_dir)
task_unlock.execute()
task_unlock.download()
task_unlock.delete_current_task()

I would expect the file to preserve the name but as from the console I get the following


Uploading file...
File uploaded! Below file stats:
download_filename: C:\path\to\the\file\my_pdf_compress_19-11-2024.pdf 
filesize: 834572 
output_extensions: ["pdf"] 
output_filenumber: 1 
output_filesize: 198742 
status: TaskSuccess 
timer: 0.254 

Downloading processed file...
File downloaded!
Task delete status: 200 

Uploading file...
File uploaded! Below file stats:
download_filename: C:\path\to\the\file\my_pdf_unlock_19-11-2024.pdf 
filesize: 834572 
output_extensions: ["pdf"] 
output_filenumber: 1 
output_filesize: 828766 
status: TaskSuccess 
timer: 0.110 

Downloading processed file...
File downloaded!
Task delete status: 200 

The file is saved under the expected directory, but the filename is the whole original file path plus compress/unlock
C:\download\dir\path\path_to_the_file_my_pdf_compress_19-11-2024.pdf
C:\download\dir\path\path_to_the_file_my_pdf_unlock_19-11-2024.pdf

the path \path\to\the\file has been converted and included as part of the filename

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