Page 1 of 1

converting doc or docx file to pdf

Posted: 2016-04-18T07:11:01-07:00
by suman114
Hello,

I am trying to convert a doc file to pdf with imagemagick.
The debug log shows that the doc file is successfully converted to pdf, but while moving it, it tries to find a doc that doesn't exists. Eg;

Code: Select all

convert -verbose apple.doc logo.png -gravity south -quality 100 -fill "rgba(180,180,180,0.80)" -pointsize 18 -weight bold -annotate +0+50 "Downloaded from Hart Energy's Alexandria Library" -compose multiply -layers composite output.pdf
Log:

Code: Select all

"soffice" --headless --convert-to pdf --outdir `dirname "apple.doc"` "apple.doc" 
2> "/tmp/magick-27774N2VanFQ6A6bn"; mv "apple.doc.pdf" "/tmp/magick-27774IwoX-tNyM0gj"
convert apple.doc -> apple.pdf using writer_pdf_Export
Overwriting: apple.pdf
mv: cannot stat ‘apple.doc.pdf’: No such file or directory
The above log is slightly modified. My question is why is it trying to move apple.doc.pdf instead of apple.pdf?

And how do I fix this?

Re: converting doc or docx file to pdf

Posted: 2016-04-18T07:42:50-07:00
by Bonzo
Your code options order looks a bit of a mess. I would start with something simple for instance compositing the two images and then build in the rest of your code. This would prove that part works as you have so many parts where it can go wrong.

Re: converting doc or docx file to pdf

Posted: 2016-04-18T11:17:21-07:00
by fmw42
Bonzo is correct. Just try converting the apple.doc to pdf. See if that works.

I see a couple of possible issues with your command.

First, you may need to use parenthesis about the logo.png and annotate to isolate it to just the logo. Your code may be trying to process both images with the annotate. See http://www.imagemagick.org/Usage/basics/#parenthesis

Second, I am not sure you can use a compose method with layers composite. Try just -compose multiplly -composite or -compose multiply -layers merge +repage. layers composite is typically used to merge animations. See
http://www.imagemagick.org/Usage/anim_mods/#composite
http://www.imagemagick.org/Usage/layers/#compose
http://www.imagemagick.org/Usage/layers ... _composite

Re: converting doc or docx file to pdf

Posted: 2016-04-18T11:45:25-07:00
by snibgo
Perhaps the OP wants to multiply logo.png with each image from apple.doc. If so, a "NULL:" is needed between them. I don't know what should be annotated.

In any case, I agree with Bonzo and Fred. Break down the problem into sub-problems, as as simple as possible, each one a "convert" command. Debug each one. Then, when it all works, optimise by combining the commands.

Re: converting doc or docx file to pdf

Posted: 2016-04-18T11:58:55-07:00
by fmw42
Good point snibgo. I was assuming he had one single page doc file and one logo. But I think you are probably right in that he wants to watermark each page of the doc file with the logo. -layers composite is then correct, but I do not think you can do -compose with that. But a NULL: is definitely needed between the two images when using -layers composite. If the user wants a less pronounce watermark that and overlay, then he should modify the logo's transparency.

Re: converting doc or docx file to pdf

Posted: 2016-04-18T17:34:27-07:00
by suman114
The above code works well while converting pdf to watermarked pdf.
I am trying to convert doc file to watermarked pdf. And it gave that error. Why is it trying to find the apple.doc.pdf instead of converted apple.pdf?
The apple.pdf is actually created. Just gives the above mentioned error

Re: converting doc or docx file to pdf

Posted: 2016-04-18T17:41:02-07:00
by suman114
Even simple converting doc shows the same error

Code: Select all

convert -verbose aaaaa.doc outputsss.pdf
"soffice" --headless --convert-to pdf --outdir `dirname "aaaaa.doc"` "aaaaa.doc" 2> "/tmp/magick-13123jDqOlCXpGDh8"; mv "aaaaa.doc.pdf" "/tmp/magick-13123_Eb6RP3Vcg46"
convert /home/suman/aaaaa.doc -> /home/suman//aaaaa.pdf using writer_pdf_Export
mv: cannot stat ‘aaaaa.doc.pdf’: No such file or directory
convert: delegate failed `"soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o"' @ error/delegate.c/InvokeDelegate/1333.
convert: unable to open image `/tmp/magick-13123gXfKk44RNnuB': No such file or directory @ error/blob.c/OpenBlob/2702.
convert: unable to open file `/tmp/magick-13123gXfKk44RNnuB': No such file or directory @ error/constitute.c/ReadImage/540.
convert: no images defined `outputsss.pdf' @ error/convert.c/ConvertImageCommand/3252.
convert -version shows following delegates

Code: Select all

Delegates (built-in): bzlib djvu fftw fontconfig freetype gvc jbig jng jpeg lcms lqr lzma openexr pangocairo png tiff wmf x xml zlib
Do I need the doc, docx and other office file extension there as well?

Re: converting doc or docx file to pdf

Posted: 2016-04-18T19:29:51-07:00
by fmw42
We have been unsure of your purpose. Are you trying to convert a single page doc or a multipage doc? If the latter, are you trying to add the logo to each page or just one page? If you are trying to watermark each page, then you need a NULL: between the doc image and the logo image.

You may be getting one error message that is confusing, if IM detects a different issue such as a missing NULL: when using -layers composite.

Please try what we have suggested above or give us more information about your goals and data.

Re: converting doc or docx file to pdf

Posted: 2016-04-18T22:39:51-07:00
by suman114
Please see my last post. All I am trying to do is convert a multipage doc to pdf file with

Code: Select all

convert aaaaa.doc outputsss.pdf
Disregard all other content. The above command throws me error

Code: Select all

"soffice" --headless --convert-to pdf --outdir `dirname "aaaaa.doc"` "aaaaa.doc" 2> "/tmp/magick-13123jDqOlCXpGDh8"; mv "aaaaa.doc.pdf" "/tmp/magick-13123_Eb6RP3Vcg46"
convert /home/suman/aaaaa.doc -> /home/suman//aaaaa.pdf using writer_pdf_Export
mv: cannot stat ‘aaaaa.doc.pdf’: No such file or directory
convert: delegate failed `"soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o"' @ error/delegate.c/InvokeDelegate/1333.
convert: unable to open image `/tmp/magick-13123gXfKk44RNnuB': No such file or directory @ error/blob.c/OpenBlob/2702.
convert: unable to open file `/tmp/magick-13123gXfKk44RNnuB': No such file or directory @ error/constitute.c/ReadImage/540.
convert: no images defined `outputsss.pdf' @ error/convert.c/ConvertImageCommand/3252.

Re: converting doc or docx file to pdf

Posted: 2016-04-18T23:29:14-07:00
by fmw42
convert aaaaa.doc outputsss.pdf
Should work fine if you have the correct delegate program and the delegates.xml file points to the location of that delegate. Do you have Soffice in your delegates.xml file and is it pointing to the correct location for that file. If not, the put the full path to that delegate and make sure you have a current version of it on your system. Perhaps your should post a link to your aaaaa.doc file so one of the Windows users can test with it.

Re: converting doc or docx file to pdf

Posted: 2016-04-19T00:51:48-07:00
by suman114
fmw42 wrote:
convert aaaaa.doc outputsss.pdf
Should work fine if you have the correct delegate program and the delegates.xml file points to the location of that delegate. Do you have Soffice in your delegates.xml file and is it pointing to the correct location for that file. If not, the put the full path to that delegate and make sure you have a current version of it on your system. Perhaps your should post a link to your aaaaa.doc file so one of the Windows users can test with it.
convert -version

Code: Select all

Delegates (built-in): bzlib djvu fftw fontconfig freetype gvc jbig jng jpeg lcms lqr lzma openexr pangocairo png tiff wmf x xml zlib
no soffice delegates seen here.

But

Code: Select all

 soffice --headless --convert-to pdf --outdir apps.pdf aaaaa.doc
works just fine.

My delegate.xml has following with other many delegates as well.

Code: Select all

<delegate decode="doc" command=""soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o""/>
  <delegate decode="docx" command=""soffice" --headless --convert-to pdf --outdir `dirname "%i"` "%i" 2> "%Z"; mv "%i.pdf" "%o""/>
  

Re: converting doc or docx file to pdf

Posted: 2016-04-19T06:53:26-07:00
by snibgo
What is the platform? Not Windows, I hope. That delegate command won't work on Windows, because it doesn't have the bash back-tick mechanism.

Re: converting doc or docx file to pdf

Posted: 2016-04-19T07:13:09-07:00
by suman114
its linux/ ubuntu

Re: converting doc or docx file to pdf

Posted: 2016-04-19T09:14:44-07:00
by fmw42
try adding the full path to soffice in

command=""path2/soffice"

In your delegate.xml file line you have above