Getting corrupted excel file when converting pdf to excel using ExportConverter.Export

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
morajece
User
Posts: 3
Joined: Wed Aug 14, 2019 2:08 pm

Getting corrupted excel file when converting pdf to excel using ExportConverter.Export

Post by morajece »

Hi Team,
I am trying to convert a pdf to excel programatically using PDFXEditCore.x64.dll and getting the output excel file in corrupted format.
Could you please let me know if I am doing anything wrong in the code or any other better way to perform this conversion

Getting this error when opening excel:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/sprea ... ary>Errors were detected in file '\bin\Debug\Files\Output.xlsx'</summary><removedParts><removedPart>Replaced Part: /xl/worksheets/sheet1.xml part with XML error. Load error. Line 11, column 0.</removedPart></removedParts></recoveryLog>

Using below code to convert pdf to excel
IPXV_ExportConverter oExp ;
//PXV_Control pdfCtl = new PXV_Control();
var inst_pxv = new PXV_Inst();
inst_pxv.Init();
inst_pxv.StartLoadingPlugins();
inst_pxv.AddPluginFromFile(dir + @"\Files\ConvertPDF.pvp");
inst_pxv.FinishLoadingPlugins();

var x = inst_pxv.ExportConvertersCount;
for(int i= 0; i<=x-1; i++ )
{
IPXV_ExportConverter oexpCv = inst_pxv.ExportConverter[(uint)i];
if(oexpCv.ID == "conv.exp.office.xlsx")
{
ICab cab = inst_pxv.GetFormatConverterParams(false, oexpCv.ID);
//ICabNode convParamsRoot = cab.Root;

IAFS_Inst fsInst = inst_pxv.GetExtension("AFS");
IAFS_Name destPath = fsInst.DefaultFileSys.StringToName(exl);
int openFileFlags = (int)(AFS_OpenFileFlags.AFS_OpenFile_CreateAlways | AFS_OpenFileFlags.AFS_OpenFile_Read | AFS_OpenFileFlags.AFS_OpenFile_Write | AFS_OpenFileFlags.AFS_OpenFile_FullCache);
IAFS_File destFile = fsInst.DefaultFileSys.OpenFile(destPath, openFileFlags);

IPXC_Inst docInst = (PXC_Inst)inst_pxv.GetExtension("PXC");
IPXC_Document srcDoc = docInst.OpenDocumentFromFile(pdf, null);
oexpCv.Convert(inst_pxv, srcDoc, destFile, 0, cab, null, 0, null, null);
}
}

Appreciate any help, Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Getting corrupted excel file when converting pdf to excel using ExportConverter.Export

Post by Sasha - Tracker Dev Team »

Hello morajece,

Please try converting that pdf file to excel via the End-User Editor installed on the same machine and see whether everything goes well.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
morajece
User
Posts: 3
Joined: Wed Aug 14, 2019 2:08 pm

Re: Getting corrupted excel file when converting pdf to excel using ExportConverter.Export

Post by morajece »

Thanks for your response Alex, yes I am able to convert the pdf to excel using the editor tool installed and it is opening fine and all the fields are converted properly. But getting issue when doing it through SDK.

Thanks
Mohanraj S
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Getting corrupted excel file when converting pdf to excel using ExportConverter.Export

Post by Sasha - Tracker Dev Team »

Hello Mohanraj S,

Does this happen with all of the files or there is one specific file that you are having troubles with?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
morajece
User
Posts: 3
Joined: Wed Aug 14, 2019 2:08 pm

Re: Getting corrupted excel file when converting pdf to excel using ExportConverter.Export

Post by morajece »

Hi Alex,
It is happening with most of the pdf files I tried, but worked on one pdf file. For now I am calling pdftools.exe from my app to convert the pdf to excel.

Thanks
Mohanraj S
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8610
Joined: Wed Jan 03, 2018 6:52 pm

Re: Getting corrupted excel file when converting pdf to excel using ExportConverter.Export

Post by TrackerSupp-Daniel »

Hello Morajece,

I apologize for the relative radio silence, We are in the final stages of release prep, so the Devs a busily working through finalizing anything that our testers can find in the RC builds.

I am gad to hear you have a temporary workaround for the moment at least.
if the issue is only happening with certain files, I am curious to know if there is any discernable pattern that makes those files different from the one that did work. Could you look into those files and see, perhaps they are all around a certain size, or were all made by the came application, anything that is similar among the "not working" files, that is distinctly different from the one "working file" you have.

After that, can we ask you to send us the working document, and a few of the not working ones, so that our Development team is able to go over them (or at least reproduce the issue) and begin working towards a solution for you?

Kind regards,
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Getting corrupted excel file when converting pdf to excel using ExportConverter.Export

Post by Sasha - Tracker Dev Team »

Hello Morajece,

I've debugged your sample - you simply forgot to close the IAFS_File after conversion.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply