Render¶
Pub Analyzer provides the option to generate reports in PDF format, that summarizes all the available information. This process utilizes typst, the new markup-based typesetting system for the sciences. Let's see how to render a scientific production report for an author.
import asyncio
from pub_analyzer.internal.render import render_report
from pub_analyzer.models.report import AuthorReport
report = AuthorReport(**kwargs) # (1)!
pdf_bytes = render_report(report=report)
with open('demo.pdf', mode="wb") as file:
file.write(pdf_bytes)
- Use real information instead of
**kwargs
placeholder.
Warning
Currently, I have not discovered an efficient approach to generate a complete PDF summary for institutions, covering the huge volume of data in the reports. I am open to new ideas and suggestions about it.
Render reports.
render_report ¶
def render_report(
report: AuthorReport | InstitutionReport,
file_path: Path | None,
) -> bytes | None
Render report to PDF.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
report
|
AuthorReport | InstitutionReport
|
Report Model. |
required |
file_path
|
Path | None
|
Path to save the compiled file. |
required |
Returns:
Type | Description |
---|---|
bytes | None
|
PDF bytes or None if output file path is defined. |
Raises:
Type | Description |
---|---|
SyntaxError
|
If typst compiler syntax error. |