pdfme / pdfme

A TypeScript based PDF generator library, made with React.
https://pdfme.com
MIT License
2.19k stars 194 forks source link

Multi Page PDF as basePDF #65

Closed karo-init closed 1 year ago

karo-init commented 2 years ago

Hi Kyohei, at first thanks for the great repository ! I'm still on the "Getting started level" with it and I tried to use a self created Multipage PDF as basePDF but I had only success with a Single Page PDF. Do I have to use an additional property for using a Multipage PDF as basePDF or is it not possible yet ?

hand-dot commented 2 years ago

Hi @karo-init !

We can use Multipage PDF as basePDF. Could you please share minimal reproduction and code?

karo-init commented 2 years ago

Hi @hand-dot,

this is the code i tried out:

function App() {
  const template: Template = {
    basePdf: EXAMPLE_PDF,
    schemas: [
      {
        a: {
          type: "text",
          position: { x: 0, y: 0 },
          width: 10,
          height: 10,
        },
        b: {
          type: "text",
          position: { x: 10, y: 10 },
          width: 10,
          height: 10,
        },
        c: {
          type: "text",
          position: { x: 20, y: 20 },
          width: 10,
          height: 10,
        },
      },
    ],
  };

  const inputs = [{ a: "a1", b: "b1", c: "c1" }];

  const onGeneratePDF = async () => {
    const pdf = await generate({ template, inputs });
    const blob = new Blob([pdf.buffer], { type: "application/pdf" });
    window.open(URL.createObjectURL(blob));
  };

And EXAMPLE_PDF is a Multipage PDF I created from a webpage with the built in PDF Printer from Chrome Browser. The Encoding of the PDF starts with "export const EXAMPLE_PDF = 'data:application/pdf;base64, ... ".

Thanks in advance for looking at it !

hand-dot commented 2 years ago

@karo-init

Sorry for the late reply. Could you upload EXAMPLE_PDF?

hand-dot commented 1 year ago

@karo-init I labeled the answer because I did not receive a reply. If there are no replies at this point, it will be closed after 30 days. If you have any questions, please comment.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been open 30 days with no activity after answered. Remove stale label or comment or this issue will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was automatically closed because of stale in 7 days