Skip to content

Broken PDF Generated in Docker build #99

Description

@nikolai-momot-finaeo

I have a Node 14 app that uses the pdf-fill-form to fill out questionnaires.

When I run the app on Mac it works well; a new PDF is successfully generated and the fields are filled out.

However, when I run the app on our docker container the generated PDF is broken and unusable.

The strangest part is that the PDF only breaks when the a key in the json mappings actually matches a field id
ex.

Mapping of { "test": "fake" }, properly working PDF generated
Mapping of { "q1a.pi1.first": "Bob" }, broken PDF generated

Has anyone else encountered this issue?

Here is the method that handles calling the pdf-fill-form package

import pdfFillForm from 'pdf-fill-form'

export const fill = async (
  template: Buffer,
  mappings: Record<string, string>
): Promise<Buffer> => {
  const resultPDF = await pdfFillForm.writeBuffer(template, mappings, {
    save: 'pdf'
  })

  return resultPDF
}

Here is a redacted version of the Dockerfile used:

FROM node:14.15.1-alpine

COPY . .

RUN apk update && \
  apk add --no-cache make gcc g++ python libgcc libstdc++ linux-headers poppler-qt5-dev cairo-dev && \
  yarn global add typescript && \
  yarn install && \
  tsc -p ./tsconfig.build.json

FROM node:14.15.1-alpine
ADD https://github.com/just-containers/s6-overlay/releases/download/v1.21.8.0/s6-overlay-amd64.tar.gz /tmp/
RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C /

RUN apk update &&  apk add --no-cache qt5-qtbase poppler-qt5-dev cairo-dev

...

CMD ["node", "/app/src/server.js"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions