Pulkit Raina
Pulkit Raina

Reputation: 1

Adding SVG to PDF using jsPDF on server (using NestJS or NodeJS)

I am trying to insert a SVG to my PDF using NestJS and jsPDF. But I think jsPDF doens't have support for inserting SVGs on server. Is there any way around this someone has found? Would be really helpful.

I have made a addImage function that is working as expected and inserting the image:

  addImage = (imageData: Buffer, options?: any): void => {
    this.doc.addImage(
      imageData,
      'JPEG',
      options?.x || this.x,
      options?.y || this.y,
      options?.width || this.doc.internal.pageSize.getWidth(),
      options?.height || this.doc.internal.pageSize.getHeight(),
    );

    this.y =
      options?.height ||
      this.doc.internal.pageSize.getHeight() + this.doc.getLineHeight();
    this.updatePointer();
  };

But the addSvgAsImage (as per the jsPDF docs jsPDF Docs: SVG) function doesn't seem to work

Upvotes: 0

Views: 113

Answers (1)

dariush jokar
dariush jokar

Reputation: 46

This issue has been resolved in jsPDF already if your dont find your answer yet check the link below How to add SVG to PDF

Upvotes: 0

Related Questions