-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpdfengines.go
More file actions
318 lines (262 loc) · 9.42 KB
/
Copy pathpdfengines.go
File metadata and controls
318 lines (262 loc) · 9.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
package gotenberg
import (
"context"
"io"
"strconv"
"time"
)
// Convert creates a request to convert PDFs to PDF/A & PDF/UA.
func (r *PDFEngines) Convert(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/convert")
return r
}
// MetadataRead creates a request to read metadata from PDFs.
func (r *PDFEngines) MetadataRead(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/metadata/read")
return r
}
// MetadataWrite creates a request to write metadata to PDFs.
func (r *PDFEngines) MetadataWrite(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/metadata/write")
return r
}
// Merge creates a request to merge PDFs.
func (r *PDFEngines) Merge(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/merge")
return r
}
// Split creates a request to split PDFs.
func (r *PDFEngines) Split(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/split")
return r
}
// Flatten creates a request to flatten PDFs.
func (r *PDFEngines) Flatten(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/flatten")
return r
}
// Watermark creates a request to apply a watermark behind page content.
func (r *PDFEngines) Watermark(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/watermark")
return r
}
// Stamp creates a request to apply a stamp on top of page content.
func (r *PDFEngines) Stamp(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/stamp")
return r
}
// Rotate creates a request to rotate PDF pages by 90°, 180°, or 270°.
func (r *PDFEngines) Rotate(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/rotate")
return r
}
// BookmarksRead creates a request to read the bookmark outline from PDF files as JSON.
func (r *PDFEngines) BookmarksRead(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/bookmarks/read")
return r
}
// BookmarksWrite creates a request to write bookmarks to PDF files.
func (r *PDFEngines) BookmarksWrite(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/bookmarks/write")
return r
}
// Send executes the request and returns the response.
func (r *PDFEngines) Send() (*Response, error) {
return r.Request.Send()
}
// Header adds an HTTP header to the request.
func (r *PDFEngines) Header(key, value string) *PDFEngines {
r.Request.Header(key, value)
return r
}
// Param adds a form parameter to the request.
func (r *PDFEngines) Param(key, value string) *PDFEngines {
r.Request.Param(key, value)
return r
}
// Bool adds a boolean form parameter to the request.
func (r *PDFEngines) Bool(fieldName string, value bool) *PDFEngines {
r.Request.Bool(fieldName, value)
return r
}
// Float adds a float64 form parameter to the request.
func (r *PDFEngines) Float(fieldName string, value float64) *PDFEngines {
r.Request.Float(fieldName, value)
return r
}
// File adds a file to the request.
func (r *PDFEngines) File(filename string, content io.Reader) *PDFEngines {
r.Request.File(filename, content)
return r
}
// WebhookURL sets the webhook URL and HTTP method for successful operations.
func (r *PDFEngines) WebhookURL(url, method string) *PDFEngines {
r.Request.WebhookURL(url, method)
return r
}
// WebhookErrorURL sets the webhook URL and HTTP method for failed operations.
func (r *PDFEngines) WebhookErrorURL(url, method string) *PDFEngines {
r.Request.WebhookErrorURL(url, method)
return r
}
// WebhookEventsURL sets the webhook events URL for structured JSON event callbacks.
func (r *PDFEngines) WebhookEventsURL(url string) *PDFEngines {
r.Request.WebhookEventsURL(url)
return r
}
// WebhookHeader adds a custom header to be sent with webhook requests.
func (r *PDFEngines) WebhookHeader(key, value string) *PDFEngines {
r.Request.WebhookHeader(key, value)
return r
}
// DownloadFrom sets the downloadFrom parameter for downloading files from URLs.
func (r *PDFEngines) DownloadFrom(url string, headers map[string]string) *PDFEngines {
r.Request.DownloadFrom(url, headers)
return r
}
// OutputFilename sets the output filename.
func (r *PDFEngines) OutputFilename(filename string) *PDFEngines {
r.Request.OutputFilename(filename)
return r
}
// Trace sets the request trace identifier for debugging and monitoring.
func (r *PDFEngines) Trace(trace string) *PDFEngines {
r.Request.Trace(trace)
return r
}
// Timeout sets a timeout for the request.
func (r *PDFEngines) Timeout(duration time.Duration) *PDFEngines {
r.Request.Timeout(duration)
return r
}
// Metadata sets the metadata for the PDF.
func (r *PDFEngines) Metadata(key, value string) *PDFEngines {
r.Request.Metadata(key, value)
return r
}
// PDFA converts to PDF/A format.
func (r *PDFEngines) PDFA(pdfa string) *PDFEngines {
return r.Param("pdfa", pdfa)
}
// PDFUA enables PDF for Universal Access.
func (r *PDFEngines) PDFUA(pdfua bool) *PDFEngines {
return r.Bool("pdfua", pdfua)
}
// SplitMode sets the split mode.
func (r *PDFEngines) SplitMode(mode string) *PDFEngines {
return r.Param("splitMode", mode)
}
// SplitSpan sets the split span.
func (r *PDFEngines) SplitSpan(span string) *PDFEngines {
return r.Param("splitSpan", span)
}
// SplitUnify specifies whether to unify split pages.
func (r *PDFEngines) SplitUnify(unify bool) *PDFEngines {
return r.Bool("splitUnify", unify)
}
// FlattenPDF sets the flatten flag.
func (r *PDFEngines) FlattenPDF(flatten bool) *PDFEngines {
return r.Bool("flatten", flatten)
}
// RotateAngle sets the rotation angle for pages.
func (r *PDFEngines) RotateAngle(angle int) *PDFEngines {
return r.Param("rotateAngle", strconv.Itoa(angle))
}
// RotatePages sets the page selection for rotation.
func (r *PDFEngines) RotatePages(pages string) *PDFEngines {
return r.Param("rotatePages", pages)
}
// Bookmarks sets the bookmarks JSON.
func (r *PDFEngines) Bookmarks(json string) *PDFEngines {
return r.Param("bookmarks", json)
}
// AutoIndexBookmarks extracts and reindexes existing bookmarks from input files during merge.
func (r *PDFEngines) AutoIndexBookmarks(v bool) *PDFEngines {
return r.Bool("autoIndexBookmarks", v)
}
// WatermarkFile adds a watermark source file (image or PDF) to the request.
func (r *PDFEngines) WatermarkFile(filename string, content io.Reader) *PDFEngines {
r.file("watermark", filename, content)
return r
}
// StampFile adds a stamp source file (image or PDF) to the request.
func (r *PDFEngines) StampFile(filename string, content io.Reader) *PDFEngines {
r.file("stamp", filename, content)
return r
}
// EmbedsMetadata sets per-file metadata.
func (r *PDFEngines) EmbedsMetadata(metadataJSON string) *PDFEngines {
return r.Param("embedsMetadata", metadataJSON)
}
// Embed creates a request to embed files into a PDF.
func (r *PDFEngines) Embed(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/embed")
return r
}
// FacturX creates a request to generate a Factur-X / ZUGFeRD e-invoice.
func (r *PDFEngines) FacturX(ctx context.Context) *PDFEngines {
r.Req = r.HttpStream.Multipart(ctx, "/forms/pdfengines/factur-x")
return r
}
// FacturXXml adds the CII invoice XML file.
func (r *PDFEngines) FacturXXml(filename string, content io.Reader) *PDFEngines {
r.file("facturxXml", filename, content)
return r
}
// FacturXConformanceLevel sets the conformance level recorded in XMP metadata.
func (r *PDFEngines) FacturXConformanceLevel(level string) *PDFEngines {
return r.Param("facturxConformanceLevel", level)
}
// FacturXDocumentType sets the document type.
func (r *PDFEngines) FacturXDocumentType(docType string) *PDFEngines {
return r.Param("facturxDocumentType", docType)
}
// FacturXVersion sets the version recorded in XMP metadata.
func (r *PDFEngines) FacturXVersion(version string) *PDFEngines {
return r.Param("facturxVersion", version)
}
// UserPassword sets the password required to open the PDF.
func (r *PDFEngines) UserPassword(password string) *PDFEngines {
r.Request.UserPassword(password)
return r
}
// OwnerPassword sets the password required to change permissions or edit the PDF.
func (r *PDFEngines) OwnerPassword(password string) *PDFEngines {
r.Request.OwnerPassword(password)
return r
}
// AllowPrinting permits printing the document.
func (r *PDFEngines) AllowPrinting(allow bool) *PDFEngines {
r.Request.AllowPrinting(allow)
return r
}
// AllowCopying permits extracting text and graphics.
func (r *PDFEngines) AllowCopying(allow bool) *PDFEngines {
r.Request.AllowCopying(allow)
return r
}
// AllowModifying permits changing the document content.
func (r *PDFEngines) AllowModifying(allow bool) *PDFEngines {
r.Request.AllowModifying(allow)
return r
}
// AllowAnnotating permits adding or modifying annotations.
func (r *PDFEngines) AllowAnnotating(allow bool) *PDFEngines {
r.Request.AllowAnnotating(allow)
return r
}
// AllowFillingForms permits filling in form fields.
func (r *PDFEngines) AllowFillingForms(allow bool) *PDFEngines {
r.Request.AllowFillingForms(allow)
return r
}
// AllowAssembling permits inserting, deleting, and rotating pages.
func (r *PDFEngines) AllowAssembling(allow bool) *PDFEngines {
r.Request.AllowAssembling(allow)
return r
}
// Embeds adds a file to be embedded in the resulting PDF.
func (r *PDFEngines) Embeds(filename string, content io.Reader) *PDFEngines {
r.Request.Embeds(filename, content)
return r
}