Invalid Pointer

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
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Invalid Pointer

Post by DolphinMann »

I am getting the follow message: "Error [System]: Invalid pointer." on the line:
IPXC_Document doc = convertByExtension[Path.GetExtension(fileName).ToUpper()].Convert(((PXV_Inst)viewerInstance), destFile);

When attempting to convert a DOC/DOCX file, but only those types of files with the following code segment(s). It seems that converting text/images work fine, but Office documents DOC(X)/XLS(X) do not. I'm sure there is some other type of error happening here but how would I figure out what that is?

Code: Select all

                        convertByExtension = new Dictionary<string, IPXV_ImportConverter>();

                        for (uint count = 0; count < viewerInstance.ImportConvertersCount; count++)
                        {
                            string[] extensions = viewerInstance.ImportConverter[count].Extensions.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                            foreach (string s in extensions)
                            {
                                if (!corePDFConversionExtensions.Contains(s.Replace("*", "").ToUpper()))
                                {
                                    corePDFConversionExtensions.Add(s.Replace("*", "").ToUpper());
                                    convertByExtension.Add(s.Replace("*", "").ToUpper(), viewerInstance.ImportConverter[count]);
                                    Logger.Log("Added: " + s.Replace("*", "").ToUpper() + " to possible PDF Conversion types", 5);
                                }
                            }
                        }

Code: Select all

                if (viewerInstance == null)
                {
                    try
                    {
                        viewerInstance = new PXV_Inst();
                        viewerInstance.Init(null, DolphinCorePDF.devKey);

                        Logger.Log("PDF Converter Object Initialized", 5);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Error During Init for PDFTools", ex, 1);
                        int hr = Marshal.GetHRForException(ex);
                        PDFTools.LogErrMsg(hr);
                    }
                }

                if (auxInst == null)
                {
                    auxInst = (IAUX_Inst)viewerInstance.GetExtension("AUX");
                }
                            ICab AParams;
                            ICabNode AOpts;

                            string tempFileName = outputFileName;
                            AParams = viewerInstance.CreateOpenDocParams();
                            AOpts = AParams.Root;
                            AOpts.SetBool("NoProgress", true);
                            AOpts.Flags &= ~((uint)AFS_OpenFileFlags.AFS_OpenFile_AllowUI);

                            IAFS_Inst fsInst = (IAFS_Inst)viewerInstance.GetExtension("AFS");
                            IAFS_Name fileToOpen = fsInst.DefaultFileSys.StringToName(fileName);
                            int openFlags = ((int)AOpts.Flags);
                            IAFS_File destFile = fsInst.DefaultFileSys.OpenFile(fileToOpen, openFlags);
                            IPXC_Document doc = convertByExtension[Path.GetExtension(fileName).ToUpper()].Convert(((PXV_Inst)viewerInstance), destFile);
                            doc.WriteToFile(tempFileName);
                            doc.Close();
                            doc = null;
                            destFile.Close();
                            destFile = null;
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Invalid Pointer

Post by DolphinMann »

I should also add that if I do not load the document via code, but via the standard "Open File" dialog in the front-end the same document loads and converts. It is something with my method of opening programmatically
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Invalid Pointer

Post by Sasha - Tracker Dev Team »

Hello DolphinMann,

Do you have a MSOffice >= 2007 preinstalled on your machine?
Also, try simplifying your code:

Code: Select all

string extension = "conv.imp.office.doc";
PDFXEdit.IPXV_ImportConverter cov = null;
for (int i = 0; i < pdfCtl.Inst.ImportConvertersCount; i++)
{
	cov = pdfCtl.Inst.get_ImportConverter((uint)i);
	if (cov.ID == extension)
		break;
}
if ((cov != null) && (cov.ID == extension))
{
	PDFXEdit.IAFS_Inst fsInst = (PDFXEdit.IAFS_Inst)pdfCtl.Inst.GetExtension("AFS");
	PDFXEdit.IAFS_Name name = fsInst.DefaultFileSys.StringToName(@"C:\Users\polar_000\Documents\S-1.docx");
	int openFileFlags = (int)(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read | PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_ShareRead);

	PDFXEdit.IAFS_File destFile = fsInst.DefaultFileSys.OpenFile(name, openFileFlags);
	PDFXEdit.PXV_FmtCheckResult ret = cov.CheckFormat(pdfCtl.Inst, destFile);
	PDFXEdit.ICab cab = pdfCtl.Inst.GetFormatConverterParams(true, extension);
	PDFXEdit.IPXC_Document doc = cov.Convert(pdfCtl.Inst, destFile);
	pdfCtl.OpenDocFrom(doc);
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Invalid Pointer

Post by DolphinMann »

Alex,

Thank you. That indirectly did help! I am not using the PDFControl as this is a background application where I just create a viewer instance but it still worked.

It seems the problem was with my "openFileFlags", it simply does not like the way I was using the suppress UI flag. Is there any way to get it so the conversion popup window does not display?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Invalid Pointer

Post by Sasha - Tracker Dev Team »

Hello DoplhinMann,

There is no way to hide the office conversion window - you can use the search on forums for similar topic.

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

Re: Invalid Pointer

Post by DolphinMann »

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

Re: Invalid Pointer

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply