44for supported document processing operations.
55"""
66
7- from typing import TYPE_CHECKING , Any , Dict , List , Optional , Protocol
7+ from typing import TYPE_CHECKING , Any , Protocol
88
99from nutrient_dws .file_handler import FileInput
1010
@@ -40,17 +40,17 @@ def _process_file(
4040 self ,
4141 tool : str ,
4242 input_file : FileInput ,
43- output_path : Optional [ str ] = None ,
43+ output_path : str | None = None ,
4444 ** options : Any ,
45- ) -> Optional [ bytes ] :
45+ ) -> bytes | None :
4646 """Process file method that will be provided by NutrientClient."""
4747 raise NotImplementedError ("This method is provided by NutrientClient" )
4848
4949 def convert_to_pdf (
5050 self ,
5151 input_file : FileInput ,
52- output_path : Optional [ str ] = None ,
53- ) -> Optional [ bytes ] :
52+ output_path : str | None = None ,
53+ ) -> bytes | None :
5454 """Convert a document to PDF.
5555
5656 Converts Office documents (DOCX, XLSX, PPTX) to PDF format.
@@ -76,8 +76,8 @@ def convert_to_pdf(
7676 return self .build (input_file ).execute (output_path ) # type: ignore[attr-defined,no-any-return]
7777
7878 def flatten_annotations (
79- self , input_file : FileInput , output_path : Optional [ str ] = None
80- ) -> Optional [ bytes ] :
79+ self , input_file : FileInput , output_path : str | None = None
80+ ) -> bytes | None :
8181 """Flatten annotations and form fields in a PDF.
8282
8383 Converts all annotations and form fields into static page content.
@@ -99,10 +99,10 @@ def flatten_annotations(
9999 def rotate_pages (
100100 self ,
101101 input_file : FileInput ,
102- output_path : Optional [ str ] = None ,
102+ output_path : str | None = None ,
103103 degrees : int = 0 ,
104- page_indexes : Optional [ List [ int ]] = None ,
105- ) -> Optional [ bytes ] :
104+ page_indexes : list [ int ] | None = None ,
105+ ) -> bytes | None :
106106 """Rotate pages in a PDF.
107107
108108 Rotate all pages or specific pages by the specified degrees.
@@ -129,9 +129,9 @@ def rotate_pages(
129129 def ocr_pdf (
130130 self ,
131131 input_file : FileInput ,
132- output_path : Optional [ str ] = None ,
132+ output_path : str | None = None ,
133133 language : str = "english" ,
134- ) -> Optional [ bytes ] :
134+ ) -> bytes | None :
135135 """Apply OCR to a PDF to make it searchable.
136136
137137 Performs optical character recognition on the PDF to extract text
@@ -156,14 +156,14 @@ def ocr_pdf(
156156 def watermark_pdf (
157157 self ,
158158 input_file : FileInput ,
159- output_path : Optional [ str ] = None ,
160- text : Optional [ str ] = None ,
161- image_url : Optional [ str ] = None ,
159+ output_path : str | None = None ,
160+ text : str | None = None ,
161+ image_url : str | None = None ,
162162 width : int = 200 ,
163163 height : int = 100 ,
164164 opacity : float = 1.0 ,
165165 position : str = "center" ,
166- ) -> Optional [ bytes ] :
166+ ) -> bytes | None :
167167 """Add a watermark to a PDF.
168168
169169 Adds a text or image watermark to all pages of the PDF.
@@ -209,8 +209,8 @@ def watermark_pdf(
209209 def apply_redactions (
210210 self ,
211211 input_file : FileInput ,
212- output_path : Optional [ str ] = None ,
213- ) -> Optional [ bytes ] :
212+ output_path : str | None = None ,
213+ ) -> bytes | None :
214214 """Apply redaction annotations to permanently remove content.
215215
216216 Applies any redaction annotations in the PDF to permanently remove
@@ -233,9 +233,9 @@ def apply_redactions(
233233 def split_pdf (
234234 self ,
235235 input_file : FileInput ,
236- page_ranges : Optional [ List [ Dict [ str , int ]]] = None ,
237- output_paths : Optional [ List [ str ]] = None ,
238- ) -> List [bytes ]:
236+ page_ranges : list [ dict [ str , int ]] | None = None ,
237+ output_paths : list [ str ] | None = None ,
238+ ) -> list [bytes ]:
239239 """Split a PDF into multiple documents by page ranges.
240240
241241 Splits a PDF into multiple files based on specified page ranges.
@@ -320,9 +320,9 @@ def split_pdf(
320320 def duplicate_pdf_pages (
321321 self ,
322322 input_file : FileInput ,
323- page_indexes : List [int ],
324- output_path : Optional [ str ] = None ,
325- ) -> Optional [ bytes ] :
323+ page_indexes : list [int ],
324+ output_path : str | None = None ,
325+ ) -> bytes | None :
326326 """Duplicate specific pages within a PDF document.
327327
328328 Creates a new PDF containing the specified pages in the order provided.
@@ -404,9 +404,9 @@ def duplicate_pdf_pages(
404404 def delete_pdf_pages (
405405 self ,
406406 input_file : FileInput ,
407- page_indexes : List [int ],
408- output_path : Optional [ str ] = None ,
409- ) -> Optional [ bytes ] :
407+ page_indexes : list [int ],
408+ output_path : str | None = None ,
409+ ) -> bytes | None :
410410 """Delete specific pages from a PDF document.
411411
412412 Creates a new PDF with the specified pages removed. The API approach
@@ -544,9 +544,9 @@ def delete_pdf_pages(
544544
545545 def merge_pdfs (
546546 self ,
547- input_files : List [FileInput ],
548- output_path : Optional [ str ] = None ,
549- ) -> Optional [ bytes ] :
547+ input_files : list [FileInput ],
548+ output_path : str | None = None ,
549+ ) -> bytes | None :
550550 """Merge multiple PDF files into one.
551551
552552 Combines multiple files into a single PDF in the order provided.
0 commit comments