adminweb/websheet-php

用于生成PDF并发送电子邮件的Websheet SDK。

1.1.2 2022-10-01 20:50 UTC

This package is auto-updated.

Last update: 2024-09-29 06:20:08 UTC


README

PHP Composer

此软件包允许使用我们的服务,以HTML内容生成PDF(并通过电子邮件发送)。

安装

 $ composer require adminweb/websheet-php

用法

https://www.websheet.tech上创建一个API密钥。(无需信用卡)

  1. 生成PDF文件
<?php

require 'vendor/autoload.php';
use WebSheet\Sdk\Pdf;

$pdf = new Pdf('api-key');

$content = '<html>
                <head>
                    <meta charset="utf-8">
                    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
                    <style>
                        body {font-family: "Tangerine", serif;font-size: 48px; text-shadow: 4px 4px 4px #aaa;}
                    </style>
                </head>
                <body>
                    <div>Making the Web Beautiful!</div>
                </body>
            </html>';

$result = $pdf->make('almost finalizado', $content);

echo $result->id; // ID of file
echo $result->name; // Name of file
echo $result->url; // URL of created PDF file
// Creation date of Pdf file (returns DateTime object) (and formats brazilian format here)
echo $result->createdAt->format('d/m/Y '); 
  1. 生成PDF文件并发送电子邮件
<?php

require 'vendor/autoload.php';
use WebSheet\Sdk\Pdf;

$pdf = new Pdf('api-key');

$content = '<html>
                <head>
                    <meta charset="utf-8">
                    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
                    <style>
                        body {font-family: "Tangerine", serif;font-size: 48px; text-shadow: 4px 4px 4px #aaa;}
                    </style>
                </head>
                <body>
                    <div>Making the Web Beautiful!</div>
                </body>
            </html>';
            
// The generated file will send by email to destinatary
$result = $pdf->setDestinatary('bob@example.com')->make('almost finalizado', $content); 
  1. 使用您自己的电子邮件模板生成PDF文件并发送电子邮件(某些计划)。
<?php

require 'vendor/autoload.php';
use WebSheet\Sdk\Pdf;

$pdf = new Pdf('api-key');

$content = '<html>
                <head>
                    <meta charset="utf-8">
                    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
                    <style>
                        body {font-family: "Tangerine", serif;font-size: 48px; text-shadow: 4px 4px 4px #aaa;}
                    </style>
                </head>
                <body>
                    <div>Making the Web Beautiful!</div>
                </body>
            </html>';

// The generated file will send by email to destinatary 
// with template registered in https://websheet.tech
$result = $pdf->setDestinatary('bob@example.com')
              ->setTemplate('template ID')
              ->make('almost finalizado', $content);