Converting PDF to Excel using Adobe PDF Tool API in NET

0 votes

I need to convert PDF to Excel as part of a current Azure function that I'm working on. To convert, I'm using the Adobe PDF Tools API. The PDF is in my Azure storage account, and I can read the content in the memory stream using the Data lake file client. I utilize the API after that, and the code is displayed in the image.

    await file.ReadToAsync(memoryStream);
Credentials credentials = Credentials.ServiceAccountCredentialsBuilder()
                                   .FromFile("pdftools-api-credentials.json")
                                   .Build();

Adobe.DocumentServices.PDFTools.ExecutionContext executionContext = Adobe.DocumentServices.PDFTools.ExecutionContext.Create(credentials);
                        ExportPDFOperation exportPdfOperation = ExportPDFOperation.CreateNew(ExportPDFTargetFormat.XLSX);
                        
FileRef sourceFileRef = FileRef.CreateFromStream(memoryStream, ExportPDFOperation.SupportedSourceFormat.PDF.GetMediaType());
                        exportPdfOperation.SetInput(sourceFileRef);
FileRef result = exportPdfOperation.Execute(executionContext);

Now, when I run this, I get the following error:

"Error response received for the request: An error occurred while sending the request. The response ended prematurely."

The code is in C#.

Can someone please help? 


Dec 15, 2022 in Others by Kithuzzz
• 38,010 points
886 views

1 answer to this question.

0 votes

An identical mistake was occurring for me when exporting a pdf to pictures.

A more helpful error notice appeared after I downgraded Adobe.DocumentServices.PDFTools NuGet package from version 1.3.0 to 1.2.0: "The input file is a zero-length file."

Adding this fixed it for me.

memoryStream.Position = 0;
answered Dec 15, 2022 by narikkadan
• 63,720 points

Related Questions In Others

0 votes
0 answers

How to insert dropdown or checkbox in Excel using Javascript API?

I'm following the doc (https://dev.office.com/reference/add-ins/excel/excel-add-ins-reference-overview) to build ...READ MORE

Oct 31, 2022 in Others by Kithuzzz
• 38,010 points
490 views
0 votes
0 answers

Converting feet & inches (e.g., "5 ft 1 in") to decimal feet using VBA or Excel

I have a database with a few ...READ MORE

Nov 2, 2022 in Others by Kithuzzz
• 38,010 points
471 views
0 votes
1 answer

How to download SQL data in excel format using asp.net

Solution Download Open XML Download Close XML Library. import this Namespaces using System.IO; using System.Data; using ...READ MORE

answered Nov 14, 2022 in Others by narikkadan
• 63,720 points
892 views
0 votes
1 answer

How to remove borders from cells in a range in Excel using VB.net?

range.Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlLineStyleNone range.Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = Excel.XlLineStyle.xlLineStyleNone range.Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlLineStyleNone range.Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle ...READ MORE

answered Jan 5, 2023 in Others by narikkadan
• 63,720 points
1,420 views
0 votes
1 answer

Merge and export Excel/Word/PDF to PDF

Use GroupDocs.Merger for .NET API to merge Word, Excel, ...READ MORE

answered Oct 3, 2022 in Others by narikkadan
• 63,720 points
1,156 views
0 votes
1 answer

Deleting duplicate rows in Excel using Epplus

You need to re-think this… the while ...READ MORE

answered Feb 23, 2022 in Database by gaurav
• 23,260 points
1,214 views
0 votes
1 answer

Print Pdf in C#

Using an installed Adobe Reader or any ...READ MORE

answered Jun 7, 2022 in C# by pranav
• 2,590 points
717 views
0 votes
1 answer

Export DataTable to Excel File

Add Interop References. First we need to ...READ MORE

answered Jun 9, 2022 in JQuery by gaurav
• 23,260 points
641 views
0 votes
1 answer

How to print an Excel Sheet using VBA with Nitro PDF Creator in Excel 2016

you can use the built-in excel facilities ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 63,720 points
1,071 views
0 votes
1 answer

Converting excel to pdf using PHP

If utilizing PHP on a Windows PC, ...READ MORE

answered Oct 23, 2022 in Others by narikkadan
• 63,720 points
5,119 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP