|
76 | 76 | BasePdfRestGraphicPayload, |
77 | 77 | BmpPdfRestPayload, |
78 | 78 | ConvertToMarkdownPayload, |
| 79 | + ConvertToPdfPayload, |
| 80 | + ConvertUrlsToPdfPayload, |
79 | 81 | DeletePayload, |
80 | 82 | ExtractImagesPayload, |
81 | 83 | ExtractTextPayload, |
|
118 | 120 | FlattenQuality, |
119 | 121 | GifColorModel, |
120 | 122 | GraphicSmoothing, |
| 123 | + HtmlPageOrientation, |
| 124 | + HtmlPageSize, |
| 125 | + HtmlWebLayout, |
121 | 126 | JpegColorModel, |
122 | 127 | OcrLanguage, |
123 | 128 | PdfAType, |
| 129 | + PdfConversionCompression, |
| 130 | + PdfConversionDownsample, |
| 131 | + PdfConversionLocale, |
124 | 132 | PdfInfoQuery, |
125 | 133 | PdfMergeInput, |
126 | 134 | PdfPageSelection, |
@@ -3078,6 +3086,100 @@ def rasterize_pdf( |
3078 | 3086 | timeout=timeout, |
3079 | 3087 | ) |
3080 | 3088 |
|
| 3089 | + def convert_to_pdf( |
| 3090 | + self, |
| 3091 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 3092 | + *, |
| 3093 | + output: str | None = None, |
| 3094 | + compression: PdfConversionCompression | None = None, |
| 3095 | + downsample: PdfConversionDownsample | None = None, |
| 3096 | + tagged_pdf: bool | None = None, |
| 3097 | + locale: PdfConversionLocale | None = None, |
| 3098 | + page_size: HtmlPageSize | None = None, |
| 3099 | + page_margin: str | None = None, |
| 3100 | + page_orientation: HtmlPageOrientation | None = None, |
| 3101 | + web_layout: HtmlWebLayout | None = None, |
| 3102 | + extra_query: Query | None = None, |
| 3103 | + extra_headers: AnyMapping | None = None, |
| 3104 | + extra_body: Body | None = None, |
| 3105 | + timeout: TimeoutTypes | None = None, |
| 3106 | + ) -> PdfRestFileBasedResponse: |
| 3107 | + """Convert a supported file type to PDF.""" |
| 3108 | + |
| 3109 | + payload: dict[str, Any] = {"files": file} |
| 3110 | + if output is not None: |
| 3111 | + payload["output"] = output |
| 3112 | + if compression is not None: |
| 3113 | + payload["compression"] = compression |
| 3114 | + if downsample is not None: |
| 3115 | + payload["downsample"] = downsample |
| 3116 | + if tagged_pdf is not None: |
| 3117 | + payload["tagged_pdf"] = tagged_pdf |
| 3118 | + if locale is not None: |
| 3119 | + payload["locale"] = locale |
| 3120 | + if page_size is not None: |
| 3121 | + payload["page_size"] = page_size |
| 3122 | + if page_margin is not None: |
| 3123 | + payload["page_margin"] = page_margin |
| 3124 | + if page_orientation is not None: |
| 3125 | + payload["page_orientation"] = page_orientation |
| 3126 | + if web_layout is not None: |
| 3127 | + payload["web_layout"] = web_layout |
| 3128 | + |
| 3129 | + return self._post_file_operation( |
| 3130 | + endpoint="/pdf", |
| 3131 | + payload=payload, |
| 3132 | + payload_model=ConvertToPdfPayload, |
| 3133 | + extra_query=extra_query, |
| 3134 | + extra_headers=extra_headers, |
| 3135 | + extra_body=extra_body, |
| 3136 | + timeout=timeout, |
| 3137 | + ) |
| 3138 | + |
| 3139 | + def convert_urls_to_pdf( |
| 3140 | + self, |
| 3141 | + urls: UrlInput, |
| 3142 | + *, |
| 3143 | + output: str | None = None, |
| 3144 | + compression: PdfConversionCompression | None = None, |
| 3145 | + downsample: PdfConversionDownsample | None = None, |
| 3146 | + page_size: HtmlPageSize | None = None, |
| 3147 | + page_margin: str | None = None, |
| 3148 | + page_orientation: HtmlPageOrientation | None = None, |
| 3149 | + web_layout: HtmlWebLayout | None = None, |
| 3150 | + extra_query: Query | None = None, |
| 3151 | + extra_headers: AnyMapping | None = None, |
| 3152 | + extra_body: Body | None = None, |
| 3153 | + timeout: TimeoutTypes | None = None, |
| 3154 | + ) -> PdfRestFileBasedResponse: |
| 3155 | + """Convert HTML content from one or more URLs to PDF.""" |
| 3156 | + |
| 3157 | + payload: dict[str, Any] = {"url": urls} |
| 3158 | + if output is not None: |
| 3159 | + payload["output"] = output |
| 3160 | + if compression is not None: |
| 3161 | + payload["compression"] = compression |
| 3162 | + if downsample is not None: |
| 3163 | + payload["downsample"] = downsample |
| 3164 | + if page_size is not None: |
| 3165 | + payload["page_size"] = page_size |
| 3166 | + if page_margin is not None: |
| 3167 | + payload["page_margin"] = page_margin |
| 3168 | + if page_orientation is not None: |
| 3169 | + payload["page_orientation"] = page_orientation |
| 3170 | + if web_layout is not None: |
| 3171 | + payload["web_layout"] = web_layout |
| 3172 | + |
| 3173 | + return self._post_file_operation( |
| 3174 | + endpoint="/pdf", |
| 3175 | + payload=payload, |
| 3176 | + payload_model=ConvertUrlsToPdfPayload, |
| 3177 | + extra_query=extra_query, |
| 3178 | + extra_headers=extra_headers, |
| 3179 | + extra_body=extra_body, |
| 3180 | + timeout=timeout, |
| 3181 | + ) |
| 3182 | + |
3081 | 3183 | def convert_to_pdfa( |
3082 | 3184 | self, |
3083 | 3185 | file: PdfRestFile | Sequence[PdfRestFile], |
@@ -4365,6 +4467,100 @@ async def rasterize_pdf( |
4365 | 4467 | timeout=timeout, |
4366 | 4468 | ) |
4367 | 4469 |
|
| 4470 | + async def convert_to_pdf( |
| 4471 | + self, |
| 4472 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 4473 | + *, |
| 4474 | + output: str | None = None, |
| 4475 | + compression: PdfConversionCompression | None = None, |
| 4476 | + downsample: PdfConversionDownsample | None = None, |
| 4477 | + tagged_pdf: bool | None = None, |
| 4478 | + locale: PdfConversionLocale | None = None, |
| 4479 | + page_size: HtmlPageSize | None = None, |
| 4480 | + page_margin: str | None = None, |
| 4481 | + page_orientation: HtmlPageOrientation | None = None, |
| 4482 | + web_layout: HtmlWebLayout | None = None, |
| 4483 | + extra_query: Query | None = None, |
| 4484 | + extra_headers: AnyMapping | None = None, |
| 4485 | + extra_body: Body | None = None, |
| 4486 | + timeout: TimeoutTypes | None = None, |
| 4487 | + ) -> PdfRestFileBasedResponse: |
| 4488 | + """Asynchronously convert a supported file type to PDF.""" |
| 4489 | + |
| 4490 | + payload: dict[str, Any] = {"files": file} |
| 4491 | + if output is not None: |
| 4492 | + payload["output"] = output |
| 4493 | + if compression is not None: |
| 4494 | + payload["compression"] = compression |
| 4495 | + if downsample is not None: |
| 4496 | + payload["downsample"] = downsample |
| 4497 | + if tagged_pdf is not None: |
| 4498 | + payload["tagged_pdf"] = tagged_pdf |
| 4499 | + if locale is not None: |
| 4500 | + payload["locale"] = locale |
| 4501 | + if page_size is not None: |
| 4502 | + payload["page_size"] = page_size |
| 4503 | + if page_margin is not None: |
| 4504 | + payload["page_margin"] = page_margin |
| 4505 | + if page_orientation is not None: |
| 4506 | + payload["page_orientation"] = page_orientation |
| 4507 | + if web_layout is not None: |
| 4508 | + payload["web_layout"] = web_layout |
| 4509 | + |
| 4510 | + return await self._post_file_operation( |
| 4511 | + endpoint="/pdf", |
| 4512 | + payload=payload, |
| 4513 | + payload_model=ConvertToPdfPayload, |
| 4514 | + extra_query=extra_query, |
| 4515 | + extra_headers=extra_headers, |
| 4516 | + extra_body=extra_body, |
| 4517 | + timeout=timeout, |
| 4518 | + ) |
| 4519 | + |
| 4520 | + async def convert_urls_to_pdf( |
| 4521 | + self, |
| 4522 | + urls: UrlInput, |
| 4523 | + *, |
| 4524 | + output: str | None = None, |
| 4525 | + compression: PdfConversionCompression | None = None, |
| 4526 | + downsample: PdfConversionDownsample | None = None, |
| 4527 | + page_size: HtmlPageSize | None = None, |
| 4528 | + page_margin: str | None = None, |
| 4529 | + page_orientation: HtmlPageOrientation | None = None, |
| 4530 | + web_layout: HtmlWebLayout | None = None, |
| 4531 | + extra_query: Query | None = None, |
| 4532 | + extra_headers: AnyMapping | None = None, |
| 4533 | + extra_body: Body | None = None, |
| 4534 | + timeout: TimeoutTypes | None = None, |
| 4535 | + ) -> PdfRestFileBasedResponse: |
| 4536 | + """Asynchronously convert HTML content from one or more URLs to PDF.""" |
| 4537 | + |
| 4538 | + payload: dict[str, Any] = {"url": urls} |
| 4539 | + if output is not None: |
| 4540 | + payload["output"] = output |
| 4541 | + if compression is not None: |
| 4542 | + payload["compression"] = compression |
| 4543 | + if downsample is not None: |
| 4544 | + payload["downsample"] = downsample |
| 4545 | + if page_size is not None: |
| 4546 | + payload["page_size"] = page_size |
| 4547 | + if page_margin is not None: |
| 4548 | + payload["page_margin"] = page_margin |
| 4549 | + if page_orientation is not None: |
| 4550 | + payload["page_orientation"] = page_orientation |
| 4551 | + if web_layout is not None: |
| 4552 | + payload["web_layout"] = web_layout |
| 4553 | + |
| 4554 | + return await self._post_file_operation( |
| 4555 | + endpoint="/pdf", |
| 4556 | + payload=payload, |
| 4557 | + payload_model=ConvertUrlsToPdfPayload, |
| 4558 | + extra_query=extra_query, |
| 4559 | + extra_headers=extra_headers, |
| 4560 | + extra_body=extra_body, |
| 4561 | + timeout=timeout, |
| 4562 | + ) |
| 4563 | + |
4368 | 4564 | async def convert_to_pdfa( |
4369 | 4565 | self, |
4370 | 4566 | file: PdfRestFile | Sequence[PdfRestFile], |
|
0 commit comments