IPXV_ImportConverter.Convert throws NullReferenceException

PDF-XChange Editor SDK for Developers

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

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
HiThere44
User
Posts: 5
Joined: Tue Apr 06, 2021 11:51 am

IPXV_ImportConverter.Convert throws NullReferenceException

Post by HiThere44 » Sat May 08, 2021 7:36 pm

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.

User avatar
Sasha - Tracker Dev Team
User
Posts: 5496
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXV_ImportConverter.Convert throws NullReferenceException

Post by Sasha - Tracker Dev Team » Tue May 11, 2021 3:24 pm

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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

HiThere44
User
Posts: 5
Joined: Tue Apr 06, 2021 11:51 am

Re: IPXV_ImportConverter.Convert throws NullReferenceException

Post by HiThere44 » Wed May 19, 2021 8:50 am

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?

HiThere44
User
Posts: 5
Joined: Tue Apr 06, 2021 11:51 am

Re: IPXV_ImportConverter.Convert throws NullReferenceException

Post by HiThere44 » Wed May 19, 2021 9:10 am

Okay, wait... It works with the PDFXEditCore.x64.dll. But it does not work with the PDFXEditCore.x86.dll.
Thats it.

User avatar
Sasha - Tracker Dev Team
User
Posts: 5496
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXV_ImportConverter.Convert throws NullReferenceException

Post by Sasha - Tracker Dev Team » Wed May 19, 2021 9:44 am

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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply