cycomanic / Menextract2pdf

Extract Mendely annotations to PDF FIles
GNU General Public License v3.0
35 stars 15 forks source link

Fail to open PDF Files. "Could not find pdffile~" #22

Open shga89 opened 4 years ago

shga89 commented 4 years ago

In the process of the opening original PDF files, this error below occurred.

"Could not find pdffile C:\C:\Users**\AppData\Local\Mendeley Ltd\Mendeley Desktop\Downloaded**.pdf"

The problem was the misrecognized file directory path, "C:\C:\".

"C:\" is duplicated twice.

I added one line to the coverturl2abspath method in the original code.

pth = pth.lstrip('/')

def converturl2abspath(URL):
    """Convert a url string to an absolute path"""
    try:
        pth = unquote(urlparse(url).path) #this is necessary for filenames with unicode strings
    except:
        pth = unquote(str(urlparse(url).path)).decode("utf8") #this is necessary for filenames with unicode strings
    pth = pth.lstrip('/')
    return os.path.abspath(pth)

After modifying the code, the adding annotations process had well-done, but I didn't modify the code in GitHub because I am not sure if this error occurs the same in all users.