Page 1 of 1

Error when try to view image files (Tiff or BMP)

Posted: Wed Mar 22, 2017 2:28 am
by visual approvals
Hi Guys

windows 10 ,framework 4.6.1 , win 64 dll ver 6.0.319.0

Im using the following to view a Tiff or bmp file in the viewer but am getting errors

public void OpenPdfDoc(string pFileName, string Display = "All")
{
if (pFileName != "")
{
try
{

axPXV_Control1.Inst.Settings["Docs.AutoSyncDocPanesLayouts"].v = false;
axPXV_Control1.Inst.FireAppPrefsChanged(PDFXEdit.PXV_AppPrefsChanges.PXV_AppPrefsChange_Documents);

PDFXEdit.IPXV_MainFrame secondMainFrame = axPXV_Control1.Inst.MainFrm[SupportClass.FrameCount];
secondMainFrame.OpenDocFrom(pxcInst.OpenDocumentFromFile(@CurrentPdfFilePath.ToString(), null));

if (axPXV_Control1.Doc != null)
{ PageCount = axPXV_Control1.Doc.CoreDoc.Pages.Count;
axPXV_Control1.Doc.ActiveView.Panes.Show(axPXV_Control1.Doc.ActiveView.PageThumbsView);


PDFXEdit.IUIX_ScrollContainer scrollContainer = GetParentScrollContainer(axPXV_Control1.Doc.ActiveView.PageThumbsView.Obj);
PDFXEdit.IUIX_CmdLine line = scrollContainer.CmdPaneTop[0];
PDFXEdit.IUIX_CmdBar bar = line[0];
PDFXEdit.IUIX_CmdItem item = bar.FindFirstItemByCmdName("cmd.delete");
item.Delete();

axPXV_Control1.Doc.ActiveView.Panes.Hide(axPXV_Control1.Doc.ActiveView.PagesView);

}

// axPXV_Control1.Inst.ExecUICmd("cmd.zoom.level.fitPage");


}
catch (Exception ex)
{
ShowErrorMessage(System.Runtime.InteropServices.Marshal.GetHRForException(ex));
}
}
}

The error occurs at secondMainFrame.OpenDocFrom(pxcInst.OpenDocumentFromFile(@CurrentPdfFilePath.ToString(), null));
ex is Exception from HRESULT: 0x82140002



PDF files dont cause any issues

Re: Error when try to view image files (Tiff or BMP)

Posted: Wed Mar 22, 2017 7:29 am
by Sasha - Tracker Dev Team
Hello visual approvals,

The exception occurs, because you are trying to open the image file on the core level and then pass the IPXC_Document to the editor's level. Only the editor's level uses converters in the OpenDoc methods. In your case, try using this method:
https://sdkhelp.pdf-xchange.com/vie ... ocFromPath

Cheers,
Alex

Re: Error when try to view image files (Tiff or BMP)

Posted: Thu Mar 23, 2017 3:14 am
by visual approvals
Thanks for the reply,
I did spend some time experimenting with the method you advise but could not come to grips with it in a C# context

Are you able to provide some sample code in C# i could work from :-)
Thanks

Andre

Re: Error when try to view image files (Tiff or BMP)

Posted: Thu Mar 23, 2017 7:10 am
by Sasha - Tracker Dev Team
Hello Andre,

You simply should change this:

Code: Select all

secondMainFrame.OpenDocFrom(pxcInst.OpenDocumentFromFile(@CurrentPdfFilePath.ToString(), null));
To this:

Code: Select all

secondMainFrame.OpenDocFromPath(@CurrentPdfFilePath.ToString(), null);
Cheers,
Alex

Re: Error when try to view image files (Tiff or BMP)

Posted: Thu Mar 23, 2017 7:40 pm
by visual approvals
Hi Alex
Thanks for the quick reply.
I did try that but get an invalid parameter exception.
Let me review my code and Ill have another go
Andre

Re: Error when try to view image files (Tiff or BMP)  SOLVED

Posted: Thu Mar 23, 2017 7:58 pm
by Sasha - Tracker Dev Team
Hello Andre,

Additionally, you can use this method, to know what the error is exactly: https://sdkhelp.pdf-xchange.com/vie ... xtFromHRes

Cheers,
Alex

Re: Error when try to view image files (Tiff or BMP)

Posted: Thu Mar 23, 2017 10:12 pm
by visual approvals
Hi Alex
All good...got it sorted...thanks for your help :-)
Andre

Re: Error when try to view image files (Tiff or BMP)

Posted: Fri Mar 24, 2017 6:31 am
by Sasha - Tracker Dev Team
:)