-1

I'm trying to convert a .pdf file to .docx using Aspose.Cloud.

It converts other formats like word or text to PDF fairly easily, but I'm having trouble converting a .pdf file to any other format.

I have also tried the Aspose.Pdf service, but that only allows you to convert to/from a physical path (D/myfile.pdf). I want to be able to do this within the storage itself (azure blob), i.e. Pick a file from one container (pdfcontainer) -- convert to docx -- store to doccontainer.

I've tried the ConvertDocument and ConvertToSomeFormat methods exposed by the PDFService class. I'm also converting documents of other formats like doc, txt to PDF using the ConvertDocument method of the WordsService class and this converts the documents and saves it successfully. But ConvertToSomeFormat doesn't save the file to the specified container. I get a "404 not found" error while trying to retrieve the file.

Converting docx/txt to PDF - This works!

WordsService wordService = new WordsService("myAppId", "myAppKey");
wordsService.ConvertDocument(convertFromFile, WordOutputFormat.Pdf, convertFromContainer, convertToContainer + "/" + targetFilename, asposeStorageName);

Converting PDF to docx - Doesn't work!

PDFService pdfService = new PDFService("myAppId", "myAppKey");
pdfService.ConvertToSomeFormat(convertFromFile, PDFDocumentConvertFormat.Doc, convertToContainer, convertToContainer + "/" + targetFilename, asposeStorageName);
Paul Roub
  • 35,100
  • 27
  • 72
  • 83
  • Please share what you have done so far and any errors that you're getting. – Gaurav Mantri Jun 10 '16 at 06:15
  • @GauravMantri - I've tried the ConvertDocument and ConvertToSomeFormat methods exposed by PDFService class. I'm also converting documents of other formats like doc, txt to pdf using ConvertDocument method of WordsService class and this converts the documents and saves it successfully. But ConvertToSomeFormat doesnt save the file to the specified container. I get a 404 not found error while trying to retrieve the file. – Kartik Jethani Jun 10 '16 at 06:22
  • Please update your question with these details and also share the code. Things tend to get lost in the comments :). – Gaurav Mantri Jun 10 '16 at 06:35
  • If you're getting a 404 on the file stored in Azure Blob Storage, please check the ACL on the container. It should be either set to `Blob` or `Off`. If it is `Private`, then you would get a 404 error. – Gaurav Mantri Jun 10 '16 at 08:01
  • It doesn't really convert and save the file to blob. Works fine if I'm converting a docx to pdf but doesn't work the other way round. Sorry for the confusion. – Kartik Jethani Jun 10 '16 at 08:24
  • Hi Kartik, did you try following the instructions specified over following link for PDF to DOCX conversion using Aspose.Pdf for Cloud (as the code snippet shared above appears different). In case you still face same issue, please share your resource file in Aspose.Pdf product support forum. We will test the scenario and will reply accordingly. http://www.aspose.com/docs/display/pdfcloud/Convert+PDF+to+Images%2C+TIFF%2C+DOC%2C+HTML+and+other+Formats – codewarior Jun 19 '16 at 21:05
  • @codewarior I tried the REST API but the `GetResultStream` method returns ContentLength = 0 my response uri looks like this `http://api.aspose.com/v1.1/pdf/82ca3472-7dbc-497c-be72-284227b59966?format=Doc&storage=MyStorage&folder=resumes&outPath=convertedworddocs/82ca3472-7dbc-497c-be72-284227b59966&appSID=myId&signature=myKey` Is there something I maybe doing wrong? I also tried with a blob that doesn'texist but that throws a 404 not found - which is correct. But with the blob that does exist, I don't get any exception but I don't get the stream as well – Kartik Jethani Jun 24 '16 at 09:00

1 Answers1

0
  1. You need to download the PDF SDK for .NET from https://github.com/aspose-pdf/Aspose.Pdf-for-Cloud and then use with the SDK code given at http://www.aspose.com/docs/display/pdfcloud/Convert+PDF+to+Images%2C+TIFF%2C+DOC%2C+HTML+and+other+Formats

  2. If you do not want to use PDF SDK and want to keep using your existing code, then you should check the following

A. If the size of input file and generated output file is within your plan limits. You can test with a smaller PDF to confirm if all PDFs produce the same issue. B. You should also check his destination folder because when you specify outPath parameter, then you should not get the output file in response stream. It will be saved to outPath only.

You may check and confirm if output file is not generated at the outPath he specified. I think it should be present at the outPath because no exception is thrown by his REST code

Once you have shared this information, we will proceed with further investigation.

If the problem still persists, please share your App SID, App Key, Azure storage name and folder name via email nayyer.shahbaz@aspose.com You should not share App SID or Key in public forums.

codewarior
  • 521
  • 2
  • 9
  • thank you for your response. Is there a way to give azure storage path as the outPath within the REST call - so that the file is directly stored first and then retrieved for downloading? I'm doing this so as to avoid having to convert the file every time a user tries to download it. As of now I am returning the stream and then making another call to the storage to save it, but I would like this to be handled within the conversion call itself. Does it make sense? – Kartik Jethani Jul 05 '16 at 03:52