Not logged in. · Lost password · Register
Forum: General Help and Support Plugins RSS
Modifying ODT Plugin
Avatar
temporaryaccount #1
Member since Aug 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: Modifying ODT Plugin
Hi all,

I wish to modify the ODT plugin to suit my needs (https://www.dokuwiki.org/plugin:odt).  Essentially what I am trying to achieve is a one stop shop to export to word.

Using the ODT plugin in a vanilla sense to export a page from DokuWiki and then using LibreOffice/soffice '-convert-to' functionality standalone works well and meets my requirements.

After figuring out that the ODT configuration was actually in the Configuration Settings page of DokuWiki I noticed that it has the ability to export to PDF by changing a few parameters, specifically the 'plugin»odt»convert_to_pdf' setting by giving it a command line option to LibreOffice to allow LibreOffice to convert the file and '\odt\action\export.php' file on line 46 from:

$params = array('do' => 'export_odt');

to:

$params = array('do' => 'export_odt_pdf');

Thinking I had it all figured out and I could hack it to suit I changed the setting 'plugin»odt»convert_to_pdf' to:

"Z:\DokuWiki\lo\App\libreoffice\program\soffice.exe" -headless -convert-to doc -outdir %outdir% %sourcefile% 2>&1

This somewhat works whereby in the 'Z:\DokuWiki\data\tmp\odt' directory I can see the odt file get created ready for conversion however it does not offer the file .doc file through the web browser to the user like it would with the pdf file.

Using the command line:

"Z:\DokuWiki\lo\App\libreoffice\program\soffice.exe" -headless -convert-to pdf -outdir %outdir% %sourcefile% 2>&1

works successfully although in the pdf format.

I have tried changing various parameters within the php files from 'pdf' to 'doc' however I'm not progressing any further.  Could anyone shed a little light in regards where I should look or potentially offer a solution?

Thanks in advance.
Avatar
temporaryaccount #2
Member since Aug 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Hi all,

I'm keen to get this working.  It is technically possible since it works by converting to PDF. 

Can anyone point me in the right direction?

Thanks!
Avatar
temporaryaccount #3
Member since Aug 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Anyone?
Avatar
temporaryaccount #4
Member since Aug 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Finally got it.  So for anyone wanting to convert to .doc using the ODT plugin do the following:

- Modify line 46 of export.php in odt\action\ to:
$params = array('do' => 'export_odt_pdf');

- Modify line 277 of page.php in odt\renderer\ to:
$output_filename = str_replace(':','-',$ID).'.doc';

- Modify line 535 of page.php in odt\renderer\ to:
$pdf_file = $temp_dir.'/convert.doc';

- Modify the plugin»odt»convert_to_pdf setting in the Configuration Settings of Dokuwiki to:
"Z:\DokuWiki\lo\App\libreoffice\program\soffice.exe" -headless -convert-to doc -outdir %outdir% %sourcefile% 2>&1
Avatar
kuntule #5
Member since Oct 2015 · 7 posts
Group memberships: Members
Show profile · Link to this post
Thank you. The setting really work!!
Avatar
gsslay #6
Member since Mar 2007 · 12 posts · Location: Perth
Group memberships: Members
Show profile · Link to this post
Just wanted to post an update for this, as I've just gone through the above process and it needs updated.

First, it should be noted that this doesn't generate a doc file.  What it does is produce an Open Document Text (odt) file, with a doc extension.  But when opened in Word, Word recognises this and reads it as an ODT.  If you later save it, it will choose the odt format unless you select a different format.

So it works in getting you from Dokuwiki to Word, but is still one step away from producing a doc file.  Only Word can do that for you.

Secondly, the location of the lines you need to modify in the plugin have changed;

- Modify line 54 of export.php in odt\action\ from:
$params = array('do' => 'export_odt');
to:
$params = array('do' => 'export_odt_pdf');

- Modify line 273 of page.php in odt\renderer\ from:
$output_filename = str_replace(':','-',$ID).'.odt';
to:
$output_filename = str_replace(':','-',$ID).'.doc';

- Modify line 86 of pagepdf.php in odt\renderer\ from:
$pdf_file = $temp_dir.'/convert.pdf';
to:
$pdf_file = $temp_dir.'/convert.doc';

- Modify the line (exact line number may vary) in odt\conf\default.php that says:
$conf['convert_to_pdf'] = 'libreoffice --headless --convert-to pdf --outdir %outdir% %sourcefile% 2>&1';
to:
$conf['convert_to_pdf'] = 'libreoffice --headless --convert-to doc --outdir %outdir% %sourcefile% 2>&1';
Avatar
LarsDW223 #7
Member since Sep 2014 · 422 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
First, it should be noted that this doesn't generate a doc file.

Well it should generate a real doc file. Better said the ODT plugin will first generate a ODT file and then the command line

$conf['convert_to_pdf'] = 'libreoffice --headless --convert-to doc --outdir %outdir% %sourcefile% 2>&1';

should convert it from .odt to a .doc file (using LibreOffice in this case).
This post was edited on 2019-07-04, 18:40 by LarsDW223.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-07-23, 01:04:04 (UTC +02:00)