|
75 | 75 | BasePdfRestGraphicPayload, |
76 | 76 | BmpPdfRestPayload, |
77 | 77 | ConvertToMarkdownPayload, |
| 78 | + ConvertToPdfPayload, |
| 79 | + ConvertUrlsToPdfPayload, |
78 | 80 | DeletePayload, |
79 | 81 | ExtractImagesPayload, |
80 | 82 | ExtractTextPayload, |
|
113 | 115 | FlattenQuality, |
114 | 116 | GifColorModel, |
115 | 117 | GraphicSmoothing, |
| 118 | + HtmlPageOrientation, |
| 119 | + HtmlPageSize, |
| 120 | + HtmlWebLayout, |
116 | 121 | JpegColorModel, |
117 | 122 | OcrLanguage, |
118 | 123 | PdfAType, |
| 124 | + PdfConversionCompression, |
| 125 | + PdfConversionDownsample, |
| 126 | + PdfConversionLocale, |
119 | 127 | PdfInfoQuery, |
120 | 128 | PdfMergeInput, |
121 | 129 | PdfPageSelection, |
@@ -2822,6 +2830,100 @@ def rasterize_pdf( |
2822 | 2830 | timeout=timeout, |
2823 | 2831 | ) |
2824 | 2832 |
|
| 2833 | + def convert_to_pdf( |
| 2834 | + self, |
| 2835 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 2836 | + *, |
| 2837 | + output: str | None = None, |
| 2838 | + compression: PdfConversionCompression | None = None, |
| 2839 | + downsample: PdfConversionDownsample | None = None, |
| 2840 | + tagged_pdf: bool | None = None, |
| 2841 | + locale: PdfConversionLocale | None = None, |
| 2842 | + page_size: HtmlPageSize | None = None, |
| 2843 | + page_margin: str | None = None, |
| 2844 | + page_orientation: HtmlPageOrientation | None = None, |
| 2845 | + web_layout: HtmlWebLayout | None = None, |
| 2846 | + extra_query: Query | None = None, |
| 2847 | + extra_headers: AnyMapping | None = None, |
| 2848 | + extra_body: Body | None = None, |
| 2849 | + timeout: TimeoutTypes | None = None, |
| 2850 | + ) -> PdfRestFileBasedResponse: |
| 2851 | + """Convert a supported file type to PDF.""" |
| 2852 | + |
| 2853 | + payload: dict[str, Any] = {"files": file} |
| 2854 | + if output is not None: |
| 2855 | + payload["output"] = output |
| 2856 | + if compression is not None: |
| 2857 | + payload["compression"] = compression |
| 2858 | + if downsample is not None: |
| 2859 | + payload["downsample"] = downsample |
| 2860 | + if tagged_pdf is not None: |
| 2861 | + payload["tagged_pdf"] = tagged_pdf |
| 2862 | + if locale is not None: |
| 2863 | + payload["locale"] = locale |
| 2864 | + if page_size is not None: |
| 2865 | + payload["page_size"] = page_size |
| 2866 | + if page_margin is not None: |
| 2867 | + payload["page_margin"] = page_margin |
| 2868 | + if page_orientation is not None: |
| 2869 | + payload["page_orientation"] = page_orientation |
| 2870 | + if web_layout is not None: |
| 2871 | + payload["web_layout"] = web_layout |
| 2872 | + |
| 2873 | + return self._post_file_operation( |
| 2874 | + endpoint="/pdf", |
| 2875 | + payload=payload, |
| 2876 | + payload_model=ConvertToPdfPayload, |
| 2877 | + extra_query=extra_query, |
| 2878 | + extra_headers=extra_headers, |
| 2879 | + extra_body=extra_body, |
| 2880 | + timeout=timeout, |
| 2881 | + ) |
| 2882 | + |
| 2883 | + def convert_urls_to_pdf( |
| 2884 | + self, |
| 2885 | + urls: UrlInput, |
| 2886 | + *, |
| 2887 | + output: str | None = None, |
| 2888 | + compression: PdfConversionCompression | None = None, |
| 2889 | + downsample: PdfConversionDownsample | None = None, |
| 2890 | + page_size: HtmlPageSize | None = None, |
| 2891 | + page_margin: str | None = None, |
| 2892 | + page_orientation: HtmlPageOrientation | None = None, |
| 2893 | + web_layout: HtmlWebLayout | None = None, |
| 2894 | + extra_query: Query | None = None, |
| 2895 | + extra_headers: AnyMapping | None = None, |
| 2896 | + extra_body: Body | None = None, |
| 2897 | + timeout: TimeoutTypes | None = None, |
| 2898 | + ) -> PdfRestFileBasedResponse: |
| 2899 | + """Convert HTML content from one or more URLs to PDF.""" |
| 2900 | + |
| 2901 | + payload: dict[str, Any] = {"url": urls} |
| 2902 | + if output is not None: |
| 2903 | + payload["output"] = output |
| 2904 | + if compression is not None: |
| 2905 | + payload["compression"] = compression |
| 2906 | + if downsample is not None: |
| 2907 | + payload["downsample"] = downsample |
| 2908 | + if page_size is not None: |
| 2909 | + payload["page_size"] = page_size |
| 2910 | + if page_margin is not None: |
| 2911 | + payload["page_margin"] = page_margin |
| 2912 | + if page_orientation is not None: |
| 2913 | + payload["page_orientation"] = page_orientation |
| 2914 | + if web_layout is not None: |
| 2915 | + payload["web_layout"] = web_layout |
| 2916 | + |
| 2917 | + return self._post_file_operation( |
| 2918 | + endpoint="/pdf", |
| 2919 | + payload=payload, |
| 2920 | + payload_model=ConvertUrlsToPdfPayload, |
| 2921 | + extra_query=extra_query, |
| 2922 | + extra_headers=extra_headers, |
| 2923 | + extra_body=extra_body, |
| 2924 | + timeout=timeout, |
| 2925 | + ) |
| 2926 | + |
2825 | 2927 | def convert_to_pdfa( |
2826 | 2928 | self, |
2827 | 2929 | file: PdfRestFile | Sequence[PdfRestFile], |
@@ -3864,6 +3966,100 @@ async def rasterize_pdf( |
3864 | 3966 | timeout=timeout, |
3865 | 3967 | ) |
3866 | 3968 |
|
| 3969 | + async def convert_to_pdf( |
| 3970 | + self, |
| 3971 | + file: PdfRestFile | Sequence[PdfRestFile], |
| 3972 | + *, |
| 3973 | + output: str | None = None, |
| 3974 | + compression: PdfConversionCompression | None = None, |
| 3975 | + downsample: PdfConversionDownsample | None = None, |
| 3976 | + tagged_pdf: bool | None = None, |
| 3977 | + locale: PdfConversionLocale | None = None, |
| 3978 | + page_size: HtmlPageSize | None = None, |
| 3979 | + page_margin: str | None = None, |
| 3980 | + page_orientation: HtmlPageOrientation | None = None, |
| 3981 | + web_layout: HtmlWebLayout | None = None, |
| 3982 | + extra_query: Query | None = None, |
| 3983 | + extra_headers: AnyMapping | None = None, |
| 3984 | + extra_body: Body | None = None, |
| 3985 | + timeout: TimeoutTypes | None = None, |
| 3986 | + ) -> PdfRestFileBasedResponse: |
| 3987 | + """Asynchronously convert a supported file type to PDF.""" |
| 3988 | + |
| 3989 | + payload: dict[str, Any] = {"files": file} |
| 3990 | + if output is not None: |
| 3991 | + payload["output"] = output |
| 3992 | + if compression is not None: |
| 3993 | + payload["compression"] = compression |
| 3994 | + if downsample is not None: |
| 3995 | + payload["downsample"] = downsample |
| 3996 | + if tagged_pdf is not None: |
| 3997 | + payload["tagged_pdf"] = tagged_pdf |
| 3998 | + if locale is not None: |
| 3999 | + payload["locale"] = locale |
| 4000 | + if page_size is not None: |
| 4001 | + payload["page_size"] = page_size |
| 4002 | + if page_margin is not None: |
| 4003 | + payload["page_margin"] = page_margin |
| 4004 | + if page_orientation is not None: |
| 4005 | + payload["page_orientation"] = page_orientation |
| 4006 | + if web_layout is not None: |
| 4007 | + payload["web_layout"] = web_layout |
| 4008 | + |
| 4009 | + return await self._post_file_operation( |
| 4010 | + endpoint="/pdf", |
| 4011 | + payload=payload, |
| 4012 | + payload_model=ConvertToPdfPayload, |
| 4013 | + extra_query=extra_query, |
| 4014 | + extra_headers=extra_headers, |
| 4015 | + extra_body=extra_body, |
| 4016 | + timeout=timeout, |
| 4017 | + ) |
| 4018 | + |
| 4019 | + async def convert_urls_to_pdf( |
| 4020 | + self, |
| 4021 | + urls: UrlInput, |
| 4022 | + *, |
| 4023 | + output: str | None = None, |
| 4024 | + compression: PdfConversionCompression | None = None, |
| 4025 | + downsample: PdfConversionDownsample | None = None, |
| 4026 | + page_size: HtmlPageSize | None = None, |
| 4027 | + page_margin: str | None = None, |
| 4028 | + page_orientation: HtmlPageOrientation | None = None, |
| 4029 | + web_layout: HtmlWebLayout | None = None, |
| 4030 | + extra_query: Query | None = None, |
| 4031 | + extra_headers: AnyMapping | None = None, |
| 4032 | + extra_body: Body | None = None, |
| 4033 | + timeout: TimeoutTypes | None = None, |
| 4034 | + ) -> PdfRestFileBasedResponse: |
| 4035 | + """Asynchronously convert HTML content from one or more URLs to PDF.""" |
| 4036 | + |
| 4037 | + payload: dict[str, Any] = {"url": urls} |
| 4038 | + if output is not None: |
| 4039 | + payload["output"] = output |
| 4040 | + if compression is not None: |
| 4041 | + payload["compression"] = compression |
| 4042 | + if downsample is not None: |
| 4043 | + payload["downsample"] = downsample |
| 4044 | + if page_size is not None: |
| 4045 | + payload["page_size"] = page_size |
| 4046 | + if page_margin is not None: |
| 4047 | + payload["page_margin"] = page_margin |
| 4048 | + if page_orientation is not None: |
| 4049 | + payload["page_orientation"] = page_orientation |
| 4050 | + if web_layout is not None: |
| 4051 | + payload["web_layout"] = web_layout |
| 4052 | + |
| 4053 | + return await self._post_file_operation( |
| 4054 | + endpoint="/pdf", |
| 4055 | + payload=payload, |
| 4056 | + payload_model=ConvertUrlsToPdfPayload, |
| 4057 | + extra_query=extra_query, |
| 4058 | + extra_headers=extra_headers, |
| 4059 | + extra_body=extra_body, |
| 4060 | + timeout=timeout, |
| 4061 | + ) |
| 4062 | + |
3867 | 4063 | async def convert_to_pdfa( |
3868 | 4064 | self, |
3869 | 4065 | file: PdfRestFile | Sequence[PdfRestFile], |
|
0 commit comments