Reorganize project structure and migrate CI to Forgejo
Some checks are pending
Deploy / deploy (push) Waiting to run
Some checks are pending
Deploy / deploy (push) Waiting to run
Move all files from deploy/ to project root, replace .gitlab-ci.yml with .forgejo/workflows/deploy.yml using Gitea Actions format. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
baa36144a8
commit
b130f5c9d8
13 changed files with 71 additions and 66 deletions
|
|
@ -1,320 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Web2Print API Documentation</title>
|
||||
<link rel="stylesheet" href="/assets/css/docs.css">
|
||||
<link rel="stylesheet" href="/assets/css/highlight-github-dark.min.css">
|
||||
<script src="/assets/js/highlight.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div class="container">
|
||||
<h1>Web2Print API</h1>
|
||||
<p class="subtitle">Générez des PDF à partir de HTML avec Paged.js</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
<section class="intro">
|
||||
<h2>Introduction</h2>
|
||||
<p>
|
||||
L'API Web2Print permet de générer des documents PDF de haute qualité à partir de contenu HTML.
|
||||
Elle utilise <strong>Paged.js</strong> pour appliquer les standards CSS Paged Media,
|
||||
offrant un contrôle précis sur la mise en page, les sauts de page, les en-têtes, les pieds de page et bien plus.
|
||||
</p>
|
||||
<p>
|
||||
Cette API est conçue pour être simple d'utilisation tout en offrant une grande flexibilité
|
||||
pour créer des documents professionnels tels que rapports, factures, catalogues ou livres.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="auth-info">
|
||||
<strong>🔐 Authentification requise</strong>
|
||||
<p>
|
||||
Toutes les requêtes doivent inclure un header <code>X-API-Key</code> avec une clé API valide.
|
||||
Contactez l'administrateur pour obtenir votre clé d'accès.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<h2>Endpoints</h2>
|
||||
|
||||
<article class="endpoint">
|
||||
<div class="endpoint-header">
|
||||
<span class="method">POST</span>
|
||||
<span class="path">/generate</span>
|
||||
</div>
|
||||
|
||||
<p class="description">
|
||||
Génère un document PDF à partir de contenu HTML. Le HTML peut inclure des styles inline
|
||||
ou dans une balise <code><style></code>. CSS additionnel peut être fourni via le paramètre <code>css</code>.
|
||||
</p>
|
||||
|
||||
<h3>Paramètres</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Paramètre</th>
|
||||
<th>Type</th>
|
||||
<th>Requis</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>html</code></td>
|
||||
<td>string</td>
|
||||
<td><span class="badge required">Requis</span></td>
|
||||
<td>Contenu HTML du document à convertir en PDF</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>css</code></td>
|
||||
<td>string</td>
|
||||
<td><span class="badge optional">Optionnel</span></td>
|
||||
<td>Styles CSS additionnels à appliquer au document</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>options</code></td>
|
||||
<td>object</td>
|
||||
<td><span class="badge optional">Optionnel</span></td>
|
||||
<td>Options de configuration pour la génération PDF</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>Headers requis</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Header</th>
|
||||
<th>Valeur</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>Content-Type</code></td>
|
||||
<td><code>application/json</code></td>
|
||||
<td>Type de contenu de la requête</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>X-API-Key</code></td>
|
||||
<td>Votre clé API</td>
|
||||
<td>Clé d'authentification</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>Réponse</h3>
|
||||
<p class="description">
|
||||
En cas de succès, l'API retourne le fichier PDF binaire avec le header <code>Content-Type: application/pdf</code>.
|
||||
En cas d'erreur, elle retourne un JSON avec un objet <code>error</code>.
|
||||
</p>
|
||||
|
||||
<h3>Exemples de code</h3>
|
||||
|
||||
<div class="tabs">
|
||||
<button class="tab-button active" data-tab="curl">cURL</button>
|
||||
<button class="tab-button" data-tab="javascript">JavaScript</button>
|
||||
<button class="tab-button" data-tab="python">Python</button>
|
||||
<button class="tab-button" data-tab="php">PHP</button>
|
||||
</div>
|
||||
|
||||
<div class="tab-content active" id="curl">
|
||||
<pre><code class="language-bash">curl -X POST https://web2print.studio-variable.com/generate \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: YOUR_API_KEY" \
|
||||
-d '{
|
||||
"html": "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><style>@page { size: A4; margin: 2cm; } body { font-family: Arial; } h1 { color: #333; }</style></head><body><h1>Mon Document</h1><p>Contenu du document.</p></body></html>"
|
||||
}' \
|
||||
--output document.pdf</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab-content" id="javascript">
|
||||
<pre><code class="language-javascript">const response = await fetch('https://web2print.studio-variable.com/generate', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-Key': 'YOUR_API_KEY'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
html: `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
@page { size: A4; margin: 2cm; }
|
||||
body { font-family: Arial; }
|
||||
h1 { color: #333; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Mon Document</h1>
|
||||
<p>Contenu du document.</p>
|
||||
</body>
|
||||
</html>`
|
||||
})
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'document.pdf';
|
||||
a.click();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
console.error('Erreur:', error);
|
||||
}</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab-content" id="python">
|
||||
<pre><code class="language-python">import requests
|
||||
|
||||
url = 'https://web2print.studio-variable.com/generate'
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-Key': 'YOUR_API_KEY'
|
||||
}
|
||||
data = {
|
||||
'html': '''<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
@page { size: A4; margin: 2cm; }
|
||||
body { font-family: Arial; }
|
||||
h1 { color: #333; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Mon Document</h1>
|
||||
<p>Contenu du document.</p>
|
||||
</body>
|
||||
</html>'''
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
|
||||
if response.status_code == 200:
|
||||
with open('document.pdf', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print('PDF généré avec succès')
|
||||
else:
|
||||
print('Erreur:', response.json())</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab-content" id="php">
|
||||
<pre><code class="language-php">$ch = curl_init('https://web2print.studio-variable.com/generate');
|
||||
|
||||
$html = '<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
@page { size: A4; margin: 2cm; }
|
||||
body { font-family: Arial; }
|
||||
h1 { color: #333; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Mon Document</h1>
|
||||
<p>Contenu du document.</p>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
$data = json_encode(['html' => $html]);
|
||||
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
'X-API-Key: YOUR_API_KEY'
|
||||
],
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($httpCode === 200) {
|
||||
file_put_contents('document.pdf', $response);
|
||||
echo 'PDF généré avec succès';
|
||||
} else {
|
||||
$error = json_decode($response, true);
|
||||
echo 'Erreur: ' . $error['error'];
|
||||
}</code></pre>
|
||||
</div>
|
||||
|
||||
<h3>Codes de réponse HTTP</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Code</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>200</code></td>
|
||||
<td>Succès - Le PDF est retourné dans le corps de la réponse</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>400</code></td>
|
||||
<td>Requête invalide - JSON mal formé ou paramètre manquant</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>401</code></td>
|
||||
<td>Non autorisé - Clé API manquante ou invalide</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>405</code></td>
|
||||
<td>Méthode non autorisée - Seul POST est accepté</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>413</code></td>
|
||||
<td>Requête trop volumineuse - Le contenu HTML dépasse la limite</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>500</code></td>
|
||||
<td>Erreur serveur - Erreur lors de la génération du PDF</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
</main>
|
||||
|
||||
<footer class="container">
|
||||
<p>Web2Print API © 2024 - Propulsé par Paged.js</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
// Gestion des onglets
|
||||
document.querySelectorAll('.tab-button').forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
const tabName = button.dataset.tab;
|
||||
const tabGroup = button.closest('.endpoint');
|
||||
|
||||
// Désactiver tous les onglets et contenus
|
||||
tabGroup.querySelectorAll('.tab-button').forEach(btn => {
|
||||
btn.classList.remove('active');
|
||||
});
|
||||
tabGroup.querySelectorAll('.tab-content').forEach(content => {
|
||||
content.classList.remove('active');
|
||||
});
|
||||
|
||||
// Activer l'onglet et le contenu sélectionnés
|
||||
button.classList.add('active');
|
||||
tabGroup.querySelector(`#${tabName}`).classList.add('active');
|
||||
});
|
||||
});
|
||||
|
||||
// Highlight.js
|
||||
hljs.highlightAll();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue