3

I am trying to include an image (institurtional logo) from direct web address, using \hyperref and pdftex. I am trying a command of the form (many other variants tried, with varios error messages ...):

\href{http://www.hbv.no/getfile.php/1-hbv.no/bilder/Logo%20og%20grafiske%20elementer/}{\includegraphics[]{hbv}}  

The image filetype is .png. A complicating problem might be the presence of percent % signs in the url ... The actual error message produced is "file `hbv' not found"

?ideas? (In trying to research this, I found a lot of material about \hyperref on the web, but mostly without image examples ...)

Adding a minimal example, as asked for (the included packages are there because they are needed in the full file, and there might be interferences ...)

\documentclass[norsk,a4paper,pdftex]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{babel}
\usepackage{graphicx}  
\usepackage{xcolor}

\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
   \href{http://www.hbv.no/getfile.php/1-hbv.no/bilder/Logo%20og%20grafiske%20elementer/}{\includegraphics[]{hbv}}  
\end{document}

pdftexing this produces a onepage pdf with an emptybox-symbol followed by the letters hbv, all inside a small (blue-green) box.

  • I tried accessing the link, and it seems the picture is no longer there, or you have the wrong link (the website says the page does not exist). Also, it is always helpful to include a minimal working example of code for the complete .tex document - for instance, there are same packages that need to be loaded for your command to compile that people who would like to help you might not realize need to be loaded. – Jānis Lazovskis Nov 26 '14 at 14:17
  • Do you want to display a remote image-URL during viewing time of the PDF document? – AlexG Nov 26 '14 at 14:24
  • AlexG: Actually, the document will only be printed, so the inclusion at real time is not needed. – kjetil b halvorsen Nov 26 '14 at 14:27
  • Harish Kumar: Tried that error is different: ERROR: Undefined control sequence. \includegraphics []{example-imae} l.11 ...menter/}{\includegraphics[]{example-imae}}

    TeX encountered an unknown command name. You probably misspelled the name. If this message occurs when a LaTeX command is being processed, the command is probably in the wrong place---for example, the error can be produced by an \item command that's not inside a list-making environment.

    – kjetil b halvorsen Nov 26 '14 at 14:46
  • jlv: The image file is there, am am inside that ubv.no domain, maybe be (directly) accessible from outside. – kjetil b halvorsen Nov 26 '14 at 14:47
  • 1
    Would it be much easier to download the image to the document folder and include it? Or is that an image that changes frequently and you need the latest copy at compilation time? – ajeh Nov 26 '14 at 14:51
  • The % comment out your line and you have not loaded graphicx package to define \includegraphics – David Carlisle Nov 26 '14 at 14:55
  • David Carlisle: I had forgot that, but including graphicx still produces the same error as originally, that is, file not found. – kjetil b halvorsen Nov 26 '14 at 15:05
  • ajeh: For this particular example it would be easier to just download the file, bit I want to learn and understand this ... – kjetil b halvorsen Nov 26 '14 at 15:19
  • do you have an image file called hbv.png (or different extension) If not, it won't be found... – David Carlisle Nov 26 '14 at 15:24
  • David Carlisle: It is named hbv.png. If I download it into my work folder, it is found. But I want to understand the weblinking stuff! – kjetil b halvorsen Nov 26 '14 at 15:25
  • the web link is not relevant, you have \includegraphics{hbv} so tex needs a file of that name in its search path. this is for the link text the fact that you make it an active link pointing to some web site doesn't change that. The URL is just specifying what happens when a reader clicks on the image it doesn't affect how it is typeset – David Carlisle Nov 26 '14 at 15:27
  • David Carlisle: OK, but can you then propose a syntax to include the web file with \includegraphics? Is then package hyperref relevant at all, or can I just use \includegraphics? If so, how? – kjetil b halvorsen Nov 26 '14 at 15:32
  • hyperref is only relevant if you want to make hyperlinks in the document. tex can not fetch files over the web. (You could use --shell-escape and make it call a command line http client such as wget (if you have that) to fetch the file each time, but there is no point, you may as well just fetch it once. – David Carlisle Nov 26 '14 at 15:35

2 Answers2

5

The URL is not specifying a location of an image to TeX, it is specifying what the PDF reader should do when the user clicks on the link.

You have \includegraphics{hbv} so tex needs a file of that name in its search path.

David Carlisle
  • 757,742
2

The PDF standard does not provide a means for displaying remote images from URLs at viewing time. So \includegraphics cannot embed these.

But the Adobe Supplement to the ISO 32000 defines the RichMedia Annotation. It is implemented in AdobeReader on Windows and MacOSX and allows playing media (embedded or from URL).

Here is an example, using StrobeMediaPlayback.swf, shipping with the media9 package. You need AdobeReader (Win/Mac) to see the logo of your institute.

\documentclass{article}
\usepackage{media9}

\begin{document}
Image from URL at viewing time:\\
\includemedia[
  width=0.5\linewidth,height=0.5\linewidth,
  activate=pageopen,
  transparent,
  flashvars={
    src=http://www.hbv.no/getfile.php/1-hbv.no/bilder/Logo\%20og\%20grafiske\%20elementer/hbv.png
    &controlBarMode=none
    &scaleMode=stretch
  }
]{}{StrobeMediaPlayback.swf}
\end{document}
AlexG
  • 54,894