Ticket #1056 (reopened defect)

Opened 2 years ago

Last modified 7 months ago

Image support

Reported by: anonymous Assigned to: athomas
Priority: high Component: PageToPdfPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.10

Description

It doesn't seem to support embedded images in the PDF using the builtin [Image] macro.

This would be a killer feature for pages which include images as part of the documentation.

Attachments

pagetopdf_image_re_patch_r3243.diff (1.1 kB) - added by reingart on 02/16/08 17:56:16.
Image regex patch

Change History

12/29/06 08:41:37 changed by athomas

  • status changed from new to closed.
  • resolution set to worksforme.

(follow-up: ↓ 3 ) 03/10/07 12:09:28 changed by mcaisse

  • status changed from closed to reopened.
  • resolution deleted.

So ... it doesn't work for me. I have been messing with it for about a day and I can't see what I might be doing wrong.

Is there a certain Image macro parameters or image types that it works with?

I'm running Trac 0.10.3.1 on a Debian server with what I think is the HEAD for the PageToPdf? plugin. The HTMLDOC version is 1.8.23.

Any ideas?

(in reply to: ↑ 2 ; follow-up: ↓ 5 ) 03/23/07 07:12:51 changed by sier@pm3.ch

Replying to mcaisse:

So ... it doesn't work for me. I have been messing with it for about a day and I can't see what I might be doing wrong. Is there a certain Image macro parameters or image types that it works with? I'm running Trac 0.10.3.1 on a Debian server with what I think is the HEAD for the PageToPdf? plugin. The HTMLDOC version is 1.8.23. Any ideas?

I had the same problem. Hav a look in your log file:

Trac[main] WARNING: 403 Forbidden (WIKI_VIEW privileges are required to perform this operation)

I granted WIKI_VIEW to user anonymous. Now it works. But how we can fix this problem? Acctually, I am logged in with a valid user!

03/23/07 15:23:44 changed by coderanger

HTMLDOC (the program which converts the HTML to a PDF) is making the image requests, so it has no credentials. There is no way around this that I can think of.

(in reply to: ↑ 3 ; follow-up: ↓ 6 ) 03/24/07 03:21:38 changed by rolf.henrich@gmx.net

Replying to sier@pm3.ch:

Replying to mcaisse:

So ... it doesn't work for me. I have been messing with it for about a day and I can't see what I might be doing wrong. Is there a certain Image macro parameters or image types that it works with? I'm running Trac 0.10.3.1 on a Debian server with what I think is the HEAD for the PageToPdf? plugin. The HTMLDOC version is 1.8.23. Any ideas?

I had the same problem. Hav a look in your log file: {{{ Trac[main] WARNING: 403 Forbidden (WIKI_VIEW privileges are required to perform this operation) }}} I granted WIKI_VIEW to user anonymous. Now it works. But how we can fix this problem? Acctually, I am logged in with a valid user!

Hi, you wrote that you granted WIKI_VIEW to anonymous and it worked – but for me it did not work. Did I miss something?

(in reply to: ↑ 5 ; follow-up: ↓ 7 ) 03/27/07 09:17:44 changed by anonymous

Replying to rolf.henrich@gmx.net:

Hi, you wrote that you granted WIKI_VIEW to anonymous and it worked – but for me it did not work. Did I miss something?

I'am using

  • trac 10.3.1
  • htmldoc 1.9-current
  • python 2.4.1

Any warnings/errors in your log files?

(in reply to: ↑ 6 ; follow-up: ↓ 8 ) 03/27/07 09:57:13 changed by anonymous

Replying to anonymous:

Replying to rolf.henrich@gmx.net:

Hi, you wrote that you granted WIKI_VIEW to anonymous and it worked – but for me it did not work. Did I miss something?

I'am using * trac 10.3.1 * htmldoc 1.9-current * python 2.4.1

We are using: Trac 0.10.3.1, htmldoc 1.8.27 und Python 2.4.4.

2007-03-21 13:56:58,636 Trac[init] WARNING: 403 Forbidden (FILE_VIEW privileges are required to perform this operation)

Any warnings/errors in your log files?

(in reply to: ↑ 7 ; follow-up: ↓ 9 ) 03/28/07 02:18:34 changed by anonymous

Replying to anonymous:

2007-03-21 13:56:58,636 Trac[init] WARNING: 403 Forbidden (FILE_VIEW privileges are required to perform this operation)

Seems that you are refering images(files) from the repository. You should enable FILE_VIEW for anonymous users. The problem with htmldoc is that it grabs images(files) always as anonymous user.

(in reply to: ↑ 8 ; follow-up: ↓ 10 ) 03/28/07 11:31:13 changed by anonymous

Replying to anonymous:

Replying to anonymous:

2007-03-21 13:56:58,636 Trac[init] WARNING: 403 Forbidden (FILE_VIEW privileges are required to perform this operation)

Seems that you are refering images(files) from the repository. You should enable FILE_VIEW for anonymous users. The problem with htmldoc is that it grabs images(files) always as anonymous user.

Perfect! Now it works!!! Thanx for help. It is not a security problem now, is it?

(in reply to: ↑ 9 ) 03/29/07 01:56:36 changed by sier@pm3.ch

Replying to anonymous:

Perfect! Now it works!!! Thanx for help. It is not a security problem now, is it?

No, if you intend to share the hole subversion repostory with anyone. People can see the content of your repository.

04/22/07 10:05:15 changed by dr2chase

  • priority changed from normal to high.

I have the problem, and anonymous can see everything. I think a wrong path is getting fed to htmldoc. Here's my page URL:

http://localhost:8080/Projects/Community/wiki/FortressQuestions

Here's the wiki reference within that page (it's an attachment):

[[Image(NAS-CG.png, 40%)]][[BR]]

I tweaked the plugin to not delete the file, so I could see what it was generating:

grep img /tmp/tmpXjtHXntracpdf
<a style="padding:0; border:none" href="/Projects/Community/attachment/wiki/FortressQuestions/NAS-CG.png"><img width="40%" alt="Nicely rendered version of NAS CG" src="/Projects/Community/attachment/wiki/FortressQuestions/NAS-CG.png?format=raw" title="Nicely rendered version of NAS CG" /></a><br />

as near as I can tell, htmldoc is not talking to any web server, only to files, and any path beginning "/Projects" will only work if fed to the web server. I have this nasty suspicion that Apache knows about the virtualness of "/Projects", but it is keeping it a secret. Here's the relevant hunk of httpd.conf:

Alias /trachtdocs/ "/opt/local/share/trac/htdocs/"
<Location /Projects>
SetHandler mod_python
# Next line fixes funny crashes, in the-o-ry
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracUriRoot "/Projects"
PythonOption TracEnvParentDir "/export/home/dc12360/Nobody/Trac"
SetEnv PYTHON_EGG_CACHE "/export/home/dc12360/Nobody/EggCache"
</Location>

(Actually, that PythonOption looks promising.)

I'd like to use this plugin, but so far, it is not working for me.

(follow-up: ↓ 13 ) 04/23/07 09:23:43 changed by dr2chase

D'oh! Previous analysis is wacked. Here's a hack fix. alt, width, etc, between "img" and "src" cause the RE to fail.

        # This doesn't work because of alt, width, etc.
        # page = re.sub('<img src="(?!\w+://)', '<img src="%s://%s:%d' % (req.scheme, req.server_name, req.server_port), page)
        page = re.sub(' src="(?!\w+://)', ' src="%s://%s:%d' % (req.scheme, req.server_name, req.server_port), page)

(in reply to: ↑ 12 ) 02/16/08 17:55:41 changed by reingart

Replying to dr2chase:

D'oh! Previous analysis is wacked. Here's a hack fix. alt, width, etc, between "img" and "src" cause the RE to fail. {{{ # This doesn't work because of alt, width, etc. # page = re.sub('<img src="(?!\w+://)', '<img src="%s://%s:%d' % (req.scheme, req.server_name, req.server_port), page) page = re.sub(' src="(?!\w+://)', ' src="%s://%s:%d' % (req.scheme, req.server_name, req.server_port), page) }}}

That worked to me too, I'll attach a patch so it can be incorporated easily to repository. Regards

02/16/08 17:56:16 changed by reingart

  • attachment pagetopdf_image_re_patch_r3243.diff added.

Image regex patch

03/03/08 10:05:41 changed by anonymous

And why aren't those image url's rewritten to local filesystem path? The plugin is running under the same user trac is so it has access directly to the trac env, no need to use http url. I did it like this

page = re.sub('src="(?!\w+://).*/attachment(/[^?"]+)[^"]*', 'src="%s\\1' % (os.path.join(self.env.path, 'attachments')), page)

This way you don't have to enable (FILE_VIEW|WIKI_VIEW) for anonymous users and the images are fetched directly from trac env, htmldoc is not bothering trac to get them.

04/29/08 10:35:39 changed by anonymous

i just tried the patch above and i still can't images included via or graphviz.

also, i turned on debug level logging and didn't see any relevant errors or warnings:

2008-04-29 11:28:18,131 Trac[ttadmin] INFO: get_admin_pages
2008-04-29 11:28:18,161 Trac[pagetopdf] DEBUG: HTML output for PageToPDF in charset iso-8859-1
2008-04-29 11:28:18,163 Trac[api] DEBUG: Updating wiki page index
2008-04-29 11:28:18,214 Trac[formatter] DEBUG: Executing Wiki macro graphviz by provider <graphviz.graphviz.Graphviz object at 0xb55919ec>
2008-04-29 11:28:18,225 Trac[formatter] DEBUG: Executing Wiki macro graphviz by provider <graphviz.graphviz.Graphviz object at 0xb55919ec>
2008-04-29 11:28:18,236 Trac[formatter] DEBUG: Executing Wiki macro RecentChanges by provider <trac.wiki.macros.RecentChangesMacro object at 0xb54f11ac>
2008-04-29 11:28:18,263 Trac[pagetopdf] DEBUG: --right 1.5cm --bottom 1.5cm --webpage  --top 1.5cm --format pdf14 --size Letter --charset iso-8859-1 --left 1.5cm

i'm running trac 0.10.4


Add/Change #1056 (Image support)




Change Properties
Action