Using Relative URLs for images.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using Relative URLs for images.

Steve Jerman
Hi folks,

At present Doxia (specifically the PDF plugin) only supports images with
URLs taken from the classpath or as absolute URLs. This doesn¹t affect
normal site generation since that just passes through the URL without
resolution and so everything works OK.

However, the PDF plugin tries to resolve the path names to images and with a
normal maven site/resources/images layout that that won¹t work. The reason
is that the Œbase¹ for resolving relative  file paths URLs is wrong by
default.

If I use the following pom config:

            <plugin>
                <groupId>org.apache.maven.doxia</groupId>
                <artifactId>doxia-maven-plugin</artifactId>
                <version>1.1.3-SNAPSHOT</version>
                <executions>
                    <execution>
                        <phase>site</phase>
                        <goals>
                            <goal>render-books</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                   
<generatedDocs>${project.build.directory}/site</generatedDocs>
                    <books>
                        <book>
                            <directory>src/site/apt</directory>
                            <descriptor>src/site/dev-guide.xml</descriptor>
                            <formats>
                                <format>
                                    <id>pdf</id>
                                </format>
                            </formats>
                        </book>
                    </books>
                </configuration>
            </plugin>

And change the location that Œitext.basedir¹ is set to (in 3-4 places...).

org.apache.maven.doxia.book.services.renderer.AbstractITextBookRenderer
org.apache.maven.doxia.docrenderer.itext.AbstractITextRender
org.apache.maven.doxia.docrenderer.pdf.itext.ITextPdfRenderer
org.apache.maven.doxia.module.itext.ITextSink

To..
        System.setProperty( "itext.basedir",
bookFile.getParentFile().getParentFile().getAbsolutePath() );

So that it looks two levels up rather than one level up... Everything seems
to work OK.

What the changes do are:

Generate the PDF to the site directory rather than it¹s own directory.
Create the site before generating PDFs .. note this puts the images in a
Œknown place¹ relative to the PDF output.
Set up the base for resolution to be consistent for both html and pdf
generation.

So... having said that, I¹m wondering what do to do next..

This change isn¹t entirely backwards compatible (but maybe someone can
figure out a way to make it so). I will create a patch for the change but am
not sure if it is worth doing if it isn¹t backwards compatible.. The
alternative is to keep a private version...

I know that a colleague of mine raised a Jira (
http://jira.codehaus.org/browse/DOXIA-356) on this subject.

Any thoughts?

Steve
Reply | Threaded
Open this post in threaded view
|

Re: Using Relative URLs for images.

Lukas Theussl-3
I assume you are only having trouble with the doxia book code/doxia maven
plugin, which is different from the maven pdf plugin (
http://maven.apache.org/plugins/maven-pdf-plugin/). I consider the book code
unmaintained and immature, I actually thought of deprecating it if nobody
comes up to give it some care. However, there are a few issues open related
to your problem (are you aware in particular of DOXIA-354, DOXIA-355?), I
would certainly consider patches if they are accompanied by reproducible
test cases...

Cheers,
-Lukas


On Thu, Dec 17, 2009 at 7:38 PM, Steve Jerman <[hidden email]> wrote:

> Hi folks,
>
> At present Doxia (specifically the PDF plugin) only supports images with
> URLs taken from the classpath or as absolute URLs. This doesn¹t affect
> normal site generation since that just passes through the URL without
> resolution and so everything works OK.
>
> However, the PDF plugin tries to resolve the path names to images and with
> a
> normal maven site/resources/images layout that that won¹t work. The reason
> is that the Œbase¹ for resolving relative  file paths URLs is wrong by
> default.
>
> If I use the following pom config:
>
>            <plugin>
>                <groupId>org.apache.maven.doxia</groupId>
>                <artifactId>doxia-maven-plugin</artifactId>
>                <version>1.1.3-SNAPSHOT</version>
>                <executions>
>                    <execution>
>                        <phase>site</phase>
>                        <goals>
>                            <goal>render-books</goal>
>                        </goals>
>                    </execution>
>                </executions>
>                <configuration>
>
> <generatedDocs>${project.build.directory}/site</generatedDocs>
>                    <books>
>                        <book>
>                            <directory>src/site/apt</directory>
>                            <descriptor>src/site/dev-guide.xml</descriptor>
>                            <formats>
>                                <format>
>                                    <id>pdf</id>
>                                </format>
>                            </formats>
>                        </book>
>                    </books>
>                </configuration>
>            </plugin>
>
> And change the location that Œitext.basedir¹ is set to (in 3-4 places...).
>
> org.apache.maven.doxia.book.services.renderer.AbstractITextBookRenderer
> org.apache.maven.doxia.docrenderer.itext.AbstractITextRender
> org.apache.maven.doxia.docrenderer.pdf.itext.ITextPdfRenderer
> org.apache.maven.doxia.module.itext.ITextSink
>
> To..
>        System.setProperty( "itext.basedir",
> bookFile.getParentFile().getParentFile().getAbsolutePath() );
>
> So that it looks two levels up rather than one level up... Everything seems
> to work OK.
>
> What the changes do are:
>
> Generate the PDF to the site directory rather than it¹s own directory.
> Create the site before generating PDFs .. note this puts the images in a
> Œknown place¹ relative to the PDF output.
> Set up the base for resolution to be consistent for both html and pdf
> generation.
>
> So... having said that, I¹m wondering what do to do next..
>
> This change isn¹t entirely backwards compatible (but maybe someone can
> figure out a way to make it so). I will create a patch for the change but
> am
> not sure if it is worth doing if it isn¹t backwards compatible.. The
> alternative is to keep a private version...
>
> I know that a colleague of mine raised a Jira (
> http://jira.codehaus.org/browse/DOXIA-356) on this subject.
>
> Any thoughts?
>
> Steve
>