# Fax download error after patch 3

**URL:** <https://community.open-emr.org/t/fax-download-error-after-patch-3/23902>\
**Category:** Support\
**Created:** [November 26, 2024, 5:59pm UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902 "2024-11-26T17:59:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![toddmleleux](https://community.open-emr.org/user_avatar/community.open-emr.org/toddmleleux/32/18862_2.png) [@toddmleleux](https://community.open-emr.org/u/toddmleleux)\
**Post date:** [November 26, 2024, 5:59pm UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902/1 "2024-11-26T17:59:21Z")

</div>

Sorry for the multiple posts here after patch 3. Some were my error with a disk volume storage. However, when trying to download a fax as pdf i get error Failed to display the document due to an invalid document format. Also previously I had some documents in the patient document folders in jpg format that kick out an error that I can start another thread. The logs for the file format for faxes is listed here.

**Situation**  
As above  
**OpenEMR Version**  
7.0.2 p3  
**Browser** :  
I’m using:  
Chrome  
**Operating System**  
I’m using:  
Ubuntu 22 LTS  
**Search**  
Yest  
**Logs**  
Did you check the logs?

```auto
[Tue Nov 26 11:52:42.011157 2024] [php:error] [pid 1045755] [client 72.206.76.140:39172] PHP Fatal error: Uncaught TypeError: OpenEMR\\Services\\ImageUtilities\\HandleImageService::convertImageToPdfUseImagick(): Return value must be of type string|false, null returned in /var/www/xxx/openemr/src/Services/ImageUtilities/HandleImageService.php:93\nStack trace:\n#0 /var/www/xxx/openemr/src/Services/ImageUtilities/HandleImageService.php(279): OpenEMR\\Services\\ImageUtilities\\HandleImageService->convertImageToPdfUseImagick('...', '')\n#1 /var/www/xxx/openemr/interface/modules/custom_modules/oe-module-faxsms/src/Controller/EtherFaxActions.php(556): OpenEMR\\Services\\ImageUtilities\\HandleImageService->convertImageToPdf('...', '')\n#2 /var/www/xxx/openemr/interface/modules/custom_modules/oe-module-faxsms/src/Controller/EtherFaxActions.php(524): OpenEMR\\Modules\\FaxSMS\\Controller\\EtherFaxActions->formatFax('...')\n#3 [internal function]: OpenEMR\\Modules\\FaxSMS\\Controller\\EtherFaxActions->viewFax(Array)\n#4 /var/www/xxx/openemr/interface/modules/custom_modules/oe-module-faxsms/src/Controller/AppDispatch.php(79): call_user_func(Array, Array)\n#5 /var/www/xxx/openemr/interface/modules/custom_modules/oe-module-faxsms/src/Controller/AppDispatch.php(52): OpenEMR\\Modules\\FaxSMS\\Controller\\AppDispatch->dispatchActions()\n#6 /var/www/xxx/openemr/interface/modules/custom_modules/oe-module-faxsms/src/Controller/EtherFaxActions.php(55): OpenEMR\\Modules\\FaxSMS\\Controller\\AppDispatch->__construct()\n#7 /var/www/xxx/openemr/interface/modules/custom_modules/oe-module-faxsms/src/Controller/AppDispatch.php(238): OpenEMR\\Modules\\FaxSMS\\Controller\\EtherFaxActions->__construct()\n#8 /var/www/xxx/openemr/interface/modules/custom_modules/oe-module-faxsms/src/Controller/AppDispatch.php(200): OpenEMR\\Modules\\FaxSMS\\Controller\\AppDispatch::getServiceInstance('...')\n#9 /var/www/xxx/openemr/interface/modules/custom_modules/oe-module-faxsms/index.php(25): OpenEMR\\Modules\\FaxSMS\\Controller\\AppDispatch::setApiService('...')\n#10 {main}\n thrown in /var/www/xxx/openemr/src/Services/ImageUtilities/HandleImageService.php on line 93, referer: https://xxx/interface/modules/custom_modules/oe-module-faxsms/messageUI.php?type=fax

```

Was there anything pertinent in them?  
Please paste them here (surround with three backticks (```) for readability.  
You can also turn on User Debugging under Administration-\>Globals-\>Logging User Debugging Options=\>All

---

<div class="post-metadata">

**Author:** ![sjpadgett](https://community.open-emr.org/user_avatar/community.open-emr.org/sjpadgett/32/21623_2.png) [@sjpadgett](https://community.open-emr.org/u/sjpadgett)\
**Post date:** [November 26, 2024, 9:09pm UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902/2 "2024-11-26T21:09:09Z")

</div>

There have been no changes to etherfax in patch 3.  
It looks like Imagick is being used so you have the imagick extension installed and enabled.  
There are three was I try to resolve tiff images to pdf. 1. imagick(first choice) 2.gd 3. Javascript routines I developed.

If neither imagick or gd are installed I auto to using Javascript.  
I’ve never tested the linux imagick. Works great on windows.

Php -m to check installed extensions.

---

<div class="post-metadata">

**Author:** ![toddmleleux](https://community.open-emr.org/user_avatar/community.open-emr.org/toddmleleux/32/18862_2.png) [@toddmleleux](https://community.open-emr.org/u/toddmleleux)\
**Post date:** [November 26, 2024, 9:17pm UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902/3 "2024-11-26T21:17:24Z")

</div>

Yes I have imagick installed because I use the scans function under miscellaneous tabs. How would I configure to use imagick for the fax sms module or does the code go down your order to try to use a conversion program. If its using imagick, which it appears it is, then how would i resolve the HandleImageService::convertImageToPdfUseImagick(): Return value must be of type string|false, null returned error. I have not had issues with imagick until now.

Todd

---

<div class="post-metadata">

**Author:** ![toddmleleux](https://community.open-emr.org/user_avatar/community.open-emr.org/toddmleleux/32/18862_2.png) [@toddmleleux](https://community.open-emr.org/u/toddmleleux)\
**Post date:** [November 26, 2024, 9:18pm UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902/4 "2024-11-26T21:18:34Z")

</div>

Or could I hard code the module to use Javascript instead of imagick? Im assuming thats removing theme from the module code. Let me know if im on the right track.

Todd

---

<div class="post-metadata">

**Author:** ![sjpadgett](https://community.open-emr.org/user_avatar/community.open-emr.org/sjpadgett/32/21623_2.png) [@sjpadgett](https://community.open-emr.org/u/sjpadgett)\
**Post date:** [November 26, 2024, 9:26pm UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902/5 "2024-11-26T21:26:05Z")

</div>

yes. it’s unfortunate imagick doesn’t work but I actually spent a lot of time to avoid using any extension but forgot to remove the code for extensions.  
Goto:

```auto
src/Services/ImageUtilities/HandleImageService.php around L-260
 public function convertImageToPdf($imageData, $pdfPath = '', $useExt = 'gd'): false|string
    {
        $content = '';
        return false;

```

just add a return false; at top then if you want you can delete the rest of method code.

---

<div class="post-metadata">

**Author:** ![toddmleleux](https://community.open-emr.org/user_avatar/community.open-emr.org/toddmleleux/32/18862_2.png) [@toddmleleux](https://community.open-emr.org/u/toddmleleux)\
**Post date:** [November 27, 2024, 5:30am UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902/6 "2024-11-27T05:30:43Z")

</div>

Thanks Jerry,

I simply changed imageick to gd and left the rest of the code alone and it works now.

code is as follows starting on line 260:

````public
    {
        $content = '';

        if (is_file($imageData)) {
            $imageContent = file_get_contents($imageData);
        } else {
            $imageContent = $imageData;
        }
        // Check for extension availability
        $usingImagick = $this->isImagickAvailable() && $useExt === 'imagick';
        $usingGd = $this->isGdAvailable() && $useExt === 'gd' && !$usingImagick;

        if (!$usingImagick && !$usingGd) {
            return false; // todo Could provide an alternative method but JS will pick this up
        }

        try {
            if ($usingImagick) {
                $content = $this->convertImageToPdfUseImagick($imageContent, $pdfPath);
            } elseif ($usingGd) {
                // Implement GD conversion or provide a message if not yet implemented
                $content = false; // Placeholder for actual GD implementation
                error_log('GD based conversion not implemented.');
            }
        } catch (Exception $e) {
            error_log('Error converting image to PDF using ' . ($usingImagick ? 'Imagick' : 'GD') . ': ' . text($e->getMessage()));
            return false;
        }

        return $content;
    }
}```
````

---

<div class="post-metadata">

**Author:** ![toddmleleux](https://community.open-emr.org/user_avatar/community.open-emr.org/toddmleleux/32/18862_2.png) [@toddmleleux](https://community.open-emr.org/u/toddmleleux)\
**Post date:** [November 27, 2024, 5:31am UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902/7 "2024-11-27T05:31:29Z")

</div>

sorry it was incomlete.

```
public function convertImageToPdf($imageData, $pdfPath = '', $useExt = 'gd'): false|string
{
    $content = '';

    if (is_file($imageData)) {
        $imageContent = file_get_contents($imageData);
    } else {
        $imageContent = $imageData;
    }
    // Check for extension availability
    $usingImagick = $this->isImagickAvailable() && $useExt === 'imagick';
    $usingGd = $this->isGdAvailable() && $useExt === 'gd' && !$usingImagick;

    if (!$usingImagick && !$usingGd) {
        return false; // todo Could provide an alternative method but JS will pick this up
    }

    try {
        if ($usingImagick) {
            $content = $this->convertImageToPdfUseImagick($imageContent, $pdfPath);
        } elseif ($usingGd) {
            // Implement GD conversion or provide a message if not yet implemented
            $content = false; // Placeholder for actual GD implementation
            error_log('GD based conversion not implemented.');
        }
    } catch (Exception $e) {
        error_log('Error converting image to PDF using ' . ($usingImagick ? 'Imagick' : 'GD') . ': ' . text($e->getMessage()));
        return false;
    }

    return $content;
}

```

}

---

<div class="post-metadata">

**Author:** ![sjpadgett](https://community.open-emr.org/user_avatar/community.open-emr.org/sjpadgett/32/21623_2.png) [@sjpadgett](https://community.open-emr.org/u/sjpadgett)\
**Post date:** [November 27, 2024, 2:55pm UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902/8 "2024-11-27T14:55:58Z")

</div>

That’ll work too!  
The only reason those extensions are needed is to deal with tiff images.  
I believe I need to keep them in thought I have a JS solution perhaps for Patient Documents so I guess I’ll add a Config item to select which to use.  
I’m curious why works on window but not linux but for another day.🙂

Glad you’re working.

---

<div class="post-metadata">

**Author:** ![toddmleleux](https://community.open-emr.org/user_avatar/community.open-emr.org/toddmleleux/32/18862_2.png) [@toddmleleux](https://community.open-emr.org/u/toddmleleux)\
**Post date:** [November 27, 2024, 3:58pm UTC](https://community.open-emr.org/t/fax-download-error-after-patch-3/23902/9 "2024-11-27T15:58:32Z")

</div>

Odd that imagick doesnt work either. Usually its more of a pain to install on windows and more functional on linux. Its a great module and I appreciate your work.

On a site note, for the module, when sending faxes it ties up the system while its transmitting the file to etherfax or other service. As an added feature it would be nice to be able to send the fax and have it go to an outbound que and process in the background if possible.

Happy holidays

Todd
