简体   繁体   English

href不适用于mpdf中的动态网址

[英]a href is not working for dynamic url in mpdf

I am getting problem in anchor tag while export to PDF.Anchor tag is working for static url like http:google.com but it is not working for dynamic url.I am using mpdf module for PDF. 我在导出到PDF时在锚标记中遇到问题。锚标记适用于http://google.com等静态网址,但不适用于动态url。我正在将mpdf模块用于PDF。

$url = $fullBaseUrl.'/designers/attachment/time/'.$value['filetime'].'/uploadTab/imgattach'; 
// http://localhost/msme_latest/designers/attachment/time/1394432246/uploadTab/imgattach     

$html= '<a href="'.$url.'">'.$value['filename'].'</a>';        

// echo $html; die;

$mpdf->WriteHTML($html);
$mpdf->Output();
exit;

When i echo my code $html it is giving my link properly.But when i export this code in PDF it is not giving any kind of link PDF. 当我回显我的代码$ html时,它正确地给出了我的链接。但是当我将此代码导出为PDF时,它没有给出任何形式的链接PDF。 Any help will be appriciated. 任何帮助将被申请。

For solve this problem you have to make just i change in mpdf.php 为了解决这个问题,您必须使我在mpdf.php中进行更改

Actual Code is in mpdf.php on line no.20146 实际代码在第20146行的mpdf.php中

if(isset($vetor[1]) and $vetor[1] != '') //LINK
{
  if (strpos($vetor[1],".") === false && strpos($vetor[1],"@") !== 0) //assuming every external link has a dot indicating extension (e.g: .html .txt .zip www.somewhere.com etc.) 
  {
    //Repeated reference to same anchor?
    /*
    while(array_key_exists($vetor[1],$this->internallink)) $vetor[1]="#".$vetor[1];
        $this->internallink[$vetor[1]] = $this->AddLink();
        $vetor[1] = $this->internallink[$vetor[1]];
    */
  }
  $this->HREF = $vetor[1];                  // HREF link style set here ******
}

and you have just comment line of code (line number:20151 to 20153) 并且您只注释了代码行(行号:20151至20153)

        /*
        while(array_key_exists($vetor[1],$this->internallink)) $vetor[1]="#".$vetor[1];
            $this->internallink[$vetor[1]] = $this->AddLink();
            $vetor[1] = $this->internallink[$vetor[1]];
        */

and your pdf will accept all link include "localhost" and other external links. 并且您的pdf将接受所有链接,包括“ localhost”和其他外部链接。

use Ip address instead of localhost or use Live server url it is working for me 使用Ip地址而不是localhost或使用Live服务器url对我有用

<?php
$fullBaseUrl = "http://127.0.0.1/meme_latest";
$url = $fullBaseUrl.'/designers/attachment/time/'.$value['filetime'].'/uploadTab/imgattach'; 
            //(http://localhost/msme_latest/designers/attachment/time/1394432246/uploadTab/imgattach)     
            $html= '<a href="'.$url.'">Test link</a>';        

            //echo $html; die;

include("../mpdf.php");

$mpdf=new mPDF(); 

$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
?>      

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM