Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
151ali opened this issue Oct 16, 2023 · 1 comment
Open

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

151ali opened this issue Oct 16, 2023 · 1 comment
Labels
T: bug Functionality that does not work as intended/expected

Comments

@151ali
Copy link

151ali commented Oct 16, 2023

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

  1. uncomment convertTo: 'pdf' option
  2. The command below loop for ever
curl -o result-pdf.pdf --location --request GET 'http://localhost:3000/api/pdf'
@151ali 151ali added the T: bug Functionality that does not work as intended/expected label Oct 16, 2023
@maniac-on-moon
Copy link

maniac-on-moon commented Jan 29, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

No branches or pull requests

2 participants