PHP code example of lampnick / doctron-client-php
1. Go to this page and download the library: Download lampnick/doctron-client-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lampnick / doctron-client-php example snippets
use PHPUnit\Framework\TestCase;
hpunit --bootstrap src/Doctron.php tests/DoctronHtml2PdfTest.php
*/
class DoctronHtml2PdfTest extends TestCase
{
const domain = "http://47.52.25.206:8080";
const defaultUsername = "doctron";
const defaultPassword = "lampnick";
const pathPrefix = "./tests/data/";
public function testHtml2Pdf()
{
$requestDTO = \lampnick\doctron\request\HTML2PdfRequestDTO::NewDefaultHTML2PdfRequestDTO();
$requestDTO->url = "http://doctron.lampnick.com/doctron.html";
$doctron = new \lampnick\doctron\Doctron(self::domain, self::defaultUsername, self::defaultPassword);
$localFileFullPath = self::pathPrefix . "html2pdf.pdf";
$doctron->html2Pdf($localFileFullPath, $requestDTO);
//need ulink file manually.
}
public function testHtml2PdfAndUpload()
{
$requestDTO = \lampnick\doctron\request\HTML2PdfRequestDTO::NewDefaultHTML2PdfRequestDTO();
$requestDTO->url = "http://doctron.lampnick.com/doctron.html";
$requestDTO->uploadKey = "test.pdf";
$doctron = new \lampnick\doctron\Doctron(self::domain, self::defaultUsername, self::defaultPassword);
$commonResponse = $doctron->html2PdfAndUpload($requestDTO);
$this->assertEquals(
"https://qjhdqx-prod.oss-cn-zhangjiakou.aliyuncs.com/test.pdf",
$commonResponse->data
);
}
}