dompdf 相关问题

用PHP编写的HTML到PDF转换器

DOMPDF 不起作用,尝试使用“DejaVu Sans”时返回 500

我无法让我的 pdf 生成器工作。我正在使用 dompdf/dompdf 库,但在生成我想要的 PDF 时遇到很多麻烦。我的问题是:每次我尝试使用使用样式的文件生成 PDF 时...

回答 1 投票 0

PHP Dompdf - 找不到块级父级。不好。 (66号线)

所以,我为我的一个项目安装了 dompdf,但是当我尝试转换为 PDF 时,出现以下错误: 遇到未捕获的异常 类型:DOMPDF_Exception 消息:没有块级

回答 1 投票 0

受密码保护的 PDF 无法在 PHP 中打开 DOMPDF

我使用以下代码创建了密码保护, $dompdf = new Dompdf(array('enable_remote' => true)); $dompdf->loadHtml($html_print); #(可选)设置纸张尺寸和方向...

回答 3 投票 0

DOMPDF 仅在最后一页显示图像水印

我尝试使用DomPdf显示图像水印,但它只出现在最后一页。我浏览了一些网站,但没有找到任何相关内容。 这是我的代码: 我尝试使用 DomPdf 显示图像水印,但它只出现在最后一页。我浏览了一些网站,但没有找到任何相关内容。 这是我的代码: <?php require_once 'dompdf/autoload.inc.php'; //referenciar o DomPDF com namespace use Dompdf\Dompdf; //Referenciar o NameSpace Options use Dompdf\Options; //Definir Options para habilitar PHP incorporado. $options = new Options(); $options->set('isPhpEnabled', 'true'); //Criando a Instancia $dompdf = new Dompdf($options); // Carrega seu HTML $dompdf->loadhtml("<h3>https://www.TutorialsWebsite.com</h3><center><h1>Welcome to Tutorials Website</h1><div class="wpb_wrapper"> <p><strong>Tutorialswebsite</strong> is a leading online education portal that helps technologies, software, business and creative skills readers to learn new skills at their own place from the comforts of their drawing rooms. Individual, corporate and academic members have access to learn anything on <a href="https://www.tutorialswebsite.com">tutorialswebsite.com</a> likes video tutorials, blogs content etc.</p> <p>From 5 years, we worked our way to adding new fresh articles on topics ranging from programming languages that helps students, leaders, IT and design professionals, project managers or anyone who is working with software development, creatives and business skills.</p> <h2 style="text-align: center;">Mission</h2> <p>Our mission is to deliver easy and best online resources on programming and web development to encourage our readers acquire as many skills as they would like to. We offer the useful and best tutorials for web professionals-developers, programmers, freelancer free of cost. We don’t force our readers to sign up with us or submit their details.</p>   </div><h2 style="font-size: 24px;text-align: center;font-family:Roboto;font-weight:700;font-style:normal" class="vc_custom_heading">About Author</h2> <p> <strong><a href="https://www.pradeepmaurya.in/">Pradeep Maurya</a></strong> is the Professional Web Developer and Founder of &nbsp;<a href="https://www.tutorialswebsite.com">“Tutorialswebsite”</a>. He lives in Delhi and loves to be a self dependent person. As an author, he is trying his best to improve this platform day by day. You can contact him <strong><a href="https://www.facebook.com/erpradeepmauryarkt" target="_blank" rel="noopener noreferrer">@facebook</a></strong><strong>Website:</strong> <a href="https://www.pradeepmaurya.in" target="_blank" rel="noopener noreferrer">https://www.pradeepmaurya.in</a></p></center> '"); $dompdf->setPaper('A4', 'portrait'); //Renderizar o html $dompdf->render(); //Instanciar o Canvas $canvas = $dompdf->getCanvas(); //Recuperar Altura e Largura da página $width = $canvas->get_width(); $height = $canvas->get_height(); //Especifica a Imagem de Marca D'Água $imageURL = 'img/forper.png'; $imgHeight = 511; $imgWidth = 250; //Define a Opacidade da Imagem $canvas->set_opacity(.3); //Especifica as posições horizontal e vertical $x = (($width - $imgWidth) / 2); $y = (($height - $imgHeight) / 2); //Adiciona a Imagem ao PDF $canvas->image($imageURL, $x, $y, $imgWidth, $imgHeight); //Exibibir a página $dompdf->stream( "$nip.pdf", array( 'Attachment' => false //Para realizar o download somente alterar para true ) ); ?> 我更改了 HTML,因为旧的太大了。 如果只有一页,水印会正确显示,但如果有两页或更多页,图像只会出现在最后一页。 我尝试添加下面的代码以在第一页添加水印,但图像位于文本前面。 // Dirty fix for images and lines $canvas->page_script(' $image = \'img/image.png\'; // $pdf is the variable containing a reference to the canvas object provided by dompdf $pdf->image($image, ' . $x . ', ' . $y . ', ' . $imgWidth . ', ' . $imgHeight . '); '); 您必须使用 page_script 函数(就像您所做的那样),但您也需要编辑内部的画布。 为了避免格式错误并保持良好的维护语法,我建议仅使用画布代码添加一个新文件。 canvasScript.php $canvas = $dompdf->getCanvas(); $width = $canvas->get_width(); $height = $canvas->get_height(); $imageURL = 'img/forper.png'; $imgHeight = 511; $imgWidth = 250; $canvas->set_opacity(.3); $x = (($width - $imgWidth) / 2); $y = (($height - $imgHeight) / 2); $canvas->image($imageURL, $x, $y, $imgWidth, $imgHeight); 您的代码 // [...] // Renderize HTML $dompdf->render(); // Add watermark to all pages $canvasScript = file_get_contents('/canvasScript.php'); $canvas->page_script($canvasScript); $dompdf->stream("your_pdf.pdf"); dompdf没有文档,缺乏这种用法,我建议下次使用mpdf/mpdf。 通过设置水印插入前和插入后图像的不透明度找到了解决方案。 $pdf = Pdf::loadView($view, $data); $pdf->render(); $canvas = $pdf->getCanvas(); $canvas->page_script( function ($pageNumber,$pageCount,$canvas,$fontMetrics){ $w = $canvas->get_width(); $h = $canvas->get_height(); $imageURL = '';//path to image $imgWidth = 500; $imgHeight = 400; // Set opacity for current image $canvas->set_opacity(.2); $x = (($w-$imgWidth)/2); $y = (($h-$imgHeight)/2); $canvas->image($imageURL, $x, $y, $imgWidth, $imgHeight); //reset opacity (this does the trick) $canvas->set_opacity(1); }); return $pdf->stream('pdf.pdf',array("Attachment" => 0));

回答 2 投票 0

在 laravel 中使用 DOMPdf 设置字体

我试图在laravel中生成pdf,然后在页面的css中设置font-family,以便生成的pdf使用该font-family。我正在使用这个包:https://github.com/barryvdh/la...

回答 1 投票 0

无法使用 DOMPDF 渲染 PDF 中的非 ANSI 字符

我正在尝试使用 Pimcore 中的 DOMPDF 创建 PDF,其功能绝对正常,但我在尝试在 PDF 中包含非 ANSI 字符(如泰语、韩语、中文)时遇到问题

回答 1 投票 0

Laravel domPDF 阿拉伯字符生成PDF错误

在我的项目中,我想将某个页面提取到PDF文件中。该页面主要是阿拉伯语。 我正在使用 barryvdh/laravel-dompdf 第一次尝试时,没有显示任何字符,只有

回答 2 投票 0

PHPMailer Sendgrid PHP - DomPDF HTML 渲染附件

我试图通过以下代码附加 dompdf 文件而不保存到服务器: 我从 PHP 响应中得到的错误是:无法发送消息。邮件程序错误:未知编码:pdffilename....

回答 1 投票 0

Dompdf Laravel 错误“找不到图像或类型未知”

我无法下载带有图像的pdf文件,我在我的laravel项目中使用dompdf。 这是我的控制器代码: 公共函数 downloadPdf() { $cakes = Cake::all(); $数据 = [ ...

回答 1 投票 0

在php中使用dompdf将pdf页面分成两部分的问题

以下代码来自我的resume.php文件。我尝试将页面分为两个块,每个块使用 (.left) 和 (.right) 类表示。左侧块的内容正在显示,但在...

回答 1 投票 0

DOMPDF:无法流式传输 pdf:标头已发送

我正在使用基于html表单输入和上传文件的smarty模板生成php页面。使用dompdf,我想将生成的页面保存为pdf文件。 当用户提交 multipart/form-d...

回答 11 投票 0

Barryvdh\DomPDF\Facade\Pdf 不加载 css 和图像

在本地一切正常,但一旦我去检查部署,它就完全失败了。如果我将其转换为视图而不是像我的代码那样的 pdf,则可以按照我的意图检查 pdf 文件 什么...

回答 1 投票 0

dompdf:找不到图像或类型未知

这是我的代码, 我几乎尝试了所有在 PDF 上显示图像的方法,但仍然不起作用。 你能帮我解决这个问题吗? 我还将 DOMPDF_ENABLE_REMOTE 设置为 true,结果仍然相同...

回答 11 投票 0

使用 Laravel 的 amazon s3 中的 dompdf 输出未上传数据

嗨,我正在尝试上传未上传的 dompdf 输出 我试过 $path = \Storage::disk('s3')->put('invoice/invoice-1001aaaaaa.pdf', $pdf->output(), ['visibility' => 'public']); $...

回答 1 投票 0

希腊字母被替换为???一旦我使用 PHPWord 将 docx 转换为 pdf?

我做了以下简单的 laravel artisan 命令: Artisan::command('测试:pdf',function(){ \PhpOffice\PhpWord\Settings::setPdfRendererName(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF); ...

回答 2 投票 0

Laravel:在 pdf 上添加具有特定位置的图像

构建Laravel API,我有合同PDF文件存储在远程服务器中,并以uid保存在数据库中,还有在线签名文件,是png。现在,当用户单击签名按钮时,我想要...

回答 1 投票 0

dompdf 添加到附件 Laravel

我想将 pdf 文件保存在 laravel 中而不是下载它,以便在创建邮件时可以附加它。 似乎在文档中找不到保存功能。 $document = new Dompdf($option...

回答 1 投票 0

在 Symfony 应用程序中使用 Dompdf 识别和解决内存问题

问题描述 我在使用 Dompdf 生成 PDF 文件时在 Symfony 应用程序中遇到内存不足问题。我怀疑 Dompdf 库中可能存在内存泄漏。投资...

回答 1 投票 0

laravel dompdf 导出不导出我视图的所有内容

我目前正在使用 Laravel 9,laravel dompdf 包来导出我的文件,这是我得到的 pdf 文件,根本没有内容。我传递的数据没有显示在 PDF 中。 但是当我把它打开为 v...

回答 2 投票 0

dompdf 字符编码 UTF-8

我正在尝试使用正确的字符创建pdf,但有“?”字符。 我创建了一个测试 php 文件,我试图在其中寻找最佳解决方案。如果我在浏览器中打开 html,我看起来不错 你...

回答 12 投票 0

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.