Convert PPTX to PDF in Ruby on Rails

We are using aspose cloud api for our web app. Ppt to pdf works fine. But when we try to convert pptx to pdf we get a 400 Bad Request error.

Does aspose support pptx conversion for ruby on rails.

Below is the code which we are using for conversion (it works fine when we convert ppt to pdf).

@file_from_storage = File.open(’/home/user / Documents / abc.pptx’)
logger.debug“ converting to pdf via aspose”
strURI = 'http://api.saaspose.com/v1.0/slides/convert?format=pdf'
signedURI = Common::Utils.sign(strURI)
@responseStream = RestClient.put(signedURI, @file_from_storage,: accept => ‘application / xml’,: content_type => “application / vnd.openxmlformats - officedocument.presentationml.presentation”)

Could someone please let me know what could be the problem.

Hi Ankit,

Thank you for considering Aspose.

Yes, Aspose.Slides for Cloud does support PPTX to PDF conversion. However, http://api.saaspose.com/v1.0 is discontinued and you are suggested to try the new http://api.aspose.com/v1.1/ instead as your base URI, http://api.aspose.com/v1.1/ contains all the new fixes and features. You can refer to the below documentation link with sample code on how to convert PPTX to PDF using Aspose.Slides for Cloud.

http://www.aspose.com/docs/display/slidescloud/Convert+PowerPoint+Documents+to+other+File+Formats

In case you need any further assistance, please feel free to contact support.

Thanks & Regards,

Hi,

Thanks for your reply.

I tried changing the api version from 1.0 to 1.1, but still receive the same 400 bad request error.

Hi Ankit,

Please share your presentation file with us. I will test it at my end and see whether issue is related to the file or a bad request.

Thanks & Regards,

Hi,

Below is the code which we use to convert ppt/pptx to pdf.

def process_ppt
presentation = self
File.open(Rails.root + presentation.name, “wb”) do | saved_file | open(presentation.document.url, ‘rb’) do | read_file | saved_file.write(read_file.read) end end

    #open(presentation.document.url) {
      | f | File.open(“tmp” + presentation.name, “wb + ”) do | file | file.puts f.read;
        end
    }
  @file_from_storage = File.open(Rails.root + presentation.name).read
logger.debug“ converting to pdf via aspose”
strURI = ‘ [http: //api.saaspose.com/v1.1/slides/convert?format=pdf ](http://api.saaspose.com/v1.1/slides/convert?format=pdf)’
    signedURI = Common::Utils.sign(strURI)
    responseStream = RestClient.put(signedURI, @file_from_storage, {
      : accept => “application / xml”
    }, {
      : content_type => ‘application / vnd.openxmlformats - officedocument.presentationml.presentation’
    })
    /// this line gives 400 bad request when trying to convert pptx to pdf.
    logger.debug“ saving pdf to a temp file”
    Common::Utils.saveFile(responseStream, “output.pdf”)
    end

Hi Ankit,

I don’t see the file name you want to convert to PDF in your URI. As suggested in my last post, please go through the following documentation link to get the details and sample code for building your URI to convert PPTX to PDF.

http://www.aspose.com/docs/display/slidescloud/Convert+PowerPoint+Documents+to+other+File+Formats

You URI should be similar to 'http://api.aspose.com/v1.1/slides/' + file_name + '?format=pdf' where file_name is the name of the file on cloud storage.

Please update your code with the link shared above and in case you still face any issue, please do let us know.

Thanks & Regards,

Hi owais,

We are not using aspose storage to store our files, instead we are using amazon s3.

Everything works fine when we try to convert ppt to pdf with the code which I had posted:

we get a pdf file from ppt

the file are stored in s3

We get a 400 bad request error only when we try to convert a pptx file to pdf.

The code was written with reference to the following documentation link

Convert PowerPoint Documents to other File Formats without Using Storage

Hi Ankit,

Thank you for the details.

Please share the PPTX file with us for which you are getting issue in conversion. We will further check it and get back to you soon.

Thanks & Regards,

Hi,

I have attached the file.

You can use any random pptx file for testing.

Hi Ankit,

Thank you for the sharing the PPTX file.

I am able to reproduce your mentioned issue after testing with your shared PPTX file. It seems the issue is specific to the PPTX file you shared as I am able to convert other PPTX files at my end without any issue. We have created an issue in our issue tracking system with issue id: SAASSLIDES-125 for further investigation. We will update you via this forum thread once the issue gets resolved.

Sorry for the inconvenience,

Hi Ankit,

Our development team has further investigated your issue
and it seems that PPTX file you shared is not created with PowerPoint. In your
presentation there are issues with placeholder indexes and with shape ids (These
are duplicate). Please let us know, how did you create the presentation file?
It will help us in identifying the issue.

Thanks & Regards,

Hi,

Sorry! for the late response.

Yeah that pptx was created with Liberoffice impress, and not with powerpoint. We have fixed the issue and our app is successfully processing pptx presentations which are created with powerpoint.

But, currently we get 400 Bad request when we create a presentation created with open office.

Could you please let me know how can we resolve this issue.

Hi Ankit,

Thank you for the feedback.

We are happy to know that you were able to resolve the issue regarding PPTX files. Now, regarding Open Office files, please share some sample presentation file with us for testing and investigation of the issue.

Thanks & Regards,

We understood that ppt files created with powerpoint work well, but ppts created with LibreOffice impress do not work.

Currently we still get 400 Bad request when we try to process a presentation created with LibreOffice impress.

I have attached a sample ppt file which is created with LibreOffice impress.

Could you please resolve this issue.

Hi Ankit,

Thank you for the details.

I have shared the details and sample file with the development team for further investigation of your issue. Once we have any feedback, we will update you via this forum thread.

Thanks & Regards,