How to use PDF Viewer OCX (ActiveX Control) to view the PDF file from memory?

Is there any complete reference/documentation (website, Document or CHM-file) to the PDFView ActiveX control?

I have downloaded the free trial version of the control, to demo the features of the control to our customer, and would like to use the OpenPDFFromMem - method, but as I see is there only some examples to illustrate some of the features of the control.

Best regards
Customer
--------------------------------------------------
Thanks for your message, OpenPDFFromMem() function does open and view the PDF file from memory,

BOOL OpenPDFFromMem(long lpPDFData, long nPDFDataLen, LPCTSTR lpszUserPwd, LPCTSTR lpszOwnerPwd);

Please refer to following C++ example for this function,

void CSampleDlgDlg::OnBnClickedButtonOpen()

{

    char szFilter[] ="PDF File (*.pdf)|*.pdf||";

    CFileDialog  fSaveDlg(TRUE,"","",

        OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,

        szFilter,this);

    if(fSaveDlg.DoModal() != IDOK)

        return;

    CString strFileName = fSaveDlg.GetPathName();

 

#if 0

    m_PDFViewer.OpenPDF(strFileName, "", "");

   

#else

    //----------------------------------------------------------------

    //

    // Memory Open

    //

    //----------------------------------------------------------------

    CString tmp = _T( "" );

    HANDLE          hFile = ::CreateFile( strFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );

    if ( hFile == INVALID_HANDLE_VALUE )

    {

        tmp.Format( _T( "CreateFile ERROR [CODE = %d]" ), GetLastError() );

        AfxMessageBox( tmp );

        return;

    }

 

    DWORD            dwRead;

    DWORD            dwSize = ::GetFileSize( hFile, NULL );

    BYTE*              pBuffer = new BYTE[ dwSize ];

    memset(pBuffer, 0, dwSize);

 

    if ( !::ReadFile( hFile, (LPVOID)pBuffer, dwSize, &dwRead, NULL ) )

    {

        tmp.Format( _T( "ReadFile ERROR [CODE = %d]" ), GetLastError() );

        AfxMessageBox( tmp );

 

        ::CloseHandle( hFile );

        return;

    }

 

    ::CloseHandle( hFile );

 

    BOOL bRes = m_PDFViewer.OpenPDFFromMem((long)pBuffer, dwSize, "", "" );

    if ( !bRes )

    {

        AfxMessageBox( _T( "Open error!" ) );

    }

#endif

 

    CString csCurrentPage = _T( "" );

    csCurrentPage.Format( _T( "Current Page : %d" ), m_PDFViewer.GetCurrentPage() );

    AfxMessageBox( csCurrentPage );

 

    m_PDFViewer.SetMsgCallbackWnd((long)m_hWnd);

}

 

VeryDOC

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!