carboneio / carbone

Fast and simple report generator, from JSON to pdf, xslx, docx, odt...
https://carbone.io
Other
1.33k stars 196 forks source link

[Bug Report]: Can't generate PDF with next.js #195

Open 151ali opened 1 year ago

151ali commented 1 year ago

Environment Carbone Version: "^3.5.5" Node Version: v16.15.1 Browsers: Microsoft edge Version 109.0.1518.61 (Official build) (64-bit) Desktop OS: Ubuntu 22.04.1 LTS Other: LibreOffice: 7.6.1.2 (X86_64) / LibreOffice Community (installed manually) , nextjs v13.5.4

Expected Behaviour Generate a PDF document from and .odt template

Actual Behaviour Generating PDF loop forever

Steps to reproduce Steps to reproduce the bug:

  1. Create a nextjs app
  2. Create api\pdf\route.ts
import { NextResponse } from "next/server";

const carbone = require('carbone');

//Create a promise for carbone
const util = require(`util`);
const render = util.promisify(carbone.render);

export const GET = async (req: Request, res: NextResponse) => {
  try {

    // Data to inject
    let data = {
      name : 'John',
      age : 26
    };

    let options = {
      // convertTo: 'pdf'
    }

    let report = await render('./template.odt', data, options);        

    return new NextResponse(report, { status: 200 })

  } catch (error) {

    return NextResponse.json({error}, { status: 500})
  }
};
  1. run this command

    curl -o result.odt --location --request GET 'http://localhost:3000/api/pdf'

    The result.odt is generated with no problem

  2. uncomment convertTo: 'pdf' option

  3. The command below loop for ever

    curl -o result-pdf.pdf --location --request GET 'http://localhost:3000/api/pdf'
maniac-on-moon commented 10 months ago

Please try to install apt install libnss3 and give a hint if it works (so did for me, for LO 7.6.4.1). Since LO missing libss libssl3 und libsmime3 on Ubuntu minimal install.

151ali commented 3 months ago

I think that the problem is with nextJs, I tried carbone with nodejs and It works totally fine

I can't figure out what the real issue 🤔