Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docx to pdf, file link path error #145

Open
erild opened this issue Nov 12, 2019 · 1 comment
Open

docx to pdf, file link path error #145

erild opened this issue Nov 12, 2019 · 1 comment
Labels
bug Something isn't working libreoffice

Comments

@erild
Copy link

erild commented Nov 12, 2019

I am using the gotenberg docker to convert a docx containing relative file links into a pdf.
The link path are not kept through the convertion:
For a link file:///./annexes/dir/file.xlsx, after convertion, the link is transformed into ../../.././annexes/dir/file.xlsx instead of ./annexes/dir/file.xlsx

Expected Behavior

For a link (in the OOXML) file:///./annexes/dir/file.xlsx, after convertion, the link is should be ./annexes/dir/file.xlsx

Current Behavior

For a link file:///./annexes/dir/file.xlsx, after convertion, the link is transformed into ../../.././annexes/dir/file.xlsx instead of ./annexes/dir/file.xlsx

Possible Solution

Not really sure what the issue is, i haven't looked much into the code of the conversion yet. It may be due to the command used to launch the conversion (The link is correct when i use unoconv -f pdf testing.docx to do the conversion).
Maybe launch the command from inside the temporary directory created

Steps to Reproduce (for bugs)

testing ll.pdf
testing ll.docx

I joined a docx (and the converted pdf) where the issue is visible. To reproduce:

  1. Create a docx with a link to a file or download the docx file provided
  2. Launch the conversion to pdf
  3. Check the link in the pdf

Logs (LOG_LEVEL="DEBUG")

Not really useful here, except for the command launch to convert

{"level":"debug","msg":"executing command: unoconv --user-profile ///tmp/45281 --port 45281 --format pdf --output /gotenberg/tmp/BNKaM8uNWfGsAzpvkbQzMDlvuDvFqvyO/0qH9WdO4R3yHZGmppRreJEGa36S8h8xe6.pdf /gotenberg/tmp/BNKaM8uNWfGsAzpvkbQzMDlvuDvFqvyO/testing.docx","op":"xexec.LogBeforeExecute","time":"2019-11-12T12:04:10Z","trace":"BNKaM8uNWfGsAzpvkbQzMDlvuDvFqvyO"}

Context

This is for delivering a archive containing the pdf and a list of assorted xls files which can be opened from the pdf (or the docx) instead of needing to browse through the folder to find the right one

Your Environment

I reproduced the issue with a simple docker run --rm -p 3000:3000 -e LOG_LEVEL="DEBUG" thecodingmachine/gotenberg:6 and a curl post request curl --request POST --url http://localhost:3000/convert/office --header 'Content-Type: multipart/form-data' --form files=@PATH_TO_FILE/testing.docx -o ./result.pdf

@gulien gulien added the bug Something isn't working label Nov 12, 2019
@gulien
Copy link
Collaborator

gulien commented Dec 3, 2019

Hello @erild

Thank you for the well written issue!

Maybe launch the command from inside the temporary directory created

As suggested, I've tried this:

unoconv --user-profile ///tmp/40843 --port 40843 --format pdf --output 0SayLHLBOpzbIo3scrCcbN2s7QJ09GQfk.pdf testing.ll.docx

But no luck so far!

As far as I understand, unoconv resolves the / from /annexes... as the root path on the system. This is why we're getting ../../../assets because the conversion occurs in a path like /gotenberg/tmp/randomFolderName.

I've tried to update the link in the docx file with file:///./annexes/... instead of file:///annexes/... but again no luck.

@gulien gulien added this to the 7.0.0 milestone Jun 24, 2020
@gulien gulien removed this from the 7.0.0 milestone Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libreoffice
Projects
None yet
Development

No branches or pull requests

2 participants