Harvie / DokuWiki-Plugin-SVGEdit

An ultimate way, to create, store, edit, and embed SVG images in DokuWiki. [Looking for developers/adopters]
http://www.dokuwiki.org/plugin:svgedit
17 stars 9 forks source link

compatible with mpdf or dw2pdf? #11

Open wuker opened 11 years ago

wuker commented 11 years ago

I am using this plugin to insert some svg online but dw2pdf cannot generate the svg image in the output pdf. Any idea?

Harvie commented 11 years ago

Well... There is probably need of adding dw2pdf support into my plugin or SVG support into dw2pdf. I am not much familiar with dw2pdf... So i am not sure... Maybe i'll check it later. In meantime you can try asking dw2pdf authors ;-)

wuker commented 11 years ago

Thanks for your quick reply. I have been asking this questions to dw2pdf's author and in other forum but they replied that the dw2pdf is just a interface to use mPDF. So the question seems become how to make mPDF know how to interpretate svg generated by svgedit.

on 2013/1/13 ¤W¤È 04:41:30, Tomas Mudrunka notifications@github.com wrote: Re: [DokuWiki-Plugin-SVGEdit] compatible with mpdf or dw2pdf? (#11) Well... There is probably need of adding dw2pdf support into my plugin or SVG support into dw2pdf. I am not much familiar with dw2pdf... So i am not sure... Maybe i'll check it later. In meantime you can try asking dw2pdf authors ;-)

¡X Reply to this email directly or https://github.com/Harvie/DokuWiki-Plugin-SVGEdit/issues/11#issuecomment-12192056view it on GitHub.

Harvie commented 11 years ago

I've googled mPDF and it seems to be tool for converting HTML to PDF. My plugin provides valid HTML code (as it's understood by browser), so probably only problem is that mPDF does not simply support SVGs. I've googled again and i've found that it may be supported partialy. Check this:

http://mpdf.bpm1.com/forum/comments.php?DiscussionID=260

marclaporte commented 11 years ago

The example provided for 5.4 has SVG: http://www.mpdf1.com/mpdf/examples

Best regards,

M :-) On Jan 13, 2013 6:20 AM, "Tomas Mudrunka" notifications@github.com wrote:

I've googled mPDF and it seems to be tool for converting HTML to PDF. My plugin provides valid HTML code (as it's understood by browser), so probably only problem is that mPDF does not simply support SVGs. I've googled again and i've found that it may be supported partialy. Check this:

http://mpdf.bpm1.com/forum/comments.php?DiscussionID=260

— Reply to this email directly or view it on GitHubhttps://github.com/Harvie/DokuWiki-Plugin-SVGEdit/issues/11#issuecomment-12192409.

wuker commented 11 years ago

Thanks for your help. I read that carefully, it supports the SVG if the svg is inlcuded in an tag which could be recognized by the mpdf. But since svg-edit wrap svg with , as I was told by the author, it cannot interprate those object tag and extract the svg from there. I am looking into the code to see if I can rewrite the html tag. Thanks for your information anyway :)

on 2013/1/13 ¤W¤È 07:31:37, marclaporte notifications@github.com wrote: Re: [DokuWiki-Plugin-SVGEdit] compatible with mpdf or dw2pdf? (#11) The example provided for 5.4 has SVG:

http://www.mpdf1.com/mpdf/examples

Best regards,

M :-) On Jan 13, 2013 6:20 AM, "Tomas Mudrunka" notifications@github.com wrote:

I've googled mPDF and it seems to be tool for converting HTML to PDF. My plugin provides valid HTML code (as it's understood by browser), so probably only problem is that mPDF does not simply support SVGs. I've googled again and i've found that it may be supported partialy. Check this:

http://mpdf.bpm1.com/forum/comments.php?DiscussionID=260

¡X Reply to this email directly or view it on GitHubhttps://github.com/Harvie/DokuWiki-Plugin-SVGEdit/issues/11#issuecomment-12192409.

¡X Reply to this email directly or https://github.com/Harvie/DokuWiki-Plugin-SVGEdit/issues/11#issuecomment-12193667view it on GitHub.

Harvie commented 11 years ago

Actualy this plugin can use img tag, but currently it does only when user agent contains "webkit", because other browsers were not able to handle it well. I guess that's the issue and we can solve force it somehow. Right now you can try replacing this line:

if ($is_webkit) $svgtag='img src';

with this:

if (true) $svgtag='img src';
wuker commented 11 years ago

Hi Tomas, I following your way and it did change the image tag, but the src is given by the "doku.php?do=export_svg&id=". I check with mpdf again, it seems only work if we given the absolute path for the avg. Is there any way for the plugin to figure out the absolute for the svg in the img tag? Thanks.

2013/1/13 Tomas Mudrunka notifications@github.com

Actualy this plugin can use img tag, but currently it does only when user agent contains "webkit", because other browsers were not able to handle it well. I guess that's the issue and we can solve force it somehow. Right now you can try replacing this line:

if ($is_webkit) $svgtag='img src';

with this:

if (true) $svgtag='img src';

— Reply to this email directly or view it on GitHubhttps://github.com/Harvie/DokuWiki-Plugin-SVGEdit/issues/11#issuecomment-12207480.

Harvie commented 11 years ago

Not right now... You can try to hardcore it in place where src= is in code. But i am not sure if mPDF really downloads SVG or just links to it so you will need internet connection to display PDF correctly (i guess it really downloads). Maybe you just need to give mpdf base url of document... there are also scripts to map relative adresses to absolute... maybe dw2pdf authors should better handle this...

Harvie commented 11 years ago
Harvie commented 11 years ago
wuker commented 11 years ago

Hi Tomas, Sorry to bother again. I read your reply carefully and have some consideration on the possible way to make it compatible with mPDF and/or dw2pdf. First, based on your direction, I replace

if ($is_webkit) $svgtag='img src';

with

if (true) $svgtag='img src';

then the svg will be included in the following form instead

<img type="image/svg+xml" alt="image:nv:figures:abc.svg" class="mediacenter" src="/nv/wiki/doku.php?do=export_svg&id=nv:figures:abc.svg">

This leads us almost there except for mPDF need to download the svg with http unless absolute path of svg is given. Because of the security, I don't think the first way will work (actually nothing shown in the exported PDF) unless we replace the src with absolute path. Yes, I check the absolute path and it works then. The problem is how to retrieve the absolute path for the svg? In the link you gave in previous email (i.e. using setting: canonical) , it might help to solve the problem but I only want the absolute path of the figure while export to pdf using dw2pdf and don't want the link shown as absolute all the time for regular browsering on the wiki. So I am still looking for a way to extract the absolute path of the svg created by svg-edit.

2013/1/16 Tomas Mudrunka notifications@github.com

Also check this: https://www.dokuwiki.org/config:canonical

— Reply to this email directly or view it on GitHubhttps://github.com/Harvie/DokuWiki-Plugin-SVGEdit/issues/11#issuecomment-12316719.

wuker commented 11 years ago

I finally find a way to replace that path with the absolute one. I think the svg from svg-edit works great with dw2pdf and mpdf now. Just one thing, all the css style are missing. But in dw2pdf help page, it mentions that we could create a pdf.css etc. to specify the styles for pdf output. I don't know how to do that but I will try.

2013/1/18 EVA LIN llwaeva@gmail.com

Hi Tomas, Sorry to bother again. I read your reply carefully and have some consideration on the possible way to make it compatible with mPDF and/or dw2pdf. First, based on your direction, I replace

if ($is_webkit) $svgtag='img src';

with

if (true) $svgtag='img src';

then the svg will be included in the following form instead

<img type="image/svg+xml" alt="image:nv:figures:abc.svg" class="mediacenter" src="/nv/wiki/doku.php?do=export_svg&id=nv:figures:abc.svg">

This leads us almost there except for mPDF need to download the svg with http unless absolute path of svg is given. Because of the security, I don't think the first way will work (actually nothing shown in the exported PDF) unless we replace the src with absolute path. Yes, I check the absolute path and it works then. The problem is how to retrieve the absolute path for the svg? In the link you gave in previous email (i.e. using setting: canonical) , it might help to solve the problem but I only want the absolute path of the figure while export to pdf using dw2pdf and don't want the link shown as absolute all the time for regular browsering on the wiki. So I am still looking for a way to extract the absolute path of the svg created by svg-edit.

2013/1/16 Tomas Mudrunka notifications@github.com

Also check this: https://www.dokuwiki.org/config:canonical

— Reply to this email directly or view it on GitHubhttps://github.com/Harvie/DokuWiki-Plugin-SVGEdit/issues/11#issuecomment-12316719.

Harvie commented 11 years ago

How did you replaced the URLs? Was enabling of canonical URLs in dokuwiki config enough for you?

wuker commented 11 years ago

I try

$svg_abs_link = 'file://'.$conf['datadir']."/".str_replace(":", "/", $svg_wiki_page).".txt";

I know it is not elegant but just a workaround for me at this point. It is fine now ... the only problem is dw2pdf cannot find the class. For example, if I set class=mediacenter, it won't aligned center because missing mediacenter but it works great for any images (other than svg) uploaded with mediamanager, I don't know why.

2013/1/18 Tomas Mudrunka notifications@github.com

How did you replaced the URLs? Was enabling of canonical URLs in dokuwiki config enough for you?

— Reply to this email directly or view it on GitHubhttps://github.com/Harvie/DokuWiki-Plugin-SVGEdit/issues/11#issuecomment-12416812.