Hi,
I need a php code for converting from any format to pdf by clicking a button called convert to pdf.
How to do?

I don't know if there is a ready PHP solution for this, but if you can install software in your hosting, then use LibreOffice in command line mode:

<?php

    $file = 'something.doc';
    $str  = sprintf("libreoffice --headless --invisible --convert-to pdf %s", $file);
    $cmd  = escapeshellcmd($str);

    exec($cmd);

There are other solutions as unoconv, based on LibreOffice and JodConverter which seems to not be anymore maintained.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.