PicasSoft Logo

Welcome to PicasSoft API

Preparing your print...

/add-bleed

PUT request. Adds bleed to a PDF file.

{
    "file": "your_file.pdf",
    "bleed_width": 0.5,
}
        

/impose

PUT request. Imposes a PDF file.

{
    "input_pdf": "your_input_file.pdf",
    "template_pdf": "your_template_file.pdf",
    "is_front": boolean,
    "params": "your_params"
}
        

/impose-glue

PUT request. Imposes a PDF file with glue.

{
    "input_front_pdf": "your_input_front_file.pdf",
    "input_back_pdf": "your_input_back_file.pdf",
    "template_glue_pdf": "your_template_file.pdf",
    "params": "your_params"
}
        

/impose-fit

PUT request. Imposes a PDF file with fit.

{
    "input_pdf": "your_input_file.pdf",
    "template_pdf": "your_template_file.pdf",
    "is_front": boolean,
    "params": "your_params"
}
        

/roll-impose

PUT request. Imposes a PDF file ona roll.

{
    "unwind": "Not Important" | 1 | 2 | 3 | 4,
    "shape": "rectangular" | "square" | "circle" | "oval" | "custom",
    "round_corners": "1/16" | "1/8" | "1/4" | "1/2",
    "size": [width, height],
    "input_pdf": "your_input_file.pdf",
    "template_pdf": "your_template_file.pdf",
    "params": {"canvas-width": [6.5, 8.5, 13],"h-align": ["left",0.125],"CutName": "Cut"}
}
        

/impose-lf-cut

PUT request. Imposes a PDF file with a laser cut.

{
    "shape": "rectangular" | "square" | "circle" | "oval" | "custom",
    "round_corners": "1/16" | "1/8" | "1/4" | "1/2",
    "size": [width, height],
    "input_pdf": "your_input_file.pdf",
    "template_pdf": "your_template_file.pdf",
}
        

/convert-html-to-pdf

PUT request. Converts HTML to a PDF file.

{
    "html_url": "your_html_url",
    "html_string": "your_html_string",
    "html_file": "your_html_file",
}
        

white-spot-separate

PUT request. Adds a white support spot to a PDF file.

{
    "input_pdf_id": "google drive id"
}
        

background-cut

PUT request. Adds support for background cut.

{
    "input_pdf_id": "google drive id",
    "texture_img_id": "google drive id of the texture jpg",
    "texture_color_code": "hex color code of the texture instead of texture image",
    "params": {"product": {"bleed": 0.25}, "background-color": "#FFFFFF"} # Change as per requirements
}
        
Enter the parameters in JSON format:

spot-uv-effect

PUT request. Adds support for spot UV effect.

{
"input_pdf_id": "google drive id",
"params": {
    "uv-angle": 90, # 0 to 180 degrees (0 is horizontal) Controls the angle of the light source
    "uv-scale": 1, # 0 to 5 (0 is no effect) Controls the intensity of the effect (0 is no effect, 1 is maximum effect and 5 is a very soft effect)
    "uv-offset": 0, # 0 to 128 (0 is no effect) Controls the transparency of the effect (0 is fully transparent and 128 is fully opaque)
    "uv-soften": 5 # 0 to 10 (0 is no effect) Controls the softness of the effect (0 is no effect, 5 is medium softness and 10 is very soft)
    }
}
        

Documentation

This is the documentation for the PicasSoft API. Below you will find the endpoints and the required parameters for each endpoint.

PicasSoft

Description

This project is a Python-based PDF processing service. It listens for new PDF files in a specified directory, processes them, and saves the output to the local file system. The project uses several Python libraries such as asyncio, os, pathlib, click, dotenv, fitz, and PIL.

Installation

  1. Clone the repository:

    git clone git@github.com:ivangoranov/PicasSoft.git
    
  2. Install the dependencies:

    pip install -r requirements.txt
    

API Endpoints

The application provides the following endpoints:

Example Requests

Here are examples of how to make requests to each of the endpoints in Python, cURL, and PHP:

Add Bleed

This endpoint is used to add a bleed to a PDF file. The input PDF file is modified by adding a bleed of the specified width to each edge of the document. The output PDF file is returned as the response. The bleed width is specified in inches.

URL: /add-bleed

Method: PUT

Data Params:

Success Response:

Example:

/add-bleed endpoint:

Python:

import requests

url = 'http://localhost:5000/add-bleed'
file_path = '/path/to/your/file.pdf'
bleed_width = 0.25
files = {'file': open(file_path, 'rb')}
data = {'bleed_width': bleed_width}
response = requests.put(url, data=data, files=files)

pdf_data = response.content

with open('output.pdf', 'wb') as f:
    f.write(pdf_data)

cURL:

curl -X PUT -F "file=@/path/to/your/file.pdf" -F "bleed_width=0.25" http://localhost:5000/add-bleed > output.pdf

PHP:

<?php
$url = "http://localhost:5000/add-bleed";
$file_path = "/path/to/your/file.pdf";
$bleed_width = 0.25;

$cfile = new CURLFile($file_path);
$data = array("file" => $cfile, "bleed_width" => $bleed_width);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
?>

Impose

This endpoint is used to impose a PDF file onto a template PDF file. The input PDF file is imposed onto the template PDF file according to the specified parameters. The output PDF file is returned as the response.

URL: /impose

Method: PUT

Data Params:

Success Response:

Example:

/impose endpoint:

Python:

import requests
import json

url = "http://localhost:5000/impose"
input_pdf_path = "/path/to/your/input.pdf"
template_pdf_path = "/path/to/your/template.pdf"
output_pdf = "/path/to/output/file.pdf"
params = {
    "canvas": (13, 19),
    "horizontal-repeat": [0, 0],
    "vertical-repeat": [0, 0, 0, 0.50, 0, 0, 0],
    "h-align": ["center", 0], 
    "v-align": ["center", 0],
    "mark-offset": 0.125,
    "mark-length": 0.25,
    "product": {"width": 8.5, "height": 11, "bleed": 0.125},
    "masksize": ["width + bleed", "height + bleed"]

}

with open(input_pdf_path, 'rb') as f1, open(template_pdf_path, 'rb') as f2:
    files = {'input_pdf': f1, 'template_pdf': f2}
    data = {'params': json.dumps(params)}
    response = requests.put(url, files=files, data=data)

print(response.status_code)

Impose Glue

This is the same as Impose, but require an additional parameter `input_back_pdf' which is the back side of the input_pdf. And the back is imposed upside down.

URL: /impose-glue

Method: PUT

Data Params:

Success Response:

Example:

/impose-glue endpoint:

Python:


import requests
import json

url = "http://localhost:5000/impose-glue"
input_pdf_path = "/path/to/your/input.pdf"
input_back_pdf_path = "/path/to/your/input_back.pdf"
template_pdf_path = "/path/to/your/template.pdf"

params = {
    "canvas": (13, 19),
    "horizontal-repeat": [0, 0],
    "vertical-repeat": [0, 0, 0, 0.50, 0, 0, 0],
    "h-align": ["center", 0], 
    "v-align": ["center", 0],
    "mark-offset": 0.125,
    "mark-length": 0.25,
    "product": {"width": 8.5, "height": 11, "bleed": 0.125},
    "masksize": ["width + bleed", "height + bleed"]

}

with open(input_pdf_path, 'rb') as f1, open(input_back_pdf_path, 'rb') as f2, open(template_pdf_path, 'rb') as f3:
    files = {'input_pdf': f1, 'input_back_pdf': f2, 'template_pdf': f3}
    data = {'params': json.dumps(params)}
    response = requests.put(url, files=files, data=data)

print(response.status_code)

Convert HTML to PDF

This endpoint is used to convert an HTML string to a PDF file.

URL: /convert-html-to-pdf

Method: PUT

Data Params:

Success Response:

Example:

/convert-html-to-pdf endpoint:

Python:

import requests

url = "http://localhost:5000/convert-html-to-pdf"
html_string = "<html><body><h1>Hello, World!</h1></body></html>"

options = {
    'page-size': 'Letter',  # Letter, A4, etc. (default 'Letter')
    'margin-top': '0.0in',
    'margin-right': '0.0in',
    'margin-bottom': '0.0in',
    'margin-left': '0.0in',
}

data = {'html_string': html_string, 'options':options}
response = requests.put(url, data=data)

# The PDF data is in the content attribute of the response
pdf_data = response.content

# Write the PDF data to a file
with open('output.pdf', 'wb') as f:
    f.write(pdf_data)

cURL:

curl -X PUT -d "html_string=<html><body><h1>Hello, World!</h1></body></html>" -d "output_pdf=/path/to/output/file.pdf" http://localhost:5000/convert-html-to-pdf

PHP:

<?php
$url = "http://localhost:5000/convert-html-to-pdf";
$html_string = "<html><body><h1>Hello, World!</h1></body></html>";
$output_pdf = "/path/to/output/file.pdf";

$data = array("html_string" => $html_string, "output_pdf" => $output_pdf);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
?>

White Support Spot

This endpoint is used to add a white support spot to a PDF file.

URL: white-spot-separate

Method: PUT

Data Params:

Success Response:

Example:

/white-spot-separate endpoint:

Python:

import requests

url = "http://127.0.0.1:5000/white-support-spot"
null = False
response = requests.put(url, data={
    "input_pdf_id": "1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ"
})
print(response.status_code)
with open("test_separation.zip", "wb") as f:
    f.write(response.content)

cURL:

curl -X PUT -F "background_pdf=@path_to_background.pdf" -F "spot_pdf=@path_to_spot.pdf" http://localhost:5000white-spot-separate > output.pdf

PHP:

<?php
$url = "http://localhost:5000white-spot-separate";
$background_pdf_path = "/path/to/your/background.pdf";
$spot_pdf_path = "/path/to/your/spot.pdf";

$cfile1 = new CURLFile($background_pdf_path);
$cfile2 = new CURLFile($spot_pdf_path);
$data = array("background_pdf" => $cfile1, "spot_pdf" => $cfile2);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
?>

Background Cut

This endpoint is used to apply clipping mask and background color to a PDF file.

URL: background-cut

Method: PUT

Data Params:

{"product": {"bleed": 0.25}, "background-color": "#FFFFFF"} # Change as per requirements

Success Response:

Example:

/background-cut endpoint:

Python:

import requests
import json

url = "http://localhost:5000/background-cut"

response = requests.put(url, data={
    "input_pdf_id": "1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ",
    "texture_img_id": "1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ",
    "texture_color_code": "#FFFFFF",
    "params": json.dumps({"product": {"bleed": 0.25}, "background-color": "#FFFFFF"})
})
print(response.status_code)
with open("test_separation.zip", "wb") as f:
    f.write(response.content)

cURL:

curl -X PUT -F "input_pdf_id=1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ" -F "texture_img_id=1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ" -F "texture_color_code=#FFFFFF" -F "params={'product': {'bleed': 0.25}, 'background-color': '#FFFFFF'}" http://localhost:5000/background-cut > output.pdf

PHP:

<?php
$url = "http://localhost:5000/background-cut";
$input_pdf_id = "1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ";
$texture_img_id = "1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ";
$texture_color_code = "#FFFFFF";
$params = array("product" => array("bleed" => 0.25), "background-color" => "#FFFFFF");

$data = array("input_pdf_id" => $input_pdf_id, "texture_img_id" => $texture_img_id, "texture_color_code" => $texture_color_code, "params" => json_encode($params));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
?>

Spot UV

This endpoint is used to apply spot UV to a PDF file.

URL: spot-uv-effect

Method: PUT

Data Params:

{
    "uv-angle": 0, # 0 to 180 degrees (0 is horizontal) Controls the angle of the light source
    "uv-scale": 1, # 0 to 5 (0 is no effect) Controls the intensity of the effect (0 is no effect, 1 is maximum effect and 5 is a very soft effect)
    "uv-offset": 0, # 0 to 128 (0 is no effect) Controls the transparency of the effect (0 is fully transparent and 128 is fully opaque)
    "uv-soften": 5 # 0 to 10 (0 is no effect) Controls the softness of the effect (0 is no effect, 5 is medium softness and 10 is very soft)
}

Success Response:

Example:

/spot-uv-effect endpoint:

Python:

import requests
import json

url = "http://localhost:5000/spot-uv-effect"

response = requests.put(url, data={
    "input_pdf_id": "1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ",
    "params": json.dumps({
        "uv-angle": 0,
        "uv-scale": 1,
        "uv-offset": 0,
        "uv-soften": 5
    })
})

print(response.status_code)
with open("test_spot_uv.png", "wb") as f:
    f.write(response.content)

cURL:

curl -X PUT -F "input_pdf_id=1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ" -F "params={'uv-angle': 0, 'uv-scale': 1, 'uv-offset': 0, 'uv-soften': 5}" http://localhost:5000/spot-uv-effect > output.png

PHP:

<?php
$url = "http://localhost:5000/spot-uv-effect";
$input_pdf_id = "1p2SsjXKwNjmj1wfXr5ka2y4aPZdqTwaJ";
$params = array(
    "uv-angle" => 0,
    "uv-scale" => 1,
    "uv-offset" => 0,
    "uv-soften" => 5
);

$data = array("input_pdf_id" => $input_pdf_id, "params" => json_encode($params));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
?>