Page 1 of 1

IPXV_ImportConverter.Convert throws NullReferenceException

Posted: Sat May 08, 2021 7:36 pm
by HiThere44
Hello,
I am currently trying to convert image files to PDF format in order to use OCR afterwards.
However, I have encountered the problem that every import converter throws a NullReferenceException in the ".Convert" method. My implementation looks like this:

This method determines the correct import converter:

Code: Select all

Public Function GetImportConverter(fileExtension As String) As IPXV_ImportConverter
        Select Case fileExtension.ToLower()
            Case ".tiff"
                Return _importConverters.Find(Function(ic) ic.ID = "conv.imp.image.tiff")
            Case ".tif"
                Return _importConverters.Find(Function(ic) ic.ID = "conv.imp.image.tiff")
            Case ".png"
                Return _importConverters.Find(Function(ic) ic.ID = "conv.imp.image.png")
            Case ".jpeg"
                Return _importConverters.Find(Function(ic) ic.ID = "conv.imp.image.jpeg")
            Case ".jpg"
                Return _importConverters.Find(Function(ic) ic.ID = "conv.imp.image.jpeg")
            Case ".bmp"
                Return _importConverters.Find(Function(ic) ic.ID = "conv.imp.image.bmp")
            Case Else
                Throw New InvalidOperationException("File format is not supported!")
        End Select
    End Function
This method uses the import converter:

Code: Select all

Private Function OpenNotPDFFileAsIPXC_Document(filepath As String) As IPXC_Document
            Dim iConverter = New ImportConverterHelper(_pdfX.pxvInst) _
                .GetImportConverter(Path.GetExtension(filepath))
            Dim afsName = _pdfX.fsInst.DefaultFileSys.StringToName(filepath)
            Dim chosenFile = _pdfX.fsInst.DefaultFileSys.OpenFile(afsName, _readonlyFileFlags)
            Dim savingFlags = CUInt(PXV_DocSaveFlags.PXV_DocSave_NoProgress Or PXV_DocSaveFlags.PXV_DocSave_NoOverwritePrompt)
            Return iConverter.Convert(_pdfX.pxvInst, chosenFile, savingFlags)
        End Function
The error description of IAUX_Inst.FormatHRESULT is:
Error [System]: Invalid pointer

Does anyone have any ideas or experience with import converters? I think I have checked everything from my side. None of these objects have a null value. The import converter was found and also the bmp and jpeg files could be opened.
Meanwhile, I'll keep looking to see what I might have missed. But I would appreciate any help of course.

Re: IPXV_ImportConverter.Convert throws NullReferenceException

Posted: Tue May 11, 2021 3:24 pm
by Sasha - Tracker Dev Team
Hello HiThere44,

Does every one of these result in an exception?
Can you simplify your sample for the single converter only?
Have you seen this sample?
viewtopic.php?f=66&t=29629&p=117375&hil ... er#p117011

Cheers,
Alex

Re: IPXV_ImportConverter.Convert throws NullReferenceException

Posted: Wed May 19, 2021 8:50 am
by HiThere44
Thanks for your response, Sasha.

I have already seen the post you linked. I do it essentially no different than described here.
So far I have seen this problem with the following file formats: .png, .jpg, .jpeg, .tiff.

The cause of this problem, it seems, is that I am instantiating PXV_Inst in a .NET Framework class library.
However, if I do the instantiation in a Winforms application, then the import using the ImportConverter also works.

Now the question is: Why does the ImportConverter not work in a class library?

Re: IPXV_ImportConverter.Convert throws NullReferenceException

Posted: Wed May 19, 2021 9:10 am
by HiThere44
Okay, wait... It works with the PDFXEditCore.x64.dll. But it does not work with the PDFXEditCore.x86.dll.
Thats it.

Re: IPXV_ImportConverter.Convert throws NullReferenceException

Posted: Wed May 19, 2021 9:44 am
by Sasha - Tracker Dev Team
Hello HiThere44,

Well we do not recommend using the x86 for .Net applications, due to high memory consumptions - thus using the x64 would be optimal.

Cheers,
Alex