Forum How do I...?

Display images without file extension

efra
Hi,

I am having difficulty including images in my output pdf.

When my image source has a filetype extension such as someimagefile.png the image link is recognised and it's included in the pdf file.

(All of the image files reside in the same directory with the xml file)

Example:

xml:

<img src="photo.png" /> 


css:
img{
	content: attr("src",url);
	display:block;
} 


The problem is, nearly all of the time the image file links in the xml doesn't have a file extension. Like the one below:

<img src="photo" /> 


When I convert this file, it does not recognize the link to the image file. Due to lack of file extension at the end.

Is there any way to make prince recognize the value of "src" as a link to the image files?

The only solution that I came up with is to add the file extension using a script. But the drawback is the image files are not consistent (various types of image files).





Edited by efra

mikeday
This should still work, are you getting any warning messages in the Prince output log?
efra
I am getting the following log when the src value in the xml doesn't have a file extension:

warning: can't open input file: No such file or directory

I have tried with different image filetypes but got the same result. (BTW I am using version 12).


Is there any extra commands that I need to consider?

Content of my test files are below:

<?xml version="1.0" encoding="UTF-8"?>

<placeholder>
<img src="someimage" />
</placeholder>




img{
	content: attr("src",url);
	display:block;
}
mikeday
That works fine for me if I put the XML in a file test.xml and the CSS in style.css and ensure there is a PNG called "someimage" in the same directory and run:
prince -s style.css test.xml

then it produces the expected output. If someimage is missing and I run with the --debug flag then I get these log messages:
prince: Preparing document...
prince: loading image: someimage
prince: debug: error loading resource: can't open input file: No such file or directory
prince: someimage: warning: can't open input file: No such file or directory

efra
This sound weird. The stylesheet, xml file and the image are in the same folder.

Whenever I type
<img src="someimage" />


The debug output is:

prince: loading image: someimage
prince: debug: error loading resource: can't open input file: No such file or directory

And I get a pdf without the image.

When I type
<img src="someimage.png" />


The debug output is:

prince: loading image: someimage.png
prince: debug: loaded resource: someimage.png

The image is loaded into the pdf.

I don't understands why it behaves like this. Don't really have any idea how to approach.
mikeday
That's very strange, would you be able to email me (mikeday@yeslogic.com) the documents and image file to take a look?