feat: add Go, PHP, Laravel examples to examples page and update landing copy
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 12m15s
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 12m15s
This commit is contained in:
parent
bc67c52d3a
commit
0e04fb5523
2 changed files with 63 additions and 4 deletions
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Code Examples — DocFast HTML to PDF API</title>
|
||||
<meta name="description" content="Practical html to pdf api examples — generate pdf from html code, invoice pdf api, markdown to pdf, Node.js and Python integrations.">
|
||||
<meta name="description" content="Practical html to pdf api examples — generate pdf from html code, invoice pdf api, markdown to pdf, Node.js, Python, Go, PHP and Laravel integrations.">
|
||||
<meta property="og:title" content="Code Examples — DocFast HTML to PDF API">
|
||||
<meta property="og:description" content="Practical code examples for generating PDFs from HTML, Markdown, and more with the DocFast API.">
|
||||
<meta property="og:url" content="https://docfast.dev/examples">
|
||||
|
|
@ -113,6 +113,8 @@ footer .container { display: flex; justify-content: space-between; align-items:
|
|||
<a href="#receipt">Receipt</a>
|
||||
<a href="#nodejs">Node.js</a>
|
||||
<a href="#python">Python</a>
|
||||
<a href="#go">Go</a>
|
||||
<a href="#php">PHP</a>
|
||||
</nav>
|
||||
|
||||
<!-- Invoice -->
|
||||
|
|
@ -348,6 +350,63 @@ pdf = response.content</code></pre>
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Go -->
|
||||
<section id="go" class="example-section">
|
||||
<h2>Go Integration</h2>
|
||||
<p>Install the official SDK: <code>go get github.com/docfast/docfast-go</code></p>
|
||||
<div class="code-block">
|
||||
<span class="code-label">Go — Using the SDK</span>
|
||||
<pre><code><span class="kw">package</span> main
|
||||
|
||||
<span class="kw">import</span> (
|
||||
<span class="str">"os"</span>
|
||||
docfast <span class="str">"github.com/docfast/docfast-go"</span>
|
||||
)
|
||||
|
||||
<span class="kw">func</span> main() {
|
||||
client := docfast.New(<span class="str">"df_pro_your_api_key"</span>)
|
||||
|
||||
pdf, err := client.HTML(<span class="str">"<h1>Hello</h1><p>Generated with DocFast</p>"</span>, &docfast.PDFOptions{
|
||||
Format: <span class="str">"A4"</span>,
|
||||
Margin: &docfast.Margin{Top: <span class="str">"20mm"</span>, Bottom: <span class="str">"20mm"</span>},
|
||||
})
|
||||
<span class="kw">if</span> err != <span class="kw">nil</span> {
|
||||
panic(err)
|
||||
}
|
||||
os.WriteFile(<span class="str">"output.pdf"</span>, pdf, <span class="num">0644</span>)
|
||||
}</code></pre>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- PHP -->
|
||||
<section id="php" class="example-section">
|
||||
<h2>PHP Integration</h2>
|
||||
<p>Install the official SDK: <code>composer require docfast/docfast-php</code></p>
|
||||
<div class="code-block">
|
||||
<span class="code-label">PHP — Using the SDK</span>
|
||||
<pre><code><span class="kw">use</span> DocFast\Client;
|
||||
<span class="kw">use</span> DocFast\PdfOptions;
|
||||
|
||||
$client = <span class="kw">new</span> Client(<span class="str">'df_pro_your_api_key'</span>);
|
||||
|
||||
$options = <span class="kw">new</span> PdfOptions();
|
||||
$options->format = <span class="str">'A4'</span>;
|
||||
$options->margin = [<span class="str">'top'</span> => <span class="str">'20mm'</span>, <span class="str">'bottom'</span> => <span class="str">'20mm'</span>];
|
||||
|
||||
$pdf = $client->html(<span class="str">'<h1>Hello</h1><p>Generated with DocFast</p>'</span>, <span class="kw">null</span>, $options);
|
||||
file_put_contents(<span class="str">'output.pdf'</span>, $pdf);</code></pre>
|
||||
</div>
|
||||
<div class="code-block">
|
||||
<span class="code-label">Laravel — Using the Facade</span>
|
||||
<pre><code><span class="kw">use</span> DocFast\Laravel\Facades\DocFast;
|
||||
|
||||
<span class="cmt">// In your controller</span>
|
||||
$pdf = DocFast::html(view(<span class="str">'invoice'</span>)->render());
|
||||
<span class="kw">return</span> response($pdf)
|
||||
->header(<span class="str">'Content-Type'</span>, <span class="str">'application/pdf'</span>);</code></pre>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue