-
Notifications
You must be signed in to change notification settings - Fork 121
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
PDF generation doesn't respect "resources" configuration attribute #291
Comments
That's kind of expected. Maybe we should add a warning in the README to avoid confusions. In order to solve this, you can setup the
But beware, because this affects the document, so once imagesdir is modified the new value remains. Alternatively, you could try to build an extension that adjustes the imagesdir dinamically looking for images in diferent directories, but I think the option above is more manteinable. |
I think we need to take a step back and focus on "That's kind of expected". The HTML and PDF converters need images at different times. The PDF converter needs the image at the time of the conversion since it embeds the image into the output document. The HTML converter needs the image at the time the document is viewed, so those images need to be copied along with the HTML (unless There is no need to copy resources when converting to PDF. Everything goes in the PDF document. However, it does mean that the imagesdir needs to point to the source location of the images. If for some reason it needs to be different, just set The one exception is if you have a mix of static source images and generated images (via Asciidoctor Diagram). In that case, things get trickier. You need to first copy the static source images to the output folder, then configure Asciidoctor Diagram to write images to that location, and finally configure Asciidoctor to look in the generated images folder to resolve all images. No doubt, this is the hardest scenario to configure...but AFAIK it is possible. When converting to HTML, the imagesdir should be the relative path from the HTML document to the image...as it is the browser that uses this value to resolve the image. |
If there are ways we can make this simpler either through code changes or documentation changes, I'm 100% in favor. I'm just trying to help you understand the scenarios first. |
In this case, you'll want to set the imagesdir attribute in the plugin configuration to the absolute path of the target images directory (the directory where you are collecting all the images). Asciidoctor PDF uses a system path to read in the images, so an absolute path will work here. |
It's important to keep in mind that Asciidoctor PDF essentially requires that all images be in the same directory (or relative to that directory). I refer to this as the images "catalog". This catalog can be anywhere though. The image "target" is the path relative to this catalog root. That's the best way to think of it. |
We could add and option to enable some sort of
Note that From a design stand point, it can be made in a way that other backends can 'hook' custom logic in the future. But this should be optional, so that if someone wants to tailor the whole process manually it can still be done. |
I think it's worth exploring that route. We should emphasize, though, that this is only necessary if you're merging images from multiple source locations (including using Asciidoctor Diagram to generate images to a temporary folder). If you are not, conversion to PDF is actually simpler since you don't have to move images at all. |
…ltiple resources for PDF
…urces (#292) * related to #291 - added note regarding configuration of multiple resources for PDF * Added @mojavelinux suggestions
@abelsromero Agreed with in PDF appproach of "first copy all resources directories" to a generated directory and then use that as the images input directory |
@mojavelinux Why doesn't asciidoctor want to support multiple images directories? For our use case, we have several guides (= several maven modules) that have a set of shared adoc files (which contain images). So we have this:
With only 1 images directory, we'd have to put pullRequestScreenshot.png, droolsLogo.png and jbpmLogo.png in the same maven module in the same git repository. This makes it painful to build out a reusable set of common adoc sections for an organization, such as:
|
Because Asciidoctor doesn't check for the presence of the image, at least not in all cases. Though I suppose that if a certain attribute is set, such as imagedirs, then that behavior could be introduced. That would have to happen in core, though. And, we'd still have to differentiate between source image directories and image paths in the output document (such as in the case of HTML). |
Using the "resources" element in the plugin configuration, we can grab images from 2 directories. We use this to include shared images and a book-specific images. This works perfectly for the html output.
However for the PDF output, configured like this:
The images end up broken in the pdf and the maven console shows messages like these for images not residing in src/main/asciidoc:
The text was updated successfully, but these errors were encountered: