Получение сообщения об ошибке «Не удалось импортировать документ» при открытии документа TCPDF в Adobe Sign & amp; заполнить

Я создал документ в TCPDF, который я должен открыть в Adobe Sign & Заполнить (на моем телефоне Android). У меня проблема в том, что при открытии PDF я получаю сообщение об ошибке, как указано в заголовке. Я опробовал некоторые примеры из TCPDF, и все они, кажется, открываются без проблем, которые говорят мне, что я что-то не так сделал. Созданный мною pdf не имеет проблем с открытием в других программах чтения PDF, даже на моем телефоне, что делает эту проблему довольно специфической.

Любая помощь приветствуется.

Вот код:

<?php

session_start();

include 'loginChecker.php';
include 'apiFunctions.php';
//include 'PHPMailerClass.php';

$url = '*link removed*';
$data = array(
'empid' => $_SESSION['empArray']['id'],
'ids' => $_GET['ids'],
'action' => 'empSubmitTimeCard'
);
$ch = curl_init($url);
$postString = http_build_query($data, '', '&');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = json_decode(curl_exec($ch));
curl_close($ch);
$empSubmitTime = json_decode(json_encode($response), true);

$empid = $_SESSION['empArray']['id'];
$employeeProfile = employeeProfile($_SESSION['empArray']['id']);
$empPic = empPic($empid);
?>

<?php
ob_start();
require_once('tcpdf/tcpdf.php');

// Colored table
function ColoredTable($dates, $regHours, $otHours, $dtHours, $data, $pdf) {
// dates cell
$pdf->SetDrawColor(147, 7, 76);
$pdf->SetFillColor(147, 7, 76);
$pdf->SetTextColor(255, 255, 255);
$pdf->SetFont('', 'B', '10');
$pdf->Cell(21.1, 5, 'Dates', 1, 0, 'C', true);
// Row of actual dates
$pdf->SetFillColor(255, 255, 255);
$pdf->SetTextColor(0, 0, 0);
for ($i = 0; $i < count($dates); $i++)
$pdf->Cell(21.1, 5, $dates[$i], 1, 0, 'C', true);
$pdf->Ln();

// Row displaying days
$dayLine = array('Day', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Totals');
$pdf->SetFillColor(210, 185, 195);
$pdf->SetTextColor(147, 7, 76);
$pdf->SetDrawColor(147, 7, 76);
$pdf->SetFont('', '', '8');
// Header
for ($i = 0; $i < count($dayLine); $i++)
$pdf->Cell(21.1, 5, $dayLine[$i], 1, 0, 'C', true);
$pdf->Ln();

// Row displaying regular hours
$pdf->MultiCell(21.1, 12, 'Regular Hours *Excluding Lunch', 1, 'C', 1, 0, '', '', true, 0, false, true, 12, 'M');
$pdf->SetFillColor(255, 255, 255);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', 'B', '16');
for ($i = 0; $i < count($regHours); $i++)
$pdf->Cell(21.1, 12, $regHours[$i], 1, 0, 'C', true);
$pdf->Ln();

//Row displaying overtime hours
$pdf->SetFillColor(210, 185, 195);
$pdf->SetTextColor(147, 7, 76);
$pdf->SetDrawColor(147, 7, 76);
$pdf->SetFont('', '', '8');
$pdf->MultiCell(21.1, 12, 'Overtime Hours', 1, 'C', 1, 0, '', '', true, 0, false, true, 12, 'M');

$pdf->SetFillColor(255, 255, 255);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', 'B', '16');
for ($i = 0; $i < count($otHours); $i++)
$pdf->Cell(21.1, 12, $otHours[$i], 1, 0, 'C', true);
$pdf->Ln();

//Row display doubletime
$pdf->SetFillColor(210, 185, 195);
$pdf->SetTextColor(147, 7, 76);
$pdf->SetDrawColor(147, 7, 76);
$pdf->SetFont('', '', '8');
$pdf->MultiCell(21.1, 12, 'Double Time Hours', 1, 'C', 1, 0, '', '', true, 0, false, true, 12, 'M');
$pdf->SetFillColor(255, 255, 255);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', 'B', '16');
for ($i = 0; $i < count($dtHours); $i++)
$pdf->Cell(21.1, 12, $dtHours[$i], 1, 0, 'C', true);
$pdf->Ln();
}



$dates = array('', '', '', '', '', '', '', '');
$regHours = array('', '', '', '', '', '', '', '');
$otHours = array('', '', '', '', '', '', '', '');
$dtHours = array('', '', '', '', '', '', '', '');
$regTotal = 0;
$otTotal = 0;
$dtTotal = 0;
foreach ($empSubmitTime['dates'] as $date => $x) {
//echo "test";
$newDate = date($date);
$day = date('N', strtotime($newDate));
//echo $day;
$dates[$day - 1] = $date;
$regHours[$day - 1] = $x["hours"];
$otHours[$day - 1] = $x["othours"];
$dtHours[$day - 1] = $x["dthours"];
$regTotal += $x["hours"];
$otTotal += $x["othours"];
$dtTotal += $x["dthours"];
}
$regHours[count($regHours) - 1] = $regTotal;
$otHours[count($otHours) - 1] = $otTotal;
$dtHours[count($dtHours) - 1] = $dtTotal;

// Column headings
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);

// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

// Data loading
$pdf->SetFont('times', '', 12);
$pdf->AddPage();
$pdf->Image('images/best-logo.png', 10, 10, 70);
// employee name
$pdf->SetFont('times', '', 10);
$pdf->SetAbsXY(0, 10);
$pdf->Cell(0, 8, 'Employee Name:', 0, 0, 'R');
$pdf->Ln(5);
$pdf->SetFont('Courier', '', 20);
$pdf->SetTextColor(255, 0, 0);
$pdf->Cell(0, 8, '33826', 0, 0, 'C');
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(0, 8, $employeeProfile['fname'] . ' ' . $employeeProfile['lname'], 0, 0, 'R');
$pdf->Ln(5);
//p.o. number
$pdf->SetFont('times', '', 10);
$pdf->Cell(0, 8, 'Enter P.O. #:', 0, 0, 'R');
$pdf->Ln(7);
$pdf->SetFont('times', 'B', 12);
$pdf->setX(175);
$pdf->TextField('po', 25, 7);
$pdf->Ln(5);
//job description
$pdf->SetFont('times', '', 10);
$pdf->Cell(0, 8, 'Job Description:', 0, 0, 'R');
$pdf->Ln(5);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(0, 8, $empSubmitTime['position'], 0, 0, 'R');
$pdf->Ln(4);
//best personnel contact
$pdf->SetFont('times', '', 9);
$pdf->Cell(0, 8, 'Suite 118 - 713 Columbia St.', 0, 0, 'L');
$pdf->Ln(3);
$pdf->Cell(0, 8, 'New Westminster, BC V3M 1B2', 0, 0, 'L');
$pdf->Cell(0, 8, 'I understand that should I desire to hire this employee within', 0, 0, 'R');

$pdf->Ln(3);
$pdf->Cell(0, 8, 'Tel: 604-552-4900 Fax: 604-522-4903', 0, 0, 'L');
$pdf->Cell(0, 8, 'a three month period from the completion date of their', 0, 0, 'R');

$pdf->Ln(3);
$pdf->Cell(0, 8, 'Email: accounting@best-personnel.ca', 0, 0, 'L');
$pdf->Cell(0, 8, 'assignment, I am obligated to notify Best Personnel and pay the', 0, 0, 'R');
$pdf->Ln(3);

$pdf->SetFont('times', '', 9);
$pdf->Cell(0, 8, 'applicable temporary or permanent placement fees.', 0, 0, 'R');
$pdf->SetFont('times', '', 10);
$pdf->Ln(4);
$pdf->SetFont('times', '', 10);
$pdf->Cell(0, 8, 'Customer Name:', 0, 0, 'L');
$pdf->Ln(4);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(0, 8, $empSubmitTime['client'], 0, 0, 'L');
$pdf->Ln(4);
$pdf->SetFont('times', '', 10);
$pdf->Cell(0, 8, 'Address:', 0, 0, 'L');
$pdf->SetFont('times', 'B', 10);
$pdf->Cell(0, 8, 'Please do not advance money to our employees.', 0, 0, 'R');
$pdf->Ln(4);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(0, 8, $empSubmitTime['site'], 0, 0, 'L');
$pdf->SetFont('times', 'B', 10);
$pdf->Cell(0, 8, '4 hours minimum per day per employee.', 0, 0, 'R');
$pdf->Ln(10);

// insert table
ColoredTable($dates, $regHours, $otHours, $dtHours, $data, $pdf);
$pdf->SetFont('times', '', 10);
$pdf->Cell(0, 8, 'Statutory minimum and overtime rates as applicable by provincial legislation.', 0, 0, 'C');
$pdf->Ln(4);
$pdf->Cell(0, 8, 'Supervisor approval includes acceptance of Best Personnel\'s terms and conditions:', 0, 0, 'C');
$pdf->Ln(4);
$pdf->SetFont('times', 'B', 10);
$pdf->Cell(0, 8, 'TERMS: PAYMENT DUE UPON RECEIPT OF INVOICE.', 0, 0, 'C');

$f = finfo_open();
$mime_type = finfo_buffer($f, $empPic, FILEINFO_MIME_TYPE);
$mime_type_arr = explode("/", $mime_type);
$extension = "." . $mime_type_arr[1];
file_put_contents("temp/" . $empid . $extension, $empPic);
/* use image */
$pdf->Image("temp/" . $empid . $extension, 80, 200, 50);
unlink("temp/" . $empid . $extension);

$pdf->SetDrawColor(0, 0, 0);
$pdf->Line(20, 175, 190, 175);
$pdf->Ln(45);
$pdf->SetFont('times', 'B', 14);
$pdf->Cell(0, 8, 'Sign here for approval.', 0, 0, 'C');
$pdf->Ln(4);
$pdf->Cell(0, 8, 'Upon approval, save this pdf and send it to payroll@best-personnel.ca.', 0, 0, 'C');

// ---------------------------------------------------------
// Close and output PDF document
// This method has several options, check the source code documentation for more information.
ob_clean();
$pdf->Output('timesheet.pdf', 'I');
ob_end_flush();
?>

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector