Image on PDF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Athensmusic
    Member
    • Feb 2020
    • 51

    Image on PDF

    Hi,
    While was using TCPDF engine on PDFs, had a url field, so on pdf was showing image from that field url.

    Now, after removing TCPDF engine, can't figure out if there is an option to show an image using url field (not through image field).

    Or, if there is any way to make use of TCPDF engine.

    Thanks
  • yuri
    Member
    • Mar 2014
    • 8695

    #2
    Hi, Not possible out of the box. Dompdf has the parameter https://github.com/dompdf/dompdf/blo...ions.php#L1010, it might do what you need.

    Note that may bring about security issues.

    Click image for larger version

Name:	image.png
Views:	212
Size:	34.2 KB
ID:	101797
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment


    • Athensmusic
      Athensmusic commented
      Editing a comment
      but, how to set 'isRemoreEnable" to true?
      curl and allow_url_fopne are both enabled
  • BigBoss
    Member
    • Nov 2023
    • 92

    #3
    If you want to continue using the TCPDF engine, you can install the extension.
    Will be available as an extension. Those who use the TCPDF engine and want to continue using it after upgrading, need to install the extension and change the PDF engine to TCPDF at Administration >...

    Comment


    • Athensmusic
      Athensmusic commented
      Editing a comment
      whould be an easy solution but does not seem to work like a extension.
      trying to upload it and I get the error "It's not an Installation package."

    • yuri
      yuri commented
      Editing a comment
      You likely downloaded not a proper archive. Download the release package https://github.com/yurikuzn/ext-tcpdf/releases

    • Athensmusic
      Athensmusic commented
      Editing a comment
      Right,
      Thanks!
  • criffoh
    Member
    • Jun 2020
    • 56

    #4
    If you add

    PHP Code:
    $options->set('isRemoteEnabled'true); 
    In application/Espo/Tools/Pdf/Dompdf/DompdfInitializer.php

    Full code
    PHP Code:
    <?php
    /************************************************************************
     * This file is part of EspoCRM.
     *
     * EspoCRM – Open Source CRM application.
     * Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
     * Website: https://www.espocrm.com
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Affero General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     * GNU Affero General Public License for more details.
     *
     * You should have received a copy of the GNU Affero General Public License
     * along with this program. If not, see <https://www.gnu.org/licenses/>.
     *
     * The interactive user interfaces in modified source and object code versions
     * of this program must display Appropriate Legal Notices, as required under
     * Section 5 of the GNU Affero General Public License version 3.
     *
     * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
     * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
     ************************************************************************/

    namespace Espo\Tools\Pdf\Dompdf;

    use 
    Dompdf\Dompdf;
    use 
    Dompdf\Options;
    use 
    Espo\Core\Utils\Config;
    use 
    Espo\Tools\Pdf\Template;

    class 
    DompdfInitializer
    {
        private 
    string $defaultFontFace 'DejaVu Sans';

        private const 
    PT 2.83465;

        public function 
    __construct(
            private 
    Config $config
        
    ) {}

        public function 
    initialize(Template $template): Dompdf
        
    {
            
    $options = new Options();

            
    $options->setDefaultFont($this->getFontFace($template));
            
    $options->set('isRemoteEnabled'true);

            
    $pdf = new Dompdf($options);

            
    $size $template->getPageFormat() === Template::PAGE_FORMAT_CUSTOM ?
                [
    0.00.0$template->getPageWidth() * self::PT$template->getPageHeight() * self::PT] :
                
    $template->getPageFormat();

            
    $orientation $template->getPageOrientation() === Template::PAGE_ORIENTATION_PORTRAIT ?
                
    'portrait' :
                
    'landscape';

            
    $pdf->setPaper($size$orientation);

            return 
    $pdf;
        }

        private function 
    getFontFace(Template $template): string
        
    {
            return
                
    $template->getFontFace() ??
                
    $this->config->get('pdfFontFace') ??
                
    $this->defaultFontFace;
        }
    }

    Works perfectly, but is a core file.

    Comment

    Working...