PejmanNik / jikji

Effortless report generator and reporting tools with React and NodeJS
https://jikji.xyz
MIT License
45 stars 1 forks source link

How to pass jsonData in SSG? #33

Closed abdul41265 closed 5 months ago

abdul41265 commented 5 months ago

Can we send dynamic data like this? And how do we access it on the front end?

const jsonData: any = { title: "Test injection 💉", table: [ { index: 1, caption: "data" }, { index: 2, caption: "more data" }, ], };

await ReportBuilder.browser(browser) .serve("./build") .report("new_report") .jsonData(jsonData) .pdf({ path: 'out.pdf' }) .build();

PejmanNik commented 5 months ago

What do you mean by dynamic data?

There is a sample in the documentation for using it: https://jikji.xyz/docs/inject-json-data

abdul41265 commented 5 months ago

Is this approach possible to transmit data from the server to the client side?

Screenshot 2024-01-25 at 12 05 40 a m
PejmanNik commented 5 months ago

The JSON data only works when you use SSG, so there is no client. If you want to fetch the data on the client side, you need to use a normal JS/React approach, for instance, check this example: QuoteFromAPI.tsx

abdul41265 commented 5 months ago

Is it possible to save a PDF file on the client side similar to how it's done in SSG by specifying a path?

PejmanNik commented 5 months ago

Please create a new issue if your question is unrelated to the original issue. I think you can find your answer in the documentation https://jikji.xyz/docs/csr-vs-ssg basically, your only option is calling window.print()

Feel free to reopen the issue if you still have any questions