Ahmed Moubtahij
Ahmed Moubtahij
SSolara
Created by Ahmed Moubtahij on 9/12/2024 in #questions-issues
rendering pdf
Yep, reorganizing project structure to have ../public relative to the running .py worked! Thank you 🙏
11 replies
SSolara
Created by Ahmed Moubtahij on 9/12/2024 in #questions-issues
rendering pdf
Oh I see, indeed, I'll fix that tonight, thanks! (Yeah other basic components work)
only show the iframe when the task is done (i.,e. when the file is written)
Did you mean something like this?
if (out_pdf := solara.lab.use_task(generate_pdf, dependencies=[])).finished:
solara.HTML(
tag="iframe",
attributes={"src": f"/static/{out_pdf.value}", "style": "width:100%; height:100%;"},
)
else:
solara.ProgressLinear(out_pdf.pending)
if (out_pdf := solara.lab.use_task(generate_pdf, dependencies=[])).finished:
solara.HTML(
tag="iframe",
attributes={"src": f"/static/{out_pdf.value}", "style": "width:100%; height:100%;"},
)
else:
solara.ProgressLinear(out_pdf.pending)
11 replies
SSolara
Created by Ahmed Moubtahij on 9/12/2024 in #questions-issues
rendering pdf
PUBLIC_DIR = Path("public/")
PDF_PATH = PUBLIC_DIR/"my_cv.pdf"

@solara.component
def Page():
with solara.Column(style={"height": "100%", "width": "100%"}):
solara.lab.use_task(generate_pdf, dependencies=[])
solara.HTML(f'<iframe src="/static/{str(PDF_PATH)}" style="width:100%; height:100%;"></iframe>')
PUBLIC_DIR = Path("public/")
PDF_PATH = PUBLIC_DIR/"my_cv.pdf"

@solara.component
def Page():
with solara.Column(style={"height": "100%", "width": "100%"}):
solara.lab.use_task(generate_pdf, dependencies=[])
solara.HTML(f'<iframe src="/static/{str(PDF_PATH)}" style="width:100%; height:100%;"></iframe>')
Replaced with use_task. It is more appropriate, thanks! I was already using "public/" in the pdf path though, I made it clearer. Here is what my project structure looks like:
├── Dockerfile
├── README.md
├── __init__.py
├── compose.yaml
├── public
│   └── my_cv.pdf
├── requirements.txt
└── ui.py
├── Dockerfile
├── README.md
├── __init__.py
├── compose.yaml
├── public
│   └── my_cv.pdf
├── requirements.txt
└── ui.py
The browser just shows A widget with mount-id="solara-main" should go here
11 replies