ilovepdf / ilovepdf-php

iLovePDF Rest Api - PHP Library (https://developer.ilovepdf.com)
146 stars 39 forks source link

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

Closed dhirajsah closed 6 years ago

dhirajsah commented 6 years ago

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();

?>
maztch commented 6 years ago

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");

dhirajsah commented 6 years ago

Did the same still not working.

beard7 commented 5 years ago

@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

uomopalese commented 5 years ago

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');
marcogrossisas commented 5 years ago

@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?

uomopalese commented 5 years ago

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.