---
title: "Edit a generated PDF server-side | Nutrient"
canonical_url: "https://www.nutrient.io/guides/document-engine/pdf-generation/from-html/edit-a-generated-pdf/"
md_url: "https://www.nutrient.io/guides/document-engine/pdf-generation/from-html/edit-a-generated-pdf.md"
last_updated: "2026-05-23T00:08:18.043Z"
description: "Discover how to finalize PDFs with cover pages, watermarks, and more using Document Engine. Combine PDF Generation and actions in one command for optimal result"
---

# Edit a generated PDF

After generating a PDF, you may still want to perform extra operations to finalize your document. Examples of these operations include adding a cover page, adding watermarks, setting page labels, and more. Any [`action`](https://www.nutrient.io/api/reference/document-engine/upstream/#model/BuildInstructions) provided by Document Engine can be used with PDF Generation. To learn more about the actions you can perform with Document Engine, see the [API Reference](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API).

This guide shows how PDF Generation and additional actions are combined in one command to produce the final document.

## Generating a PDF from HTML

The example consists of a simple styled form, which can be seen in the following HTML:

```html

<!DOCTYPE html>
<html>
  <head>
    <style>
      body {
        font-size: 16px;
        line-height: 1.6em;
        font-family: "Helvetica", Arial, sans-serif;
        color: #3d434e;

      }

      h1 {
        font-size: 42px;
        font-weight: normal;
        color: #142132;

        margin-block-start: 0.3em;
      }

      h2 {
        font-size: 32px;
        font-weight: normal;
        color: #142132;

        margin-block-start: 0.3em;
      }

      h3 {
        font-size: 12px;
        font-weight: normal;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: #4739e5;

      }.container {
        max-width: 500px;
        margin: 100px auto auto;
        page-break-after: always;
      }.grid {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
      }.column {
        display: flex;
        flex-direction: column;
      }.form-list {
        list-style: none;
        padding: 0;
      }.list-item {
        margin-bottom: 1.5rem;
      }.form-border {
        padding: 15px 10px;
        border-width: 2px;
      }.form-text {
        font-size: 18px;
        line-height: 1.5;
      }.full-width {
        width: 100%;
      }.expanded-checkbox {
        width: 30px;
        height: 30px;
      }.checkbox-label {
        display: flex;
        align-items: center;
        padding-left: 10px;
      }.checkbox-list {
        display: flex;
      }
    </style>
    <title>Data Science Online Course</title>
  </head>

  <body>
    <div class="container">
      <h3>Data Science</h3>
      <h1>Course Signup</h1>
      <p>
        Learn how to make informed decisions, create beautiful visualizations,
        and even try to predict future events through Machine Learning.
      </p>

      <form>
        <ul class="form-list">
          <li class="list-item">
            <label for="knowledge-level"></label>
            <select
              id="knowledge-level"
              class="full-width form-text form-border"
            >
              <option selected>-- Knowledge level --</option>
              <option value="beginner">Beginner</option>
              <option value="intermediate">Intermediate</option>
              <option value="professional">Professional</option>
            </select>
          </li>
          <li class="list-item">
            <div class="grid">
              <div class="column">
                <label for="first-name">First Name</label>
                <input
                  type="text"
                  id="first-name"
                  class="form-text form-border"
                />
              </div>
              <div class="column">
                <label for="last-name">Last Name</label>
                <input
                  type="text"
                  id="last-name"
                  class="form-text form-border"
                />
              </div>
            </div>
          </li>
          <li class="list-item">
            <div class="column">
              <label for="email">Email</label>
              <input type="text" id="email" class="form-text form-border" />
            </div>
          </li>
          <li class="list-item">
            <div class="column">
              <label for="phone-number">Phone Number</label>
              <input
                type="text"
                id="phone-number"
                class="form-text form-border"
              />
            </div>
          </li>
          <li class="checkbox-list">
            <input type="checkbox" id="terms" class="expanded-checkbox" />
            <label class="checkbox-label" for="terms"
              >I have read and agreed with the terms and conditions.</label
            >
          </li>
        </ul>
      </form>
    </div>
    <div class="container">
      <h2>Terms and Conditions</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit....</p>
    </div>
  </body>
</html>

```

This form includes some text boxes, a select box, and a checkbox. These have all been styled to ensure they display nicely on an A4 page.

In addition to the form, there’s a Terms and Conditions section, which is referenced on the form. To ensure this section is generated on a separate page, set the `page-break-after` property to `always` in the `container` class. This forces a page break when generated.

To generate a PDF with the form and the terms and conditions, send a multipart message using the `curl` example below. This code has margins defined for the page layout of the generated PDF:

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F page.html=@/path/to/page.html \
  -F instructions='{
  "parts": [
    {
      "html": "page.html",
      "layout": {
        "size": "a4",
        "margin": {
          "left": 10,
          "right": 10,
          "top": 40,
          "bottom": 10
        }
      }
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="page.html"; filename="page.html"
Content-Type: text/html

<HTML data>
--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "html": "page.html",
      "layout": {
        "size": "a4",
        "margin": {
          "left": 10,
          "right": 10,
          "top": 40,
          "bottom": 10
        }
      }
    }
  ]
}
--customboundary--

```

## Adding a Cover Page

To add a cover page to the generated PDF, send a request like in the example below to the [`/api/build` endpoint](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API). To learn more about combining various documents and pages, read our [merging documents](https://www.nutrient.io/guides/document-engine/editor/page-manipulation/move-or-rearrange.md) guide.

The name of the cover page in the multipart request needs to be the same name referenced by `file` in the [`FilePart`](https://www.nutrient.io/api/reference/document-engine/upstream/#model/BuildInstructions). If you don’t have a suitable PDF document, use the sample [cover page PDF](https://www.nutrient.io/downloads/examples/generation-cover-page.pdf):

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F page.html=@/path/to/page.html \
  -F cover-page=@/path/to/cover-page.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "cover-page"
    },
    {
      "html": "page.html",
      "layout": {
        "size": "a4",
        "margin": {
          "left": 10,
          "right": 10,
          "top": 40,
          "bottom": 10
        }
      }
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="page.html"; filename="page.html"
Content-Type: text/html

<HTML data>
--customboundary
Content-Disposition: form-data; name="cover-page"; filename="cover-page.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": "cover-page"
    },
    {
      "html": "page.html",
      "layout": {
        "size": "a4",
        "margin": {
          "left": 10,
          "right": 10,
          "top": 40,
          "bottom": 10
        }
      }
    }
  ]
}
--customboundary--

```![Added a cover page](@/assets/guides/document-engine/pdf-generation/editing-generation-1st-page.jpg)![Generated Forms on a page](@/assets/guides/document-engine/pdf-generation/editing-generation-2nd-page.jpg)![Generated Terms and Conditions](@/assets/guides/document-engine/pdf-generation/editing-generation-3rd-page.jpg)

## Adding a Watermark

To add a [`watermark`] to the document, use the example below.

To learn more about how to add watermarks to documents, refer to our [watermark](https://www.nutrient.io/api/reference/document-engine/upstream/#model/WatermarkAction) guide.

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F page.html=@/path/to/page.html \
  -F cover-page=@/path/to/cover-page.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "cover-page"
    },
    {
      "html": "page.html",
      "layout": {
        "size": "a4",
        "margin": {
          "left": 10,
          "right": 10,
          "top": 40,
          "bottom": 10
        }
      }
    }
  ],
  "actions": [
    {
      "type": "watermark",
      "text": "Property of PSPDFKit",
      "width": 250,
      "height": 200,
      "left": 0,
      "bottom": "50%",
      "opacity": 0.5,
      "rotation": 10,
      "fontSize": 50,
      "fontColor": "#FF0000",

      "fontStyle": [
        "italic",
        "bold"
      ],
      "fontFamily": "Helvetica"
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="page.html"; filename="page.html"
Content-Type: text/html

<HTML data>
--customboundary
Content-Disposition: form-data; name="cover-page"; filename="cover-page.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": "cover-page"
    },
    {
      "html": "page.html",
      "layout": {
        "size": "a4",
        "margin": {
          "left": 10,
          "right": 10,
          "top": 40,
          "bottom": 10
        }
      }
    }
  ],
  "actions": [
    {
      "type": "watermark",
      "text": "Property of PSPDFKit",
      "width": 250,
      "height": 200,
      "left": 0,
      "bottom": "50%",
      "opacity": 0.5,
      "rotation": 10,
      "fontSize": 50,
      "fontColor": "#FF0000",

      "fontStyle": [
        "italic",
        "bold"
      ],
      "fontFamily": "Helvetica"
    }
  ]
}
--customboundary--

```![Added a watermark to the document](@/assets/guides/document-engine/pdf-generation/editing-generation-watermark.png)

To learn more, go to the [API Reference](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API) and the [overview](https://www.nutrient.io/guides/document-engine/pdf-generation.md) guide.
---

## Related pages

- [Generate a blank PDF](/guides/document-engine/pdf-generation/from-html/blank-pdf.md)
- [Customize the page header and footer](/guides/document-engine/pdf-generation/from-html/page-header-footer.md)
- [Java](/guides/document-engine/pdf-generation/from-html/java.md)
- [Generate fillable PDF forms from HTML](/guides/document-engine/pdf-generation/from-html/fillable-pdf-forms.md)
- [Create PDFs from scratch](/guides/document-engine/pdf-generation/from-html/from-scratch.md)
- [HTML-to-PDF conversion server sample code](/guides/document-engine/pdf-generation/from-html/sample-code.md)
- [HTML-to-PDF generation schema](/guides/document-engine/pdf-generation/from-html/schema.md)
- [HTML template design for generating PDFs](/guides/document-engine/pdf-generation/from-html/template-design.md)
- [JavaScript](/guides/document-engine/pdf-generation/from-html/javascript.md)
- [PHP](/guides/document-engine/pdf-generation/from-html/php.md)
- [Python](/guides/document-engine/pdf-generation/from-html/python.md)

