Tasks
Manipulate PDF
This task manipulates PDF documents by performing operations such as rotation, cropping, resizing, quality adjustment, and grayscale conversion on specific pages or entire documents.
Use Cases
- Rotating PDF pages that are not oriented correctly to allow for better viewing and processing.
- Reducing PDF quality to reduce file size and optimize storage.
- Cropping PDF pages to focus on specific regions of interest.
- Resizing PDF pages to meet specific dimension requirements.
- Converting PDF pages to grayscale for document processing or printing.
- Processing specific pages or page ranges within a PDF document.
Basic usage
Parameters
files required object[]
An array of file objects. Each object contains file metadata.
Show child attributes
fileuuid required string
The unique identifier of the PDF file that should be manipulated.
pages optional string
Specifies which pages of the PDF to manipulate. Can be provided in multiple formats:
- Single page:
"1" - Multiple specific pages:
"1,3,5" - Page range:
"1-5" - Combination:
"1,3-5,7,10-12"
If not specified, operations will be applied to all pages in the PDF.
Default: All pages
operations required object
An object containing the manipulation operations to perform on the PDF pages. You can specify one or more operations. Available operations:
Show child attributes
crop
Crops the PDF pages to specified dimensions and offset.
widthnumber- Width of the cropped area in pixelsheightnumber- Height of the cropped area in pixelsx_offsetnumber- Horizontal offset from the top-left corner in pixelsy_offsetnumber- Vertical offset from the top-left corner in pixels
rotate
Rotates the PDF pages by the specified degrees.
degreesnumber- Rotation angle in degrees (e.g., 90, 180, 270)
resize
Resizes the PDF pages to specified dimensions.
widthnumber- New width in pixelsheightnumber- New height in pixels
adjust_quality
Adjusts the PDF quality/compression level.
qualitynumber- Quality level from 1-100, where 100 is highest quality
grayscale
Converts the PDF pages to grayscale when set to true.
Result
Properties
manipulated_files array
An array of file objects representing the manipulated PDF documents. Each object contains:
filenamestring- The filename of the manipulated PDForiginalnamestring- The original filenamefileuuidstring- The unique identifier of the manipulated PDF filecontentTypestring- The MIME type of the document (application/pdf)
Examples
Rotate specific pages 90 degrees
Rotates pages 1, 2, and 3 of an uploaded PDF 90 degrees clockwise.
Reduce PDF quality for optimization
Reduces the PDF quality to 50% to decrease file size for all pages.
Crop and resize specific pages
Crops a specific region from pages 1 and 5 of a PDF and then resizes them.
Convert to grayscale for document processing
Converts pages 2 through 10 to grayscale and reduces quality for document processing workflows.
Multiple operations on specific pages
Applies multiple manipulation operations to pages 1, 3-5, and 8: rotation, cropping, resizing, quality adjustment, and grayscale conversion.
Rotate all pages in a PDF
Rotates all pages in the PDF 180 degrees without specifying a pages parameter.