Unable to convert image files (png,jpg) to tiff

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
chavas
User
Posts: 141
Joined: Tue Mar 15, 2016 12:21 pm

Unable to convert image files (png,jpg) to tiff

Post by chavas »

Hi,


I am loading pdfxchange editor using manifest in my project which is a x64 application on DotnNet6.0
It works fine but I am not able to convert image files to tiff files. here is the code -
Dim Doc As PDFXEdit.IPXC_Document
If data.sDoc.ToLower.EndsWith(".pdf") Then
Doc = m_pxcInst.OpenDocumentFromFile(data.sDoc, Nothing)
blnconvadd = True
Else

Try
For i As Integer = 0 To m_Inst.ImportConvertersCount - 1

Dim iConv As PDFXEdit.IPXV_ImportConverter = m_Inst.ImportConverter(i)
Dim fsInst As PDFXEdit.IAFS_Inst = CType(m_Inst.GetExtension("AFS"), PDFXEdit.IAFS_Inst)
Dim name As PDFXEdit.IAFS_Name = fsInst.DefaultFileSys.StringToName(data.sDoc)
Dim openFileFlags As Int16 = CInt(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read Or PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_ShareRead)
Dim destFile As PDFXEdit.IAFS_File = fsInst.DefaultFileSys.OpenFile(name, openFileFlags)

If (iConv.ID.Equals("conv.imp.image.tiff") And (data.sDoc.ToLower.EndsWith(".tif") Or data.sDoc.ToLower.EndsWith(".tiff"))) Then
Doc = iConv.Convert(CType(m_Inst, PDFXEdit.PXV_Inst), destFile)
blnconvadd = True
Exit For
ElseIf (iConv.ID.Equals("conv.imp.image.jpeg") And data.sDoc.ToLower.EndsWith(".jpg")) Then

Doc = iConv.Convert(CType(m_Inst, PDFXEdit.PXV_Inst), destFile)

blnconvadd = True
Exit For
ElseIf (iConv.ID.Equals("conv.imp.image.bmp") And data.sDoc.ToLower.EndsWith(".bmp")) Then

Doc = iConv.Convert(CType(m_Inst, PDFXEdit.PXV_Inst), destFile)
blnconvadd = True
Exit For
ElseIf (iConv.ID.Equals("conv.imp.image.png") And data.sDoc.ToLower.EndsWith(".png")) Then

Doc = iConv.Convert(CType(m_Inst, PDFXEdit.PXV_Inst), destFile)

blnconvadd = True
Exit For
Else

End If
Next
Catch eImp As Exception
If m_Inst IsNot Nothing Then
Dim auxInst As PDFXEdit.IAUX_Inst = m_Inst.GetExtension("AUX")
Dim msg As String = auxInst.FormatHRESULT(eImp.HResult)
WriteLogLocal(LogLocation.ScanApp, msg)
End If
End Try

This works fine for x86 application with PDFXEditCore.x86.dll is registered but not in my application.
I have tried loading plugins, but not able to get it working.
I am getting error- Error [System]: Invalid pointer.
I am using version-9.1.356

Please guide

Rgds
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Unable to convert image files (png,jpg) to tiff

Post by zarkogajic »

Hi,

You are trying to convert image files to PDF?

At what line does your code raise "Invalid pointer"?

-žarko
chavas
User
Posts: 141
Joined: Tue Mar 15, 2016 12:21 pm

Re: Unable to convert image files (png,jpg) to tiff

Post by chavas »

Hi,

I am getting "Invalid Pointer" error at line-
Doc = iConv.Convert(CType(m_Inst, PDFXEdit.PXV_Inst), destFile)

I am using this operation-
m_nID = m_Inst.Str2ID("op.document.exportToImages", False)

Rgds
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Unable to convert image files (png,jpg) to tiff

Post by zarkogajic »

Hi,

change the code to (pseudo) to see if line "X=.." is causing this.

Code: Select all

X = CType(m_Inst, PDFXEdit.PXV_Inst)
Doc = iConv.Convert(X, destFile)
Note: you have multiple such lines in the code you pasted in the first post - so not clear which ImportConverter is "iConv".

Also, in your code (initial post) you have no mention of IOperation...

chavas
User
Posts: 141
Joined: Tue Mar 15, 2016 12:21 pm

Re: Unable to convert image files (png,jpg) to tiff

Post by chavas »

Hi,

Sorry for the confusion. here is my complete code again for your reference-

Dim m_Inst As PDFXEdit.PXV_Inst = Nothing
Dim m_pxcInst As PDFXEdit.IPXC_Inst
'''''Initialization code ... written when the application starts
m_Inst = New PDFXEdit.PXV_Inst()
m_Inst.Init(Nothing, licKey, Nothing, Nothing, Nothing, 0, Nothing)
ixcInst = CType(m_Inst.GetExtension("IXC"), PDFXEdit.IIXC_Inst)
m_pxcInst = CType(m_Inst.GetExtension("PXC"), PDFXEdit.IPXC_Inst)
IAUX_Inst = m_Inst.GetExtension("AUX")
m_nID = m_Inst.Str2ID("op.document.exportToImages", False)
m_Inst.StartLoadingPlugins()
m_Inst.AddPluginFromFile(Application.StartupPath & "\Plugins.x64\ConvertPDF.pvp")
m_Inst.AddPluginFromFile(Application.StartupPath & "\Plugins.x64\PDFOptimizer.pvp")
m_Inst.AddPluginFromFile(Application.StartupPath & "\Plugins.x64\ColorConvert.pvp")
m_Inst.AddPluginFromFile(Application.StartupPath & "\Plugins.x64\U3DPlugin.pvp")
m_Inst.AddPluginFromFile(Application.StartupPath & "\Plugins.x64\SanitizePlugin.pvp")
m_Inst.AddPluginFromFile(Application.StartupPath & "\Plugins.x64\FileOpenSH.pvp")
m_Inst.FinishLoadingPlugins()


'''CODE TO convert Jpg file to tiff
Dim Doc As PDFXEdit.IPXC_Document
For i As Integer = 0 To m_Inst.ImportConvertersCount - 1
Dim iConv As PDFXEdit.IPXV_ImportConverter = m_Inst.ImportConverter(i)
Dim fsInst As PDFXEdit.IAFS_Inst = CType(m_Inst.GetExtension("AFS"), PDFXEdit.IAFS_Inst)
Dim name As PDFXEdit.IAFS_Name = fsInst.DefaultFileSys.StringToName(Filenamepath)
Dim openFileFlags As Int16 = CInt(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read Or PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_ShareRead)
Dim destFile As PDFXEdit.IAFS_File = fsInst.DefaultFileSys.OpenFile(name, openFileFlags)
If (iConv.ID.Equals("conv.imp.image.jpeg") And (Filenamepath).ToLower.EndsWith(".jpg")) Then
Doc = iConv.Convert(CType(m_Inst, PDFXEdit.PXV_Inst), destFile) ****
blnconvadd = True
Exit For
end if
next

Dim OpExtDoc As PDFXEdit.IOperation = m_Inst.CreateOp(m_nID)
Dim Input As PDFXEdit.ICabNode = OpExtDoc.Params.Root("Input")
Input.Add().v = Doc
Dim options As PDFXEdit.ICabNode = OpExtDoc.Params.Root("Options")
options("PagesRange.Type").v = "All"
options("DestFolder").v = OutputfolderPath
options("ExportMode").v = "EveryToSinglePage"
options("Zoom").v = 150
options("ShowResultFolder").v = False
options("FileName").v = "_tmpImage%[AutoNumber]"
''Saving as tiff
Dim fmtParams As PDFXEdit.ICabNode = options("FormatParams")
''Compression type
fmtParams("COMP").v = 5
fmtParams("DPIX").v = 150
''Y DPI
fmtParams("DPIY").v = 150
''Image format
fmtParams("FMT").v = 1414088262
fmtParams("ITYP").v = 24
fmtParams("PRED").v = 1 ''Yes
''Thumbnail
fmtParams("THUM").v = 0 ''No

OpExtDoc.Do()

I am getting error at the line marked with **** and in bold. Pls note that the same code works with x86 dll which is registered but not working with manifest and x64 dll.

using the same m_inst I am also reading tiffs and converting them to pdf using operation- ("op.imagesToDoc") and that is working with out any issues. I am having issues with jpg, png, bmp , tiff files only.

I tried your suggestion still geting error at - "Doc = iConv.Convert(X, destFile)"

Rgds
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Unable to convert image files (png,jpg) to tiff

Post by zarkogajic »

Hi,

Disclaimer: I'm not official support here, just an SDK user as you are...

I would suggest you to extract only the relevant pieces of your code and ensure such a code block works with manifest in x86 and then in x64 (with or without manifest). You need just 5-6 lines of code to setup the Instance and get the "conv.imp.image.jpeg" converter.


I think plugins do not play a role when using import converter to convert JPG to PDF - so loading plugins part can be commented...

p.s.
Not a VB.Net dev so cannot help with real code ...

p.s.2
If you need to convert JPG to TIFF - why bother with PDFX? Why not use some dotNet class designed to do just that: convert image types.

-žarko
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Unable to convert image files (png,jpg) to tiff

Post by Tracker Supp-Stefan »

Hello zarkogajic,

Many thanks for the help!

Kind regards,
Stefan
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Unable to convert image files (png,jpg) to tiff

Post by Vasyl-Tracker Dev Team »

Hi, chavas.

We tried to reproduce it with our C# FullDemo example, in Free-Registration mode, but couldn't.
What error are you getting there?
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
chavas
User
Posts: 141
Joined: Tue Mar 15, 2016 12:21 pm

Re: Unable to convert image files (png,jpg) to tiff

Post by chavas »

Hi Vasyl,

I am getting "Invalid Pointer" error at line-
Doc = iConv.Convert(CType(m_Inst, PDFXEdit.PXV_Inst), destFile)

I am using this operation-
m_nID = m_Inst.Str2ID("op.document.exportToImages", False)

Pls note that this is working fine with x86 application where PDFXEditCore.x86.dll is registered. But not working in x64 build and using manifest file to load. In the same application (x64) I am using "op.imagesToDoc" operation and that is working.

Rgds
Charu
chavas
User
Posts: 141
Joined: Tue Mar 15, 2016 12:21 pm

Re: Unable to convert image files (png,jpg) to tiff

Post by chavas »

Hi Vasyl,

Any updates on my issue?

Rgds
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Unable to convert image files (png,jpg) to tiff

Post by Vasyl-Tracker Dev Team »

Sorry for the delay with that... Unfortunately, at the moment we cannot say exactly what is the reason of this issue. We were able to reproduce it once, on one machine only, but after some experiments(platform changed, clean/rebuild, reopen solution, etc) this problem magically disappeared! We will continue the investigation of that and let you know about the results...
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Post Reply