Interface of the Investintech PDF Viewer Control is exposed through its methods. In this section you will find details about each method: prototype, description, parameters, return value, how to call a method and some examples of using methods.
OpenPDF
GetPageCount
GetCurrentPage
GoToPage
GetCurrentZoomRatio
SetZoom
RotateView
AboutBox
ClosePDF
unsigned char OpenPDF(LPCTSTR fileName, LPCTSTR openWithPassword)
The OpenPDF() method opens a PDF file.
Non zero value if file is opened successfully, zero otherwise.
CFrameWnd* parentWnd = new CFrameWnd();
static char BASED_CODE szFilter[] = "PDF Files (*.pdf)|*.pdf";
CString strPathName;
CFileDialog dlg(true, "pdf", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this, 0);
if ( IDCANCEL == dlg.DoModal() )
return;
strPathName = dlg.GetPathName();
//create a viewer control dynamically
CDInvestintechPDFViewerControl* pViewer = new CDInvestintechPDFViewerControl();
CRect rect;
GetClientRect(&rect);
// create a view to occupy the client area of the frame
if ( !pViewer->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, rect, parentWnd, AFX_IDW_PANE_FIRST, NULL) )
else
unsigned char GetPageCount()
The GetPageCount() method counts number of pages in PDF file.
None.
Total number of pages in PDF file.
unsigned long GetCurrentPage()
The GetCurrentPage() method is used to obtain page number of currently viewed page in PDF file.
None.
Page number of currently viewed page.
unsigned char GoToPage( unsigned long pageNumber)
The GoToPage() method is used to go directly to some page in PDF file.
Non zero value if PDF file has at least as many pages as pageNumber, zero otherwise.
//assuming that CDInvestintechPDFViewerControl* pViewer is successfully created //and some PDF file is opened
unsigned char numberOfPages;
unsigned long pageNumber = 42;
numberOfPages = pViewer->GetPageCount();
if (pageToGo <= numberOfPages)
pViewer->GoToPage(pageNumber);
else
MessageBox("There is no page 42 in this PDF.");
double GetCurrentZoomRatio()
The GetCurrentZoomRatio() method gets current zoom ratio of PDF file.
None.
Current zoom ratio of PDF file as floating point double value. For example, if zoom is set to 75%, returned value will be 0.75 and if zoom is set to 200%, returned value will be 2.00.
unsigned char SetZoom(LPCTSTR zoomRationOrDescription)
The SetZoom() method sets desired zoom on PDF file.
Non zero value if zoom ratio is set successfully, zero otherwise.
//assuming that CDInvestintechPDFViewerControl* pViewer is successfully created //and some PDF file is opened
double currentZoomRatio;
Cstring zoomDescription;
currentZoomRatio = pViewer->GetCurrentZoomRatio();
strZoom.Format("%2.2f%%", currentZoomRatio*2);
if (pViewer->SetZoom(strZoom) != 0)
//zoom is successfully doubled
currentZoomRatio = pViewer->GetCurrentZoomRatio();
unsigned char RotateView(short rotateViewDegrees)
The RotateView() method rotates PDF file.
Non zero value if file is rotated successfully, zero otherwise.
void AboutBox()
The AboutBox() method displays information window about InvestintechPDFViewerControl.
None.
None.
CDInvestintechPDFViewerControl* pViewer = new CDInvestintechPDFViewerControl();
pViewer->AboutBox();
unsigned char ClosePDF()
The ClosePDF() method closes a PDF file.
None.
Non zero value if file is closed successfully, zero otherwise.
//assuming that CDInvestintechPDFViewerControl* pViewer is successfully created //and some PDF file is opened
if (pViewer->ClosePDF() != 0)
MessageBox("PDF is successfully closed!");
Convert PDF to Excel, Word and More with Able2Extract 7.0!
Able2Extract Professional - Convert Scanned PDF-OCR to Word, Excel + more.
Convert PDF to Word with Able2Doc 6.0.
Able2Doc Professional - PDF to Word Converter, including scanned PDF conversion.
Sonic PDF Creator - Create PDF files from any Windows application.