insert an image into a pdf file

hello,

I want to generate a pdf file that contains the document properties and notament image.

I created a new documentary that inherits the type rating.

I added a new property type blog that will contain an image.

I created the following automation chains :


Fetch > Context Document(s)
Conversion > Render Document
    template : myTemplate
    filename : output.html
    mimetype : text/html
    type : flt
conversion > convert to pdf
user interface > download file

myTemplate is :

Current user: ${Session.principal.name}

<H1>${This.dublincore.title}</H1>
<p>${This.dublincore.description}</p>
</br>
<p>${This.note.note}</p>
</br>
<IMG SRC="This.myDocument.myImage"/>
</br>
${This.myDocument.myImage}

How to reference the image in the IMG tag ?

thank you

0 votes

1 answers

1387 views

ANSWER



In your template, you can try to encode the image in base64 like this:

For instance:

    <img
  src="data:image/*;base64,iVBORw0KGgoAAAAN....AASUVORK5CYII="
  alt="image" />

I don't know if this works but you can give a try

0 votes



Hi,

I try .. and it didn't work :-( <img … /> in a html file show the image (outside nuxeo). But the pdf obtained by an html template convert in pdf, show an empty square.

05/23/2013

More tests… OpenOffice like LibreOffice are not able to interpret images base64 encoding in a html file.

I try on LibreOffice to save a html file with an imported image and it save the image in another file (in the same folder) with a link in the html file to this file.

So I think the only way is to indicate the path of the image in the html template. But how ? Is it possible to use resources>images ?

Hope there'll be an a positive answer here or in the http://answers.nuxeo.com/questions/5608/how-to-insert-an-image-in-a-document-template question.

05/31/2013