Convert Error

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
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Convert Error

Post by HomerWu »

Hello,

An other Error when convert Excel to PDF doc,error info is 'Call was rejected by callee.(Exception from HRESULT:0x80010001(RPC_E_CALL_REJECTED))',any one can tell me why it appears and how to fix it?

many thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert Error

Post by Sasha - Tracker Dev Team »

Hello HomerWu,

Can you please provide a sample document and a code that you are using to convert?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Convert Error

Post by HomerWu »

Hello Sasha,

Hello Sasha,

Below is our conversion method code and the attachment is my sample document,

Code: Select all

        private PDFXEdit.IPXC_Document ConvertTopdfDoc(string filePath, ref AuthCallback callback)
        {
            try
            {
                #region GetImportConverter
                 string extension = GetImportFileExt(Path.GetExtension(filePath).Trim('.').ToLower());
                PDFXEdit.IPXV_ImportConverter cov = null;
                PDFXEdit.IPXC_Document doc = null;
                for (int i = 0; i < pdfCtl.Inst.ImportConvertersCount; i++)
                {
                    cov = pdfCtl.Inst.get_ImportConverter((uint)i);
                    if (cov.ID == extension)
                    {
                        break;
                    }
                }
                #endregion
                #region Start Convert
                if (cov != null && cov.ID == extension)
                {
                    if (extension == "conv.imp.pdf")
                    {
                        #region Convert to PDF doc
                        PDFXEdit.IPXS_Inst pxsInst = (PDFXEdit.IPXS_Inst)pdfCtl.Inst.GetExtension("PXS");
                        callback = new AuthCallback(pxsInst);
                        doc = ((PDFXEdit.IPXC_Inst)pdfCtl.Inst.GetExtension("PXC")).OpenDocumentFromFile(filePath, callback);
                        if (!callback.AuthorSuccess)
                        {
                            doc.Close();
                            doc = null;
                        }
                        #endregion
                    }
                    else
                    {
                        PDFXEdit.IAFS_Inst fsInst = (PDFXEdit.IAFS_Inst)pdfCtl.Inst.GetExtension("AFS");
                        PDFXEdit.IAFS_Name name = fsInst.DefaultFileSys.StringToName(filePath);
                        int openFileFlags = (int)(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read | PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_ShareRead);

                        PDFXEdit.IAFS_File destFile = fsInst.DefaultFileSys.OpenFile(name, openFileFlags);
			//for Office document
                        if (NeedFormatConverterParams(extension))
                        {
                            PDFXEdit.ICab cab = pdfCtl.Inst.GetFormatConverterParams(true, cov.ID);
                            doc = cov.Convert(pdfCtl.Inst, destFile, 0, cab);
                        }
                        else
                        {
                            doc = cov.Convert(pdfCtl.Inst, destFile);
                        }
                        Marshal.ReleaseComObject(cov);
                        Marshal.ReleaseComObject(destFile);
                        Marshal.ReleaseComObject(name);
                        cov = null;
                        destFile = null;
                        name = null;
                    }
                }
                else
                {
                    MessageBox.Show("Unsupported format.");
                }
                #endregion
                return doc;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
        
        private bool NeedFormatConverterParams(string extension)
        {
            if (extension == "conv.imp.office.doc" ||
                extension == "conv.imp.office.xls" ||
                extension == "conv.imp.office.ppt" ||
                extension == "conv.imp.office.vsd")
            {
                return true;
            }
            return false;
        }
by the way,I found many types of documents can be converted successful,but Office documents often appear a variety of problems when converting,
I wonder if the method i used is wrong,or do you have other ways to convert Office documents?
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Convert Error

Post by HomerWu »

Hello,

Sorry for forget to upload the file :D
attachment is my sample document.

Thanks.
Attachments
attachment.rar
(8.89 KiB) Downloaded 80 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert Error

Post by Sasha - Tracker Dev Team »

Hello HomerWu,

Code: Select all

string extension = GetImportFileExt(Path.GetExtension(filePath).Trim('.').ToLower());
This line here was the problem one for me:
1) I do not have this method
2) In case of the "xlsx" file you have provided make sure you wont return the conv.imp.office.xlsx by mistake.
When I changed this line to

Code: Select all

string extension = "conv.imp.office.xls";
Your code worked for me with your file.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Convert Error

Post by HomerWu »

Hello Sasha,

yes,the method just returns a string to get the right IPXV_ImportConverter,below is the code:

Code: Select all

 private string GetImportFileExt(string ext)
        {
            IDictionary<string, string> _dicImportMapping = new Dictionary<string, string>();
            _dicImportMapping.Add("pdf", "conv.imp.pdf");
            _dicImportMapping.Add("fdf", "conv.imp.fdf");
            _dicImportMapping.Add("xfdf", "conv.imp.xfdf");
            _dicImportMapping.Add("xps", "conv.imp.xps");
            _dicImportMapping.Add("bmp", "conv.imp.image.bmp");
            _dicImportMapping.Add("gif", "conv.imp.image.gif");
            _dicImportMapping.Add("ico", "conv.imp.image.ico");
            _dicImportMapping.Add("xdp", "conv.imp.xdp");
            _dicImportMapping.Add("rtf", "conv.imp.rtf");
            #region for conv.imp.txt
            _dicImportMapping.Add("txt", "conv.imp.txt");
            _dicImportMapping.Add("sql", "conv.imp.txt");
            _dicImportMapping.Add("cs", "conv.imp.txt");
            _dicImportMapping.Add("as", "conv.imp.txt");
            _dicImportMapping.Add("asm", "conv.imp.txt");
            _dicImportMapping.Add("asp", "conv.imp.txt");
            _dicImportMapping.Add("sh", "conv.imp.txt");
            _dicImportMapping.Add("bat", "conv.imp.txt");
            _dicImportMapping.Add("cmd", "conv.imp.txt");
            _dicImportMapping.Add("nt", "conv.imp.txt");
            _dicImportMapping.Add("c", "conv.imp.txt");
            _dicImportMapping.Add("ml", "conv.imp.txt");
            _dicImportMapping.Add("cmake", "conv.imp.txt");
            _dicImportMapping.Add("h", "conv.imp.txt");
            _dicImportMapping.Add("hpp", "conv.imp.txt");
            _dicImportMapping.Add("hxx", "conv.imp.txt");
            _dicImportMapping.Add("cpp", "conv.imp.txt");
            _dicImportMapping.Add("cxx", "conv.imp.txt");
            _dicImportMapping.Add("cc", "conv.imp.txt");
            _dicImportMapping.Add("css", "conv.imp.txt");
            _dicImportMapping.Add("diff", "conv.imp.txt");
            _dicImportMapping.Add("java", "conv.imp.txt");
            _dicImportMapping.Add("js", "conv.imp.txt");
            _dicImportMapping.Add("jsp", "conv.imp.txt");
            _dicImportMapping.Add("ini", "conv.imp.txt");
            _dicImportMapping.Add("inf", "conv.imp.txt");
            _dicImportMapping.Add("reg", "conv.imp.txt");
            _dicImportMapping.Add("iss", "conv.imp.txt");
            #endregion
            _dicImportMapping.Add("jbig", "conv.imp.image.jbig");
            _dicImportMapping.Add("jbig2", "conv.imp.image.jbig2");
            _dicImportMapping.Add("pnm", "conv.imp.image.pnm");
            _dicImportMapping.Add("pgm", "conv.imp.image.pgm");
            _dicImportMapping.Add("ppm", "conv.imp.image.ppm");
            _dicImportMapping.Add("tga", "conv.imp.image.tga");
            _dicImportMapping.Add("pcx", "conv.imp.image.pcx");
            _dicImportMapping.Add("dcx", "conv.imp.image.dcx");
            _dicImportMapping.Add("png", "conv.imp.image.png");
            _dicImportMapping.Add("jpg", "conv.imp.image.jpeg");
            _dicImportMapping.Add("j2k", "conv.imp.image.j2k");
            _dicImportMapping.Add("tiff", "conv.imp.image.tiff");
            _dicImportMapping.Add("tif", "conv.imp.image.tiff");
            _dicImportMapping.Add("metafile", "conv.imp.image.metafile");
            #region for Office document
            _dicImportMapping.Add("doc", "conv.imp.office.doc");
            _dicImportMapping.Add("docx", "conv.imp.office.doc");
            _dicImportMapping.Add("xls", "conv.imp.office.xls");
            _dicImportMapping.Add("xlsx", "conv.imp.office.xls");
            _dicImportMapping.Add("ppt", "conv.imp.office.ppt");
            _dicImportMapping.Add("pptx", "conv.imp.office.ppt");
            _dicImportMapping.Add("vsd", "conv.imp.office.vsd");
            #endregion
            if (_dicImportMapping.ContainsKey(ext))
            {
                return _dicImportMapping[ext];
            }
            return "";
        }
it will return 'conv.imp.office.xls' when convert Excel file,and sometimes it the Excel file can be converted successfully,but sometimes it can not :(
The attachment is the screenshot of error info.

Thanks.
Attachments
screenshot.png
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert Error

Post by Sasha - Tracker Dev Team »

Hello HomerWu,

Please check this thread:
https://stackoverflow.com/questions/205 ... result-0x8

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Convert Error

Post by HomerWu »

Hello Sasha,

Thanks for your reply,i will have a try again. :P
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert Error

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Convert Error

Post by DolphinMann »

Sasha,

Am I to understand that PDF X-Change Editor SDK requires Microsoft Office installed(word/excel) to convert document and spreadsheet files?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Convert Error

Post by Tracker Supp-Stefan »

Hello DolphinMann,

Yes - we do rely on some Office APIs for the conversion to the proprietary office formats.

Regards,
Stefan
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Convert Error

Post by DolphinMann »

I meant to convert FROM a Doc/Excel in to PDF, not the other way around. Are those API's still required?

Do you have a list of what APIs you use and would Open Office installation suffice?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Convert Error

Post by Tracker Supp-Stefan »

Hello DolphinMann,

Yes - I think the APIs ar eneeded for conversion in both directions. Sasha will be able to tell more when he gets back in the office tomorrow (it's getting late in Europe now :) ).
I presume you can try with the OpenOffice APIs in the mean time, but I doubt this will work.

Regards,
Stefan
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Convert Error

Post by DolphinMann »

I just did actually, they work so far :) I would be interested to know exactly what libraries are required so our company can see if this is something we are legally allowed to deploy, which may be possible as Open Office is open source and it seems to work thus far. Though I will test more extensively today.

I look forward to hearing from Sasha, thank you.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert Error

Post by Sasha - Tracker Dev Team »

Hello DoplhinMann,

Office to PDF conversion requires an installed office of 2007 version and higher with the XPS Add-in included. The reason for this is that we are converting the office files to the XPS format and then converting it to PDF.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Convert Error

Post by DolphinMann »

Thank you Sasha,

Is there a list of exactly what files you reference, so they could be included with my installer, eliminating the need for a microsoft office installation?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Convert Error

Post by Sasha - Tracker Dev Team »

Hello DoplhinMann,

Here's what we have found on forums:
You can't use the Office Automation (create a COM object and launch the conversion method) without a previously installed MS Office. And even if you do manage doing that then this will be a violation of the MS Office's End-User Agreement because this would allow creating a wrapper that would use all of the available COM method practically making a Office-like product.

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