Merge pull request #3 from presenton/export_presentation_fixes

Fixes: Presentation export as pptx and pdf
This commit is contained in:
Saurav Niraula 2025-05-11 01:00:38 +05:45 committed by GitHub
commit 55edf09098
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 6 deletions

View file

@ -8,7 +8,7 @@
"start": "tsc && electron-forge start",
"package": "tsc && electron-forge package",
"make": "tsc && electron-forge make",
"setup:env": "cd servers/fastapi && poetry env remove --all && poetry install",
"setup:env": "npm install && cd servers/fastapi && poetry install && cd ../../servers/nextjs && npm install",
"build:ts": "tsc",
"build:css": "tailwindcss -i ./resources/ui/assets/tailwind.import.css -o ./resources/ui/assets/tailwind.css",
"build:nextjs": "rm -rf resources/nextjs && mkdir -p resources/nextjs && cd servers/nextjs && npm run build && cp -r .next ../../resources/nextjs",

View file

@ -21,8 +21,10 @@ class FetchPresentationAssetsMixin:
image_name = replace_file_name(
os.path.basename(parsed_url), str(uuid.uuid4())
)
image_path = os.path.join(self.temp_dir, image_name)
image_local_paths.append(image_path)
image_path = os.path.join(self.temp_dir, image_name)
image_local_paths.append(image_path)
elif image_path.startswith("file://"):
image_path = image_path.replace("file://", "")
each_shape.picture.path = image_path
each_shape.picture.is_network = False

View file

@ -288,7 +288,7 @@ async def search_icon(data: SearchIconRequest):
@presentation_router.post(
"/presentation/export_as_pptx", response_model=PresentationAndUrl
"/presentation/export_as_pptx", response_model=PresentationAndPath
)
async def export_as_pptx(data: ExportAsRequest):
request_utils = RequestUtils("/ppt/presentation/export_as_pptx")
@ -301,7 +301,7 @@ async def export_as_pptx(data: ExportAsRequest):
@presentation_router.post(
"/presentation/export_as_pdf", response_model=PresentationAndUrl
"/presentation/export_as_pdf", response_model=PresentationAndPath
)
async def export_as_pdf(data: ExportAsRequest):
request_utils = RequestUtils("/ppt/presentation/export_as_pdf")

View file

@ -268,7 +268,12 @@ class PptxPresentationCreator:
or picture_model.object_fit
or picture_model.shape
):
image = Image.open(image_path)
try:
image = Image.open(image_path)
except:
print(f"Could not open image: {image_path}")
return
image = image.convert("RGBA")
# ? Applying border radius twice to support both clip and object fit
if picture_model.border_radius: