|
73 | 73 | BmpPdfRestPayload, |
74 | 74 | GifPdfRestPayload, |
75 | 75 | JpegPdfRestPayload, |
| 76 | + PdfFlattenFormsPayload, |
76 | 77 | PdfInfoPayload, |
77 | 78 | PdfMergePayload, |
78 | 79 | PdfRedactionApplyPayload, |
79 | 80 | PdfRedactionPreviewPayload, |
80 | 81 | PdfRestRawFileResponse, |
81 | 82 | PdfSplitPayload, |
| 83 | + PdfToPdfxPayload, |
| 84 | + PdfToWordPayload, |
82 | 85 | PngPdfRestPayload, |
83 | 86 | TiffPdfRestPayload, |
84 | 87 | UploadURLs, |
|
90 | 93 | PdfPageSelection, |
91 | 94 | PdfRedactionInstruction, |
92 | 95 | PdfRGBColor, |
| 96 | + PdfXType, |
93 | 97 | ) |
94 | 98 |
|
95 | 99 | DEFAULT_BASE_URL = "https://api.pdfrest.com" |
@@ -2141,6 +2145,85 @@ def merge_pdfs( |
2141 | 2145 | timeout=timeout, |
2142 | 2146 | ) |
2143 | 2147 |
|
| 2148 | + def convert_to_word( |
| 2149 | + self, |
| 2150 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 2151 | + *, |
| 2152 | + output: str | None = None, |
| 2153 | + extra_query: Query | None = None, |
| 2154 | + extra_headers: AnyMapping | None = None, |
| 2155 | + extra_body: Body | None = None, |
| 2156 | + timeout: TimeoutTypes | None = None, |
| 2157 | + ) -> PdfRestFileBasedResponse: |
| 2158 | + """Convert a PDF to a Word document.""" |
| 2159 | + |
| 2160 | + payload: dict[str, Any] = {"files": file} |
| 2161 | + if output is not None: |
| 2162 | + payload["output"] = output |
| 2163 | + |
| 2164 | + return self._post_file_operation( |
| 2165 | + endpoint="/word", |
| 2166 | + payload=payload, |
| 2167 | + payload_model=PdfToWordPayload, |
| 2168 | + extra_query=extra_query, |
| 2169 | + extra_headers=extra_headers, |
| 2170 | + extra_body=extra_body, |
| 2171 | + timeout=timeout, |
| 2172 | + ) |
| 2173 | + |
| 2174 | + def flatten_pdf_forms( |
| 2175 | + self, |
| 2176 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 2177 | + *, |
| 2178 | + output: str | None = None, |
| 2179 | + extra_query: Query | None = None, |
| 2180 | + extra_headers: AnyMapping | None = None, |
| 2181 | + extra_body: Body | None = None, |
| 2182 | + timeout: TimeoutTypes | None = None, |
| 2183 | + ) -> PdfRestFileBasedResponse: |
| 2184 | + """Flatten form fields in a PDF so they are no longer editable.""" |
| 2185 | + |
| 2186 | + payload: dict[str, Any] = {"files": file} |
| 2187 | + if output is not None: |
| 2188 | + payload["output"] = output |
| 2189 | + |
| 2190 | + return self._post_file_operation( |
| 2191 | + endpoint="/flattened-forms-pdf", |
| 2192 | + payload=payload, |
| 2193 | + payload_model=PdfFlattenFormsPayload, |
| 2194 | + extra_query=extra_query, |
| 2195 | + extra_headers=extra_headers, |
| 2196 | + extra_body=extra_body, |
| 2197 | + timeout=timeout, |
| 2198 | + ) |
| 2199 | + |
| 2200 | + def convert_to_pdfx( |
| 2201 | + self, |
| 2202 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 2203 | + *, |
| 2204 | + output_type: PdfXType, |
| 2205 | + output: str | None = None, |
| 2206 | + extra_query: Query | None = None, |
| 2207 | + extra_headers: AnyMapping | None = None, |
| 2208 | + extra_body: Body | None = None, |
| 2209 | + timeout: TimeoutTypes | None = None, |
| 2210 | + ) -> PdfRestFileBasedResponse: |
| 2211 | + """Convert a PDF to a specified PDF/X version.""" |
| 2212 | + |
| 2213 | + payload: dict[str, Any] = {"files": file, "output_type": output_type} |
| 2214 | + if output is not None: |
| 2215 | + payload["output"] = output |
| 2216 | + |
| 2217 | + return self._post_file_operation( |
| 2218 | + endpoint="/pdfx", |
| 2219 | + payload=payload, |
| 2220 | + payload_model=PdfToPdfxPayload, |
| 2221 | + extra_query=extra_query, |
| 2222 | + extra_headers=extra_headers, |
| 2223 | + extra_body=extra_body, |
| 2224 | + timeout=timeout, |
| 2225 | + ) |
| 2226 | + |
2144 | 2227 | def convert_to_png( |
2145 | 2228 | self, |
2146 | 2229 | files: PdfRestFile | Sequence[PdfRestFile], |
@@ -2572,6 +2655,85 @@ async def merge_pdfs( |
2572 | 2655 | timeout=timeout, |
2573 | 2656 | ) |
2574 | 2657 |
|
| 2658 | + async def convert_to_word( |
| 2659 | + self, |
| 2660 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 2661 | + *, |
| 2662 | + output: str | None = None, |
| 2663 | + extra_query: Query | None = None, |
| 2664 | + extra_headers: AnyMapping | None = None, |
| 2665 | + extra_body: Body | None = None, |
| 2666 | + timeout: TimeoutTypes | None = None, |
| 2667 | + ) -> PdfRestFileBasedResponse: |
| 2668 | + """Asynchronously convert a PDF to a Word document.""" |
| 2669 | + |
| 2670 | + payload: dict[str, Any] = {"files": file} |
| 2671 | + if output is not None: |
| 2672 | + payload["output"] = output |
| 2673 | + |
| 2674 | + return await self._post_file_operation( |
| 2675 | + endpoint="/word", |
| 2676 | + payload=payload, |
| 2677 | + payload_model=PdfToWordPayload, |
| 2678 | + extra_query=extra_query, |
| 2679 | + extra_headers=extra_headers, |
| 2680 | + extra_body=extra_body, |
| 2681 | + timeout=timeout, |
| 2682 | + ) |
| 2683 | + |
| 2684 | + async def flatten_pdf_forms( |
| 2685 | + self, |
| 2686 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 2687 | + *, |
| 2688 | + output: str | None = None, |
| 2689 | + extra_query: Query | None = None, |
| 2690 | + extra_headers: AnyMapping | None = None, |
| 2691 | + extra_body: Body | None = None, |
| 2692 | + timeout: TimeoutTypes | None = None, |
| 2693 | + ) -> PdfRestFileBasedResponse: |
| 2694 | + """Asynchronously flatten form fields in a PDF.""" |
| 2695 | + |
| 2696 | + payload: dict[str, Any] = {"files": file} |
| 2697 | + if output is not None: |
| 2698 | + payload["output"] = output |
| 2699 | + |
| 2700 | + return await self._post_file_operation( |
| 2701 | + endpoint="/flattened-forms-pdf", |
| 2702 | + payload=payload, |
| 2703 | + payload_model=PdfFlattenFormsPayload, |
| 2704 | + extra_query=extra_query, |
| 2705 | + extra_headers=extra_headers, |
| 2706 | + extra_body=extra_body, |
| 2707 | + timeout=timeout, |
| 2708 | + ) |
| 2709 | + |
| 2710 | + async def convert_to_pdfx( |
| 2711 | + self, |
| 2712 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 2713 | + *, |
| 2714 | + output_type: PdfXType, |
| 2715 | + output: str | None = None, |
| 2716 | + extra_query: Query | None = None, |
| 2717 | + extra_headers: AnyMapping | None = None, |
| 2718 | + extra_body: Body | None = None, |
| 2719 | + timeout: TimeoutTypes | None = None, |
| 2720 | + ) -> PdfRestFileBasedResponse: |
| 2721 | + """Asynchronously convert a PDF to a specified PDF/X version.""" |
| 2722 | + |
| 2723 | + payload: dict[str, Any] = {"files": file, "output_type": output_type} |
| 2724 | + if output is not None: |
| 2725 | + payload["output"] = output |
| 2726 | + |
| 2727 | + return await self._post_file_operation( |
| 2728 | + endpoint="/pdfx", |
| 2729 | + payload=payload, |
| 2730 | + payload_model=PdfToPdfxPayload, |
| 2731 | + extra_query=extra_query, |
| 2732 | + extra_headers=extra_headers, |
| 2733 | + extra_body=extra_body, |
| 2734 | + timeout=timeout, |
| 2735 | + ) |
| 2736 | + |
2575 | 2737 | async def convert_to_png( |
2576 | 2738 | self, |
2577 | 2739 | files: PdfRestFile | Sequence[PdfRestFile], |
|
0 commit comments