Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert feature implementation sdk n docs #28

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions fern/scripts/insert_snippets_docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const { extractSnippets } = require("./extract_snippets");
"fill",
"extract",
"split",
"insert",
];

const curlSnippets = {
Expand Down Expand Up @@ -77,6 +78,14 @@ const { extractSnippets } = require("./extract_snippets");
-H 'Content-Type: multipart/form-data'\n \
-F 'options={splitPage:1};type=application/json'\n \
-F 'file=@document (18).pdf;type=application/pdf'`,
insert: `curl -X 'POST'\n \
'https://api.fileforge.com/pdf/insert/'\n \
-H 'accept: application/pdf'\n \
-H 'X-API-Key : '\n \
-H 'Content-Type: multipart/form-data'\n \
-F 'options={insertPage:1};type=application/json'\n \
-F '[email protected];type=application/pdf'\n \
-F 'files=@document (18).pdf;type=application/pdf'`,
};

const keywordToSnippetsMap = {};
Expand Down
2 changes: 1 addition & 1 deletion fern/sdk
Submodule sdk updated from 4e9cc2 to d45097
123 changes: 123 additions & 0 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ info:
version: 0.1.0
components:
securitySchemes:
basicAuth:
Titou325 marked this conversation as resolved.
Show resolved Hide resolved
type: http
scheme: basic
apiKey:
type: apiKey
name: X-API-Key
Expand Down Expand Up @@ -1287,6 +1290,126 @@ paths:
console.error("Error during PDF extraction:", error);
}
})();
/pdf/insert/:
post:
operationId: insertPDFDocuments
summary: Insert a PDF document into another PDF document at a specified page.
tags:
- PDF
description: >-
Insert a PDF document into another PDF document at a specified page. The
inserted document is named after the original document with a suffix
added to indicate the range of pages it contains
(ex:document\_inserted\_\$insertPage\_\$document2.pdf). Note: The first
document is the parent document and the second document is the document
to be inserted.
requestBody:
content:
multipart/form-data:
schema:
type: object
required:
- options
- files
properties:
options:
required:
- insertPage
type: object
properties:
insertPage:
type: integer
minimum: 1
description: The page number to insert the document at
files:
allOf:
- {}
- type: array
items:
type: string
format: binary
encoding:
options:
contentType: application/json
required: true
security:
- apiKey: []
x-fern-sdk-group-name:
- pdf
x-fern-sdk-method-name: insert
x-fern-availability: generally-available
responses:
'201':
description: PDF file inserted successfully
content:
application/pdf:
schema:
type: string
format: binary
'400':
description: Bad request
content:
application/json:
schema:
description: Bad request
$ref: '#/components/schemas/def-0'
'401':
description: Unauthorized
content:
application/json:
schema:
description: Unauthorized
$ref: '#/components/schemas/def-0'
'500':
description: Internal server error
x-fern-examples:
- response:
body: null
code-samples:
- sdk: curl
code: |-
curl -X 'POST'
'https://api.fileforge.com/pdf/insert/'
-H 'accept: application/pdf'
-H 'X-API-Key : '
-H 'Content-Type: multipart/form-data'
-F 'options={insertPage:1};type=application/json'
-F '[email protected];type=application/pdf'
-F 'files=@document (18).pdf;type=application/pdf'
- sdk: typescript
code: |-
import { FileforgeClient } from "@fileforge/client";
import * as fs from "fs";

(async () => {
const ff = new FileforgeClient({
apiKey: process.env.FILEFORGE_API_KEY,
});

try {
const pdfFiles = [
fs.createReadStream(__dirname + "/pdf1.pdf"),
fs.createReadStream(__dirname + "/pdf2.pdf"),
];
const insertPDFStream = await ff.pdf.insert(
pdfFiles,
{
options: {
// Specify insert options if any
insertPage: 1,
},
},
{
timeoutInSeconds: 60,
},
);
insertPDFStream.pipe(fs.createWriteStream("./result_insert.pdf"));
console.log("PDF inserted successfully. Stream ready.");
} catch (error) {
console.error("Error during PDF insertion:", error);
throw error;
}
})();
servers:
- url: https://api.fileforge.com
description: Tunnel server
Expand Down
Loading