ilovepdf/ilovepdf-php

Fatal error: Class 'Ilovepdf' not found in...

dhirajsah opened this issue · 6 comments

I am new in this i did exactly as ilovepdf document but i am getting error
below is my code:

<?php
require_once("ilovepdf/init.php");

`//` Authenticate
$ilovepdf = new Ilovepdf('project_public_id', 'project_secret_key');

// Choose your processing tool and create a new task
$myTaskCompress = $ilovepdf->newTask('compress');

// Add files to task for upload
$file1 = $myTaskCompress->addFile('file1.pdf');
$file2 = $myTaskCompress->addFile('file2.pdf');

// Execute the task
$myTaskCompress->execute();

// Download the packaged files
$myTaskCompress->download();

?>

Please make sure the require can acces the file from the script path. Maybe add a full path from current file path on require?

require_once(__DIR__ . "ilovepdf/init.php");

Did the same still not working.

@dhirajsah Try using the full namespace:
$ilovepdf = new Ilovepdf\Ilovepdf('project_public_id', 'project_secret_key');

You may also need a backslash in front of the first \Ilovepdf

I'm getting this error:
Fatal error: Uncaught Ilovepdf\Exceptions\AuthException: Unauthorized in /Users/me/Sites/pdf-a/vendor/ilovepdf/ilovepdf-php/src/Ilovepdf.php on line 185
can you help please?
my code (from samples folder):

require_once('vendor/autoload.php');
require_once('vendor/ilovepdf/ilovepdf-php/init.php');

use Ilovepdf\PdfaTask;

$myTask = new PdfaTask('project_public_id','project_secret_key');

$file = $myTask->addFile('myfile.pdf');

$file->setConformance('pdfa-1a');

$myTask->setAllowDowngrade(false);

$myTask->setOutputFilename('pdfa');

$myTask->execute();

$myTask->download('/Users/me/Sites/download');

@uomopalese hello, this should be a new issue.

But, do you have registered and swap the
$myTask = new PdfaTask('project_public_id','project_secret_key');

project_public_id and project_secret_key by the keys provided in your control panel?

Sorry, I thought this was a self-contained library to convert pdf to pdf/a using PHP, did not understand this was related to a website. Actually I don't have an account to ILovePDF. My fault.