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 charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Code Examples — DocFast HTML to PDF API</title>
|
<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: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: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">
|
<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="#receipt">Receipt</a>
|
||||||
<a href="#nodejs">Node.js</a>
|
<a href="#nodejs">Node.js</a>
|
||||||
<a href="#python">Python</a>
|
<a href="#python">Python</a>
|
||||||
|
<a href="#go">Go</a>
|
||||||
|
<a href="#php">PHP</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<!-- Invoice -->
|
<!-- Invoice -->
|
||||||
|
|
@ -348,6 +350,63 @@ pdf = response.content</code></pre>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</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>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@type": "Question",
|
"@type": "Question",
|
||||||
"name": "Do you have SDKs for Node.js and Python?",
|
"name": "Do you have official SDKs?",
|
||||||
"acceptedAnswer": {
|
"acceptedAnswer": {
|
||||||
"@type": "Answer",
|
"@type": "Answer",
|
||||||
"text": "Yes, DocFast provides official SDKs for both Node.js and Python. You can also use the REST API directly with curl or any HTTP client in your preferred language."
|
"text": "Yes, DocFast provides official SDKs for Node.js, Python, Go, PHP, and Laravel. You can also use the REST API directly with curl or any HTTP client."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -450,7 +450,7 @@ html, body {
|
||||||
<section class="features" id="features">
|
<section class="features" id="features">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2 class="section-title">Everything you need</h2>
|
<h2 class="section-title">Everything you need</h2>
|
||||||
<p class="section-sub">Official SDKs for Node.js and Python. Or just use curl.</p>
|
<p class="section-sub">Official SDKs for Node.js, Python, Go, PHP, and Laravel. Or just use curl.</p>
|
||||||
<div class="features-grid">
|
<div class="features-grid">
|
||||||
<div class="feature-card">
|
<div class="feature-card">
|
||||||
<div class="feature-icon" aria-hidden="true">⚡</div>
|
<div class="feature-icon" aria-hidden="true">⚡</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue