I am trying to convert my pptx file to pdf with SDK on python django. Running on debug I look how I cant even enter into response. On the other hand It says my directory where I want to save pdf file converted doesnt exist, which is false because I made test and I cant save files there. This is my code, thank you in advance:
def generate_and_save_pptx(self):
# Ruta PPTX
pptx_template_path = ‘panel/templates/originals/Prueba.pptx’
# Ruta PDF final
pdf_filename = f’{self.client.name} - {self.type_submission.name}_tutorial.pdf’
pdf_path = submission_directory_path(self,pdf_filename)
api_instance = groupdocs_conversion_cloud.ConvertApi.from_keys(app_sid, app_key)
# Configura la solicitud de conversión directa
convert_request = groupdocs_conversion_cloud.ConvertDocumentDirectRequest(
"pdf",
pptx_template_path, # Reemplaza con la ruta correcta a tu archivo
None,
None,
None
)
try:
# Realiza la conversión directa
response = api_instance.convert_document_direct(convert_request)
# Guarda el archivo convertido
with open(pdf_path, "wb") as pdf_file:
pdf_file.write(response)
print(f"Archivo guardado en: {pdf_path}")
except ApiException as e:
print(f"Error durante la conversión: {e}")