Skip to content
Pdf storage is designed to be universally usable PDF generator from html templates.
C# Perl HTML Dockerfile PowerShell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Data Fix: Style fixes (#43) Oct 4, 2019
Pdf Added try catch finally to generating pdf Nov 19, 2019
PdfMerge Feature/update for chromium version and qpdf (#52) Nov 7, 2019
Scripts Fix issue where sometimes blank or partially blank pdf is generated (#26 Jun 25, 2019
Test Added editorconfig and matching style fixes (#50) Nov 7, 2019
Util Remove footers etc from generated pdf:s (#34) Sep 24, 2019
Jenkinsfile Feature/update for chromium version and qpdf (#52) Nov 7, 2019
Pdf.Storage.sln PDF uploading implemented. Jun 7, 2017

Docker pulls Build Status License: MIT


PDF storage is designed to be a universally usable PDF generator from HTML templates.

Key aspects:

  • The consumer of the API doesn't have to care how PDFs, templates and so on are persisted - the storage will handle that part.
  • A simple API which takes HTML and templating data and responds with a final PDF file URL.
  • Supports merging PDFs as one.
  • Can handle very large amounts of generated PDFs and prioritize files which require a faster output (files which are currently opened if the queue is long) before everything else.
  • Supports AWS, Azure and Google services and data stores.

For further details, see the API description document.

Testing locally in docker

Easiest way to run and test application is to start in with docker

docker run -it -p 5000:5000 -e ASPNETCORE_ENVIRONMENT=Development ptcos/pdf-storage

Navigate to http://localhost:5000/doc

Running locally for development

Install .NET core SDK.

dotnet run --environment=Development

The default development setup mocks all external dependencies.

Navigate to http://localhost:5000/doc/.

The following headers must be included in API calls:

Authorization: ApiKey apikeyfortesting
Content-Type: application/json-patch+json

Local development with mocks enabled

The default Development environment setup enables all mocks in appsettings.Development.json. This way the service should start and function correctly without any external dependencies.

  "DbType": "inMemory",
  "MqType": "inMemory",
  "PdfStorageType": "inMemory"

These can be overwritten with environment variables: PdfStorageType = "inMemory" etc.

On Linux (Debian) set development, install pdftk and chromium.

sudo apt-get -y install pdftk chromium

On Windows, Chrome is required.

Run a local development database


docker run --name pdf-storage-postgress -e POSTGRES_PASSWORD=passwordfortesting -it -p 5432:5432 postgres

Connect with User ID=postgres;Password=passwordfortesting;Host=localhost;Port=5432;Database=pdfstorage;Pooling=true;.


docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=testpassword1#!' -p 1433:1433 --name sql1 -d

Connect with Server=localhost,1433;Database=pdf-storage;User=sa;Password=testpassword1#!

Hangfire dashboard

Dashboard allows traffic only from localhost on production builds.

For this reason, port forwarding to the running container is required (in Kubernetes).

kubectl -n pdf-storage port-forward pdf-storage-master-4075827073-5h77r 5000

Navigate (via forwarded port) to http://localhost:5000/hangfire.

Other technologies

The localhost requirement applies, but access methods may vary.

PDF stores

Google bucket

PDF storage supports Google bucket for saving PDF binaries.

Mount a valid service account file, configure its path and Google configurations in appconfig or environment variables.

  "PdfStorageType": "googleBucket",
  "GoogleCloud": {
    "GoogleBucketName": "pdf-storage-master",
    "GoogleAuthFile": "/path/to/key/google.key.json"

Example (not valid) service account file, see Google service accounts for further information.

  "type": "service_account",
  "project_id": "some-project",
  "private_key_id": "1234",
  "private_key": "-----BEGIN PRIVATE KEY-----\nKEY_SHOULD_BE_HERE-----END PRIVATE KEY-----\n",
  "client_email": "",
  "client_id": "1234",
  "auth_uri": "",
  "token_uri": "",
  "auth_provider_x509_cert_url": "",
  "client_x509_cert_url": ""


Configure application to use AWS S3 store.

  "PdfStorageType": "awsS3",
  "AwsS3": {
    "AwsS3BucketName": "pdf-storage-master",
    "AccessKey": "thisisaccesskey",
    "SecretKey": "ThisIsSecretKey",
    "AwsServiceURL": "http://localhost:9000",
    "AwsRegion": "EUCentral1"

Azure storage

PDF storage supports Azure storage accounts as storage.

  "PdfStorageType": "azureStorage",
  "AzureStorage": {
    "StorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=[your_account];AccountKey=[your_key];",
    "ContainerName": "pdf-storage"


There is a special script for migrations since multiple database engines are supported.

./AddOrRemoveMigrations.ps1 -MigrationName "DescriptionForMigration"

Removing the latest migration

./AddOrRemoveMigrations.ps1 -Operation Remove -MigrationName "DescriptionForMigration"


The MIT License (MIT)

You can’t perform that action at this time.