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

[BUG] Pandoc cannot find image file unless full relative path is used #81

Open
wychwitch opened this issue Nov 2, 2021 · 5 comments
Open

Comments

@wychwitch
Copy link

@wychwitch wychwitch commented Nov 2, 2021

Hello! I was trying to convert one of my files to PDF, I received the following error

Obsidian_H4jAWcObZZ

The thing is, that picture isn't in the root folder, it's in a nested folder called __Assets.

The full path is C:\Users\Username\Documents\[[Obsidian]]\Folks and Tales\Ash In The Snow\PCs\__Assets

If the full relative path (Ash In The Snow/PCs/__Assets/Axiom.png) is specified, then works. The only way to do this in obsidian (that I know of?) is by having multiple files by the same name, which forces obsidian to have a full relative link to that exact file.

Is there any way to work around this issue? I can provide any files or my exact file structure if needed.

@luckman212
Copy link

@luckman212 luckman212 commented Nov 8, 2021

Came here to report the same issue. Hope it can be solved!

@Alkaceq
Copy link

@Alkaceq Alkaceq commented Nov 14, 2021

subscribing to this one. when in Obsidain Options, Files and Links, I have defined a subfolder name for images, "attachments" for example, all pictures are in /attachments folder. Obsidian sees them and displays render them correctly. Pandoc plugin cannot see them and complains those binaries do not exist.

@ndegroot
Copy link

@ndegroot ndegroot commented Jan 14, 2022

I had a similar problem on Macos. Hope my solution translates to Windows... I tried to specify the image folder by using the parameter in the plugin settings:

--resource-path='[abs_path_name_containing_spaces]'

but it failed with the (no such file or directory) error. Even when I escaped the spaces. Using the same parameter on commandline with pandoc it did work. The problems seems to be that parameters cannot contain spaces when you specify them in the settings for this plugin. The path to the Obsidianvault when placed in iCloud allways contains at least one space. So removing the spaces in the path is impossible. I discovered a pandoc parameter so worked around it by specifying instead:

--defaults=[path_to_yaml_file_no_spaces]

I put an .pandoc-obs.yaml file (you can use any filename withoud spaces) in my homedir (no spaces in the path there). And the yaml-file contains the parameter in YAML syntax:

resource-path: ["/Users/ncdegroot/Library/Mobile Documents/iCloud~md~obsidian/Documents/Notes/00-Meta/03-Attachments"]
That worked. At least after I changed the ![[image_file_name_no_path]] links to the more MD standard !()[image_filename_no_path] to get the image to appear in the generated .docx file. To create .PDF I still need to install some more latex stuff, but thats another story.

Hope its helps!

@DawnPaladin
Copy link

@DawnPaladin DawnPaladin commented Jan 15, 2022

Your solution works on Windows, thank you! Here's what we did:

  • Converted ![[Obsidian image links]] to ![Markdown image links](/path/to/image.png)
  • Created C:/Users/Joshu/pandoc-defaults.yaml, containing this line:
    resource-path: ["C:/Users/Joshu/OneDrive - DIU/Josh Stuff/Obsidian/Attachment Folder"]
  • Added this line to "Extra Pandoc Arguments" in the Pandoc plugin settings:
    --defaults=C:/Users/Joshu/pandoc-defaults.yaml

After following these steps, Pandoc was able to export Markdown files into .docx. Only image links that specified a size at the end (image.png|300) wouldn't work; we'll just clean those out manually.

Thanks for your help with this workaround!

@ZeroCommits
Copy link

@ZeroCommits ZeroCommits commented Feb 20, 2022

While Obsidian is currently not able to copy images from a note, I am currently using this Pandoc plugin to export the images from a note so I am able to publish it on a different platform, in my case Confluence.

A recent extension was added to Pandoc to be able look files relative to the note. To implement this on this plugin I modified line 11286 in main.js file file: inputFile, format: 'markdown', to file: inputFile, format: 'markdown+rebase_relative_paths',. Next, all new links format are set to "Absolute path in vault". This is a very rough workaround. If someone familiar concatenating the links in this plugin to avoid messing with the new links format setting please add it to this plugin. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants