Free plan

Sanitize PDF

Remove scripts, attachments and hidden extras from a PDF
POST
/v1/pdfs/sanitize

About this tool

This tool cleans a PDF of things that can run by themselves or reveal more than you meant to share. It removes scripts (small programs inside the file), automatic actions, attached files and embedded video or sound. You can also remove web links and the document details such as author. The result tells you what was removed.
For example, a PDF came from someone you do not fully trust, so you clean it before opening or forwarding it.

How to use it

  1. Choose this tool.
  2. Add your PDF.
  3. Choose what to remove: scripts, actions, attachments, embedded media, links, or document details.
  4. Press Generate.
  5. Download the cleaned PDF and read what was removed.

What you get back

You get a cleaned copy of the PDF and a list of what was removed. You can download it.
GOOD TO KNOW
A PDF in, a cleaned PDF out. An encrypted file must be unlocked first. Counts as one file.
TEST IT LIVE

Try Sanitize PDF in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
PDFs
Plan
Free
Method
POST
Endpoint
/v1/pdfs/sanitize
Tool ID
pdfs.sanitize
Authentication
API key
Accepts
PDF
Background jobs
Yes
Usage group
Pdf
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/pdfs/sanitize" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'file=@document.pdf' \
  -F 'remove=["javascript","attachments","metadata"]' \
  -F 'validate_only=false' \
  -F 'response=url'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.pdfs.sanitize({
    "file": 'document.pdf',
    "remove": "[\"javascript\",\"attachments\",\"metadata\"]",
    "validate_only": false,
    "response": "url"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->pdfs()->sanitize([
    'file' => 'document.pdf',
    'remove' => '["javascript","attachments","metadata"]',
    'validate_only' => false,
    'response' => 'url',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Remove what can run or leak from a PDF before you open or share it: scripts, launch and form-submit actions, embedded files, embedded media, web links and document details. The answer says what was removed.

Sanitize PDF accepts PDF. You can send several files in one request.

Sanitize PDF is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/pdfs/sanitize with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.