用于创建 .pdf 文件的 php 代码无法在服务器上运行

发布于 2024-12-25 07:35:26 字数 2119 浏览 1 评论 0原文

我正在使用 PHP 代码创建 .pdf 文件,并在该 .pdf 文件中归档表单值。

在本地主机上,代码工作正常,它创建 .pdf ,编辑 .pdf 文件...... 但是,当我将相同的代码放在另一台服务器上时,它不会创建 .pdf 并编辑......

代码是-

<?php
date_default_timezone_set('UTC');
require('fpdf/fpdf.php');

class PDF_result extends FPDF {
    function __construct ($orientation = 'P', $unit = 'pt', $format = 'Letter', $margin = 5 ) {
        $this->FPDF($orientation, $unit, $format);
        $this->SetTopMargin($margin);
        $this->SetLeftMargin($margin);
        $this->SetRightMargin($margin);
        //$this->SetRightMargin1($margin1);
        $this->SetAutoPageBreak(true, $margin);
    }

    function Header () {
        //$this->SetLeftMargin(85);
        $this->SetLeftMargin(5);
         $this->Image('header3.jpg',25,15,560);
         $this->SetLeftMargin(25);
    //  $this->SetFont('Arial', 'B', 20);
    //  $this->SetFillColor(36, 96, 84);
    //  $this->SetTextColor(225);
    //  $this->Cell(0, 30, "YouHack MCQ Results", 0, 1, 'C', true);
    }

 function Footer()
{
    //Position at 1.5 cm from bottom
    $this->SetY(-15);
    //Arial italic 8
    $this->SetFont('Arial','I',8);
    //Page number
    $this->Cell(0,10,'ifs , india',0,0,'C');
}


function Generate_Table($subjects, $marks) {
    $this->SetFont('Arial', 'B', 12);
    $this->SetTextColor(0);
//  $this->SetFillColor(94, 188, z);
$this->SetFillColor(94, 188, 225);
    $this->SetLineWidth(1);
    $this->Cell(427, 25, "Subjects", 'LTR', 0, 'C', true);
    $this->Cell(100, 25, "Marks", 'LTR', 1, 'C', true);

    $this->SetFont('Arial', '');
    $this->SetFillColor(238);
    $this->SetLineWidth(0.2);
    $fill = false;

    for ($i = 0; $i < count($subjects); $i++) {
        $this->Cell(427, 20, $subjects[$i], 1, 0, 'L', $fill);
        $this->Cell(100, 20,  $marks[$i], 1, 1, 'R', $fill);
        $fill = !$fill;
    }
    $this->SetX(367);
    //$this->Cell(100, 20, "Total", 1);
//  $this->Cell(100, 20,  array_sum($marks), 1, 1, 'R');
}

}

(其不是完整的代码)

确切的问题是什么?

I am using PHP code for creating .pdf file and I am filing forms values in that .pdf file.

On localhost the code is working fine it creates .pdf ,edit .pdf file ....
But when i am putting same code on another server it's not creating .pdf and edit to......

the code is-

<?php
date_default_timezone_set('UTC');
require('fpdf/fpdf.php');

class PDF_result extends FPDF {
    function __construct ($orientation = 'P', $unit = 'pt', $format = 'Letter', $margin = 5 ) {
        $this->FPDF($orientation, $unit, $format);
        $this->SetTopMargin($margin);
        $this->SetLeftMargin($margin);
        $this->SetRightMargin($margin);
        //$this->SetRightMargin1($margin1);
        $this->SetAutoPageBreak(true, $margin);
    }

    function Header () {
        //$this->SetLeftMargin(85);
        $this->SetLeftMargin(5);
         $this->Image('header3.jpg',25,15,560);
         $this->SetLeftMargin(25);
    //  $this->SetFont('Arial', 'B', 20);
    //  $this->SetFillColor(36, 96, 84);
    //  $this->SetTextColor(225);
    //  $this->Cell(0, 30, "YouHack MCQ Results", 0, 1, 'C', true);
    }

 function Footer()
{
    //Position at 1.5 cm from bottom
    $this->SetY(-15);
    //Arial italic 8
    $this->SetFont('Arial','I',8);
    //Page number
    $this->Cell(0,10,'ifs , india',0,0,'C');
}


function Generate_Table($subjects, $marks) {
    $this->SetFont('Arial', 'B', 12);
    $this->SetTextColor(0);
//  $this->SetFillColor(94, 188, z);
$this->SetFillColor(94, 188, 225);
    $this->SetLineWidth(1);
    $this->Cell(427, 25, "Subjects", 'LTR', 0, 'C', true);
    $this->Cell(100, 25, "Marks", 'LTR', 1, 'C', true);

    $this->SetFont('Arial', '');
    $this->SetFillColor(238);
    $this->SetLineWidth(0.2);
    $fill = false;

    for ($i = 0; $i < count($subjects); $i++) {
        $this->Cell(427, 20, $subjects[$i], 1, 0, 'L', $fill);
        $this->Cell(100, 20,  $marks[$i], 1, 1, 'R', $fill);
        $fill = !$fill;
    }
    $this->SetX(367);
    //$this->Cell(100, 20, "Total", 1);
//  $this->Cell(100, 20,  array_sum($marks), 1, 1, 'R');
}

}

(its not complete code)

What is the exact problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ら栖息 2025-01-01 07:35:26

如果此代码在本地主机上运行,​​则可能是您的服务器上的权限问题。

If this code is working on localhost, maybe it's a permission problem on your server.

友谊不毕业 2025-01-01 07:35:26

检查你的 apache 错误日志。 它通常位于 /var/log/apache/error.log

如果您登录到服务器,输入

tail -f /var/log/apache/error.log

并重新加载页面, - 任何错误都会显示在此处。如果您需要帮助诊断它们,请将它们粘贴到此处

Check your apache error log. It's usually located in /var/log/apache/error.log

if you're logged into your server, type

tail -f /var/log/apache/error.log

and reload the page -- any errors will show here. Paste them here if you need help diagnosing them

七度光 2025-01-01 07:35:26

似乎是权限问题。设置要创建 pdf 文件的目录的权限。

Seems like permission issue. set permission on the directory where the pdf file is expected to create.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文