API
Barcode API  Currency API  Image Recognition & Processing API  Document & Conversion API  OCR API  Security API  Validate API  Video API  Virus Scan API  NLP API 

Step 1 - Install the Client SDK






Step 2 - Get Started with Example Code

/convert/archive/zip/create
Compress files to create a new zip archive
/convert/archive/zip/create/advanced
Compress files and folders to create a new zip archive with advanced options
/convert/archive/zip/create/encrypted
Compress files to create a new, encrypted and password-protected zip archive
/convert/archive/zip/decrypt
Decrypt and remove password protection on a zip file
/convert/archive/zip/encrypt/advanced
Encrypt and password protect a zip file
/convert/archive/zip/extract
Extract, decompress files and folders from a zip archive
/convert/autodetect/get-icon
Get PNG icon file for the file extension
/convert/autodetect/get-icon/advanced
Get PNG icon byte array for the file extension
/convert/autodetect/get-info
Get document type information
/convert/autodetect/to/jpg
Convert Document to JPG/JPEG image array
/convert/autodetect/to/pdf
Convert Document to PDF
/convert/autodetect/to/png
Convert Document to PNG array
/convert/autodetect/to/thumbnail
Convert File to Thumbnail Image
/convert/autodetect/to/thumbnail/advanced
Convert File to Thumbnail Image Object
/convert/autodetect/to/txt
Convert Document to Text (txt)
/convert/compare/docx
Compare Two Word DOCX
/convert/csv/multi/to/xlsx
Convert Multiple CSV Files into a Single XLSX Spreadsheet
/convert/csv/to/html
Convert CSV to HTML document
/convert/csv/to/json
Convert CSV to JSON conversion
/convert/csv/to/pdf
Convert CSV to PDF document
/convert/csv/to/xlsx
Convert CSV to Excel XLSX Spreadsheet
/convert/csv/to/xml
Convert CSV to XML conversion
/convert/doc/to/docx
Convert Word DOC (97-03) Document to DOCX
/convert/doc/to/pdf
Convert Word DOC (97-03) Document to PDF
/convert/doc/to/txt
Convert Word DOC (97-03) Document to Text (txt)
/convert/docx/to/doc
Convert Word DOCX Document to Legacy Word DOC (97-03)
/convert/docx/to/html
Convert Word DOCX Document to HTML Document
/convert/docx/to/jpg
Convert Word DOCX Document to JPG/JPEG image array
/convert/docx/to/pdf
Convert Word DOCX Document to PDF
/convert/docx/to/png
Convert Word DOCX Document to PNG image array
/convert/docx/to/rtf
Convert Word DOCX Document to RTF
/convert/docx/to/txt
Convert Word DOCX Document to Text (txt)
/convert/edit/begin-editing
Begin editing a document
/convert/edit/docx/comments/remove-all
Remove all comments from a Word DOCX document
/convert/edit/docx/create/blank
Create a blank Word DOCX document
/convert/edit/docx/delete-pages
Delete, remove pages from a Word DOCX document
/convert/edit/docx/delete-table-row
Deletes a table row in an existing table in a Word DOCX document
/convert/edit/docx/delete-table-row/range
Deletes a range of multiple table rows in an existing table in a Word DOCX document
/convert/edit/docx/find/paragraph
Find matching paragraphs in a Word DOCX document
/convert/edit/docx/get-body
Get body from a Word DOCX document
/convert/edit/docx/get-comments/flat-list
Get comments from a Word DOCX document as a flat list
/convert/edit/docx/get-comments/hierarchical
Get comments from a Word DOCX document hierarchically
/convert/edit/docx/get-headers-and-footers
Get content of a footer from a Word DOCX document
/convert/edit/docx/get-images
Get images from a Word DOCX document
/convert/edit/docx/get-macros
Get macro information from a Word DOCX/DOCM document
/convert/edit/docx/get-metadata
Get all metadata properties in Word DOCX document
/convert/edit/docx/get-pages
Get pages and content from a Word DOCX document
/convert/edit/docx/get-sections
Get sections from a Word DOCX document
/convert/edit/docx/get-styles
Get styles from a Word DOCX document
/convert/edit/docx/get-table/by-index
Get a specific table by index in a Word DOCX document
/convert/edit/docx/get-table-row
Gets the contents of an existing table row in an existing table in a Word DOCX document
/convert/edit/docx/get-tables
Get all tables in Word DOCX document
/convert/edit/docx/insert-comment/on/paragraph
Insert a new comment into a Word DOCX document attached to a paragraph
/convert/edit/docx/insert-image
Insert image into a Word DOCX document
/convert/edit/docx/insert-paragraph
Insert a new paragraph into a Word DOCX document
/convert/edit/docx/insert-table
Insert a new table into a Word DOCX document
/convert/edit/docx/insert-table-row
Insert a new row into an existing table in a Word DOCX document
/convert/edit/docx/remove-headers-and-footers
Remove headers and footers from Word DOCX document
/convert/edit/docx/remove-object
Delete any object in a Word DOCX document
/convert/edit/docx/replace/paragraph
Replace matching paragraphs in a Word DOCX document
/convert/edit/docx/replace-all
Replace string in Word DOCX document
/convert/edit/docx/replace-all/multi
Replace multiple strings in Word DOCX document
/convert/edit/docx/set-footer
Set the footer in a Word DOCX document
/convert/edit/docx/set-footer/add-page-number
Add page number to footer in a Word DOCX document
/convert/edit/docx/set-header
Set the header in a Word DOCX document
/convert/edit/docx/set-metadata/custom-property
Set custom property metadata properties in Word DOCX document
/convert/edit/docx/track-changes/accept-all
Accept all tracked changes, revisions in a Word DOCX document
/convert/edit/docx/track-changes/disable
Disable track changes, revisions in a Word DOCX document
/convert/edit/docx/track-changes/enable
Enable track changes, revisions in a Word DOCX document
/convert/edit/docx/update-table-cell
Update, set contents of a table cell in an existing table in a Word DOCX document
/convert/edit/docx/update-table-row
Update, set contents of a table row in an existing table in a Word DOCX document
/convert/edit/finish-editing
Finish editing document, and download result from document editing
/convert/edit/html/append/heading
Append a Heading to an HTML Document
/convert/edit/html/append/image/from-url
Append an Image to an HTML Document from a URL
/convert/edit/html/append/image/inline
Append a Base64 Inline Image to an HTML Document
/convert/edit/html/append/paragraph
Append a Paragraph to an HTML Document
/convert/edit/html/create/blank
Create a Blank HTML Document
/convert/edit/html/extract/links
Extract resolved link URLs from HTML File
/convert/edit/pdf/annotations/add-item
Add one or more PDF annotations, comments in the PDF document
/convert/edit/pdf/annotations/list
Get PDF annotations, including comments in the document
/convert/edit/pdf/annotations/remove-all
Remove all PDF annotations, including comments in the document
/convert/edit/pdf/annotations/remove-item
Remove a specific PDF annotation, comment in the document
/convert/edit/pdf/decrypt
Decrypt and password-protect a PDF
/convert/edit/pdf/encrypt
Encrypt and password-protect a PDF
/convert/edit/pdf/encrypt/set-permissions
Encrypt, password-protect and set restricted permissions on a PDF
/convert/edit/pdf/form/get-fields
Gets PDF Form fields and values
/convert/edit/pdf/form/set-fields
Sets ands fills PDF Form field values
/convert/edit/pdf/get-metadata
Get PDF document metadata
/convert/edit/pdf/optimize/linearize
Linearize and optimize a PDF for streaming download
/convert/edit/pdf/optimize/pdf-a
Convert a PDF file to PDF/A
/convert/edit/pdf/optimize/reduce-file-size
Reduce the file size and optimize a PDF
/convert/edit/pdf/pages/delete
Remove, delete pages from a PDF document
/convert/edit/pdf/pages/get-text
Get text in a PDF document by page
/convert/edit/pdf/pages/insert
Insert, copy pages from one PDF document into another
/convert/edit/pdf/pages/rotate/all
Rotate all pages in a PDF document
/convert/edit/pdf/pages/rotate/page-range
Rotate a range, subset of pages in a PDF document
/convert/edit/pdf/rasterize
Rasterize a PDF to an image-based PDF
/convert/edit/pdf/resize
Change PDF Document's Paper Size
/convert/edit/pdf/set-metadata
Sets PDF document metadata
/convert/edit/pdf/watermark/text
Add a text watermark to a PDF
/convert/edit/pptx/delete-slides
Delete, remove slides from a PowerPoint PPTX presentation document
/convert/edit/pptx/get-macros
Get macro information from a PowerPoint PPTX/PPTM presentation document
/convert/edit/pptx/replace-all
Replace string in PowerPoint PPTX presentation
/convert/edit/text/encoding/base64/decode
Base 64 decode, convert base 64 string to binary content
/convert/edit/text/encoding/base64/detect
Detect, check if text string is base 64 encoded
/convert/edit/text/encoding/base64/encode
Base 64 encode, convert binary or file data to a text string
/convert/edit/text/encoding/detect
Detect text encoding of file
/convert/edit/text/find/regex
Find a regular expression regex in text input
/convert/edit/text/find/string
Find a string in text input
/convert/edit/text/line-endings/change
Set, change line endings of a text file
/convert/edit/text/line-endings/detect
Detect line endings of a text file
/convert/edit/text/remove/html
Remove HTML from text string
/convert/edit/text/remove/whitespace/all
Remove whitespace from text string
/convert/edit/text/remove/whitespace/trim
Trim leading and trailing whitespace from text string
/convert/edit/text/replace/regex
Replace a string in text with a regex regular expression string
/convert/edit/text/replace/string
Replace a string in text with another string value
/convert/edit/xlsx/append-row
Append row to a Excel XLSX spreadsheet, worksheet
/convert/edit/xlsx/clear-cell/by-index
Clear cell contents in an Excel XLSX spreadsheet, worksheet by index
/convert/edit/xlsx/clear-row
Clear row from a Excel XLSX spreadsheet, worksheet
/convert/edit/xlsx/configuration/disable-shared-workbook
Disable Shared Workbook (legacy) in Excel XLSX spreadsheet
/convert/edit/xlsx/configuration/enable-shared-workbook
Enable Shared Workbook (legacy) in Excel XLSX spreadsheet
/convert/edit/xlsx/create/blank
Create a blank Excel XLSX spreadsheet
/convert/edit/xlsx/create/from/data
Create a new Excel XLSX spreadsheet from column and row data
/convert/edit/xlsx/delete-worksheet
Delete, remove worksheet from an Excel XLSX spreadsheet document
/convert/edit/xlsx/get-cell/by-identifier
Get cell from an Excel XLSX spreadsheet, worksheet by cell identifier
/convert/edit/xlsx/get-cell/by-index
Get cell from an Excel XLSX spreadsheet, worksheet by index
/convert/edit/xlsx/get-columns
Get columns from a Excel XLSX spreadsheet, worksheet
/convert/edit/xlsx/get-images
Get images from a Excel XLSX spreadsheet, worksheet
/convert/edit/xlsx/get-macros
Get macro information from a Excel XLSX/XLSM spreadsheet, worksheet
/convert/edit/xlsx/get-rows-and-cells
Get rows and cells from a Excel XLSX spreadsheet, worksheet
/convert/edit/xlsx/get-specific-row
Get a specific row from a Excel XLSX spreadsheet, worksheet by path
/convert/edit/xlsx/get-styles
Get styles from a Excel XLSX spreadsheet, worksheet
/convert/edit/xlsx/get-worksheets
Get worksheets from a Excel XLSX spreadsheet
/convert/edit/xlsx/insert-worksheet
Insert a new worksheet into an Excel XLSX spreadsheet
/convert/edit/xlsx/rename-worksheet
Rename a specific worksheet in a Excel XLSX spreadsheet
/convert/edit/xlsx/set-cell/by-identifier
Set, update cell contents in an Excel XLSX spreadsheet, worksheet by cell identifier
/convert/edit/xlsx/set-cell/by-index
Set, update cell contents in an Excel XLSX spreadsheet, worksheet by index
/convert/eml/to/html
Convert Email EML file to HTML string
/convert/eml/to/jpg
Convert Email EML file to JPG/JPEG image array
/convert/eml/to/pdf
Convert Email EML file to PDF document
/convert/eml/to/png
Convert Email EML file to PNG image array
/convert/html/to/docx
Convert HTML to Word DOCX Document
/convert/html/to/pdf
Convert HTML document file to PDF Document
/convert/html/to/png
Convert HTML document file to PNG image array
/convert/html/to/txt
HTML Document file to Text (txt)
/convert/image/{format1}/to/{format2}
Image format conversion
/convert/image/get-info
Get information about an image
/convert/image/set-dpi/{dpi}
Change image DPI
/convert/image-multipage/{format1}/to/{format2}
Multi-page image format conversion
/convert/json/to/xml
Convert JSON to XML conversion
/convert/key/to/jpg
Convert Keynote Presentation (KEY) to JPG/JPEG image array
/convert/key/to/pdf
Convert Keynote Presentation (KEY) to PDF
/convert/key/to/png
Convert Keynote Presentation (KEY) to PNG image array
/convert/key/to/pptx
Convert Keynote Presentation (KEY) to PPTX
/convert/merge/docx
Merge Two Word DOCX Together
/convert/merge/docx/multi
Merge Multple Word DOCX Together
/convert/merge/html
Merge Two HTML (HTM) Files Together
/convert/merge/html/multi
Merge Multple HTML (HTM) Files Together
/convert/merge/pdf
Merge Two PDF Files Together
/convert/merge/pdf/multi
Merge Multple PDF Files Together
/convert/merge/png/vertical
Merge Two PNG Files Together
/convert/merge/png/vertical/multi
Merge Multple PNG Files Together
/convert/merge/pptx
Merge Two PowerPoint PPTX Together
/convert/merge/pptx/multi
Merge Multple PowerPoint PPTX Together
/convert/merge/txt
Merge Two Text (TXT) Files Together
/convert/merge/txt/multi
Merge Multple Text (TXT) Files Together
/convert/merge/xlsx
Merge Two Excel XLSX Together
/convert/merge/xlsx/multi
Merge Multple Excel XLSX Together
/convert/msg/to/html
Convert Email MSG file to HTML string
/convert/msg/to/jpg
Convert Email MSG file to JPG/JPEG image array
/convert/msg/to/pdf
Convert Email MSG file to PDF document
/convert/msg/to/png
Convert Email MSG file to PNG image array
/convert/odp/to/jpg
Convert ODP Presentation to JPG/JPEG image array
/convert/odp/to/pdf
Convert ODP Presentation to PDF
/convert/odp/to/png
Convert ODP Presentation to PNG image array
/convert/odp/to/pptx
Convert ODP Presentation to PPTX
/convert/ods/to/jpg
Convert ODS Spreadsheet to JPG/JPEG image array
/convert/ods/to/pdf
Convert ODS Spreadsheet to PDF
/convert/ods/to/png
Convert ODS Spreadsheet to PNG image array
/convert/ods/to/xlsx
Convert ODS Spreadsheet to XLSX
/convert/odt/to/docx
Convert ODT Text File to Word DOCX
/convert/odt/to/jpg
Convert ODT Text File to JPG/JPEG image array
/convert/odt/to/pdf
Convert ODT Text File to PDF
/convert/odt/to/png
Convert ODT Text File to PNG image array
/convert/pdf/to/docx
Convert PDF to Word DOCX Document
/convert/pdf/to/docx/rasterize
Convert PDF to Word DOCX Document based on rasterized version of the PDF
/convert/pdf/to/jpg
Convert PDF to JPG/JPEG image array
/convert/pdf/to/png
Convert PDF to PNG Image Array
/convert/pdf/to/png/merge-single
Convert PDF to Single PNG image
/convert/pdf/to/pptx
Convert PDF to PowerPoint PPTX Presentation
/convert/pdf/to/txt
Convert PDF Document to Text (txt)
/convert/png/to/pdf
Convert PNG Array to PDF
/convert/ppt/to/pdf
Convert PowerPoint PPT (97-03) Presentation to PDF
/convert/ppt/to/pptx
Convert PowerPoint PPT (97-03) Presentation to PPTX
/convert/pptx/to/pdf
Convert PowerPoint PPTX Presentation to PDF
/convert/pptx/to/png
Convert PowerPoint PPTX to PNG image array
/convert/pptx/to/ppt
Convert PowerPoint PPTX presentation to Legacy PowerPoint PPT (97-03)
/convert/pptx/to/txt
Convert PowerPoint PPTX Presentation to Text (txt)
/convert/rtf/to/docx
Convert Rich Text Format RTF to DOCX Document
/convert/rtf/to/html
Convert Rich Text Format RTF to HTML Document
/convert/rtf/to/jpg
Convert Rich Text Format RTF to JPG/JPEG image array
/convert/rtf/to/pdf
Convert Rich Text Format RTF to PDF
/convert/rtf/to/png
Convert Rich Text Format RTF to PNG image array
/convert/split/docx
Split a single Word Document DOCX into Separate Documents by Page
/convert/split/pdf
Split a PDF file into separate PDF files, one per page
/convert/split/pptx
Split a single PowerPoint Presentation PPTX into Separate Slides
/convert/split/txt/by-line
Split a single Text file (txt) into lines
/convert/split/txt/by-string
Split a single Text file (txt) by a string delimiter
/convert/split/xlsx
Split a single Excel XLSX into Separate Worksheets
/convert/template/docx/apply
Apply Word DOCX template
/convert/template/html/apply
Apply HTML template
/convert/transform/docx/replace-all
Replace string in Word DOCX document
/convert/transform/pptx/replace-all
Replace string in PowerPoint PPTX presentation
/convert/validate/autodetect
Autodetect content type and validate
/convert/validate/csv
Validate a CSV file document (CSV)
/convert/validate/docx
Validate a Word document (DOCX)
/convert/validate/eml
Validate if an EML file is executable
/convert/validate/executable
Validate if a file is executable
/convert/validate/gzip
Validate a GZip Archive file (gzip or gz)
/convert/validate/html
Validate an HTML file
/convert/validate/html/ssrf-threat-check
Validate an HTML file and checks for SSRF threats
/convert/validate/image
Validate an Image File
/convert/validate/jpg
Validate a JPG File
/convert/validate/json
Validate a JSON file
/convert/validate/msg
Validate if an MSG file is executable
/convert/validate/pdf
Validate a PDF document file
/convert/validate/png
Validate a PNG File
/convert/validate/pptx
Validate a PowerPoint presentation (PPTX)
/convert/validate/rar
Validate a RAR Archive file (RAR)
/convert/validate/tar
Validate a TAR Tarball Archive file (TAR)
/convert/validate/txt
Validate an TXT file
/convert/validate/xlsx
Validate a Excel document (XLSX)
/convert/validate/xml
Validate an XML file
/convert/validate/zip
Validate a Zip Archive file (zip)
/convert/viewer/create/web/simple
Create a web-based viewer
/convert/web/html/to/pdf
Convert HTML string to PDF
/convert/web/html/to/png
Convert HTML string to PNG screenshot
/convert/web/html/to/txt
Convert HTML string to text (txt)
/convert/web/md/to/html
Convert Markdown to HTML
/convert/web/url/to/pdf
Convert a URL to PDF
/convert/web/url/to/screenshot
Take screenshot of URL
/convert/web/url/to/txt
Convert website URL page to text (txt)
/convert/xls/to/csv
Convert Excel XLS (97-03) Spreadsheet to CSV
/convert/xls/to/json
Convert Excel (97-2003) XLS to JSON conversion
/convert/xls/to/pdf
Convert Excel XLS (97-03) Spreadsheet to PDF
/convert/xls/to/xlsx
Convert Excel XLS (97-03) Spreadsheet to XLSX
/convert/xlsx/to/csv
Convert Excel XLSX Spreadsheet to CSV, Single Worksheet
/convert/xlsx/to/csv/multi
Convert Excel XLSX Spreadsheet to CSV, Multiple Worksheets
/convert/xlsx/to/html
Convert Excel XLSX Spreadsheet to HTML Document
/convert/xlsx/to/json
Convert Excel XLSX to JSON conversion
/convert/xlsx/to/pdf
Convert Excel XLSX Spreadsheet to PDF
/convert/xlsx/to/png
Convert Excel XLSX spreadsheet to PNG image array
/convert/xlsx/to/txt
Convert Excel XLSX Spreadsheet to Text (txt)
/convert/xlsx/to/xls
Convert Excel XLSX Spreadsheet to Legacy Excel XLS (97-03)
/convert/xlsx/to/xml
Convert Excel XLSX to XML conversion
/convert/xml/edit/xpath/add-attribute
Adds an attribute to all XML nodes matching XPath expression
/convert/xml/edit/xpath/add-child
Adds an XML node as a child to XML nodes matching XPath expression
/convert/xml/edit/xpath/remove
Remove, delete XML nodes and items matching XPath expression
/convert/xml/edit/xpath/remove-all-children
Removes, deletes all children of nodes matching XPath expression, but does not remove the nodes
/convert/xml/edit/xpath/replace
Replaces XML nodes matching XPath expression with new node
/convert/xml/edit/xpath/set-value
Sets the value contents of XML nodes matching XPath expression
/convert/xml/query/xquery
Query an XML file using XQuery query, get results
/convert/xml/query/xquery/multi
Query multiple XML files using XQuery query, get results
/convert/xml/select/xpath
Filter, select XML nodes using XPath expression, get results
/convert/xml/to/json
Convert XML to JSON conversion
/convert/xml/transform/xslt/to/xml
Transform XML document file with XSLT into a new XML document
/virus/scan/cloud-storage/aws-s3/single
Scan an AWS S3 file for viruses
/virus/scan/cloud-storage/aws-s3/single/advanced
Advanced Scan an AWS S3 file for viruses
/virus/scan/cloud-storage/azure-blob/single
Scan an Azure Blob for viruses
/virus/scan/cloud-storage/azure-blob/single/advanced
Advanced Scan an Azure Blob for viruses
/virus/scan/cloud-storage/gcp-storage/single
Scan an Google Cloud Platform (GCP) Storage file for viruses
/virus/scan/cloud-storage/gcp-storage/single/advanced
Advanced Scan an Google Cloud Platform (GCP) Storage file for viruses
/virus/scan/cloud-storage/sharepoint-online/site/advanced
Advanced Virus Scan a file in a SharePoint Online Site Drive
/virus/scan/cloud-storage/sharepoint-online/site/single
Virus Scan a file in a SharePoint Online Site Drive
/virus/scan/file
Scan a file for viruses
/virus/scan/file/advanced
Advanced Scan a file for viruses
/virus/scan/website
Scan a website for malicious content and threats

Split a single Excel XLSX into Separate Worksheets

Split an Excel XLSX Spreadsheet, comprised of multiple Worksheets (or Tabs) into separate Excel XLSX spreadsheet files, with each containing exactly one Worksheet.

import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

var semaphore = DispatchSemaphore (value: 0)

let parameters = [
     [
          "key": "inputFile",
          "src": "/path/to/file",
          "type": "file"
     ]] as [[String : Any]]

let boundary = "Boundary-\(UUID().uuidString)"
var body = ""
var error: Error? = nil
for param in parameters {
     if param["disabled"] == nil {
          let paramName = param["key"]!
          body += "--\(boundary)\r\n"
          body += "Content-Disposition:form-data; name=\"\(paramName)\""
          if param["contentType"] != nil {
               body += "\r\nContent-Type: \(param["contentType"] as! String)"
          }
          let paramType = param["type"] as! String
          if paramType == "text" {
               let paramValue = param["value"] as! String
               body += "\r\n\r\n\(paramValue)\r\n"
          } else {
               let paramSrc = param["src"] as! String
               let fileData = try NSData(contentsOfFile:paramSrc, options:[]) as Data
               let fileContent = String(data: fileData, encoding: .utf8)!
               body += "; filename=\"\(paramSrc)\"\r\n"
                 + "Content-Type: \"content-type header\"\r\n\r\n\(fileContent)\r\n"
          }
     }
}
body += "--\(boundary)--\r\n";
let postData = body.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://api.cloudmersive.com/convert/split/xlsx")!,timeoutInterval: Double.infinity)
request.addValue("", forHTTPHeaderField: "returnDocumentContents")
request.addValue("multipart/form-data", forHTTPHeaderField: "Content-Type")
request.addValue("YOUR-API-KEY-HERE", forHTTPHeaderField: "Apikey")
request.addValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
     guard let data = data else {
          print(String(describing: error))
          semaphore.signal()
          return
     }
     print(String(data: data, encoding: .utf8)!)
     semaphore.signal()
}

task.resume()
semaphore.wait()