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
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
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.