I want to add an image to a pdf file, the images are in the static directory:
'static/images/logo.png'
Settings file:
STATIC_URL = '/static/'
Part of the Code:
from borb.pdf.canvas.layout.image.image import Image
page_layout.add(
Image(
"/static/images/logo.png",
width=Decimal(128),
height=Decimal(128),
))
Error Code:
MissingSchema: Invalid URL '/static/images/Logo.png': No schema supplied. Perhaps you meant http:///static/images/Logo.png?
I do not want to show it in a front end template, instead is a backend function to generate pdfs.
Do i have to provide/generate any kind of url link to the Image function?? how to do it?
Thanks !
Disclaimer: I am Joris Schellekens, author of aforementioned library
borb
.The constructor of
Image
either accepts:str
if you intend to grab the image from a URLPath
if you intend to use a local image on your filesystemYou specified a
str
soborb
is under the impression you want to use a file that is present on your filesystem.It then tries to
assert
whether that file exists. Which is not the case. Hence the error.The solution would be to either provide a
Path
or the fully resolved file-path as astr
.