// PDFCompDemoDoc.cpp : implementation of the CPDFCompDemoDoc class // #include "stdafx.h" #include "PDFCompDemo.h" #include "PDFCompDemoDoc.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern L_VOID PDFCompError(HWND hwnd, L_INT nCode, L_TCHAR* pTitle, L_TCHAR* pFilename); ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc IMPLEMENT_DYNCREATE(CPDFCompDemoDoc, CDocument) BEGIN_MESSAGE_MAP(CPDFCompDemoDoc, CDocument) //{{AFX_MSG_MAP(CPDFCompDemoDoc) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc construction/destruction CPDFCompDemoDoc::CPDFCompDemoDoc() { // TODO: add one-time construction code here memset(&m_PDFCompSettings, 0, sizeof(m_PDFCompSettings)); m_PDFCompSettings.m_n1Bit = 5; m_PDFCompSettings.m_n2Bit = 0; m_PDFCompSettings.m_nPict = 5; m_PDFCompSettings.m_bCheckBackground = FALSE; m_PDFCompSettings.m_nSeg = 1; m_PDFCompSettings.m_nQFactor = 50; m_PDFCompSettings.nPageNumber= -1; } CPDFCompDemoDoc::~CPDFCompDemoDoc() { } BOOL CPDFCompDemoDoc::OnNewDocument() { static int i=0; if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) if(i>=1) return TRUE; else { i++; return FALSE; } } ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc serialization void CPDFCompDemoDoc::Serialize(CArchive& ar) { CFile *pf; pf = ar.GetFile(); if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc diagnostics #ifdef _DEBUG void CPDFCompDemoDoc::AssertValid() const { CDocument::AssertValid(); } void CPDFCompDemoDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc commands BOOL CPDFCompDemoDoc::OnOpenDocument(LPCTSTR lpszPathName) { L_INT nRet; CPDFCompDemoApp * pApp = (CPDFCompDemoApp *)AfxGetApp(); if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; // TODO: Add your specialized creation code here nRet = L_LoadBitmap((LPTSTR)lpszPathName, &m_LeadBitmap, sizeof(m_LeadBitmap), 0, ORDER_BGRORGRAY , &pApp->m_LoadFileOption, NULL); if(SUCCESS != nRet) { if(nRet == ERROR_PDF_BAD_INITIALIZATION_FILES) { if( IDYES == MessageBox( AfxGetMainWnd()->m_hWnd, TEXT("LEADTOOLS PDF plugin is not found, do you want to download the plugin now?"), TEXT("Open file"),MB_ICONEXCLAMATION | MB_YESNO)) ShellExecute(AfxGetMainWnd()->m_hWnd, TEXT("open"), TEXT("http://www.leadtools.com/ReleaseDownloads/v14/LEADTOOLSPDFRuntime.exe"), NULL, NULL, SW_SHOWNORMAL); } else PDFCompError(AfxGetApp()->m_pMainWnd->m_hWnd, nRet, TEXT("PDFComp Demo"), TEXT("")); return FALSE; } return TRUE; } void CPDFCompDemoDoc::OnCloseDocument() { // TODO: Add your specialized code here and/or call the base class if( m_LeadBitmap.Flags.Allocated ) L_FreeBitmap( &m_LeadBitmap ); CPDFCompDemoApp * pApp = (CPDFCompDemoApp *)AfxGetApp(); if(m_PDFCompSettings.bAdded == TRUE) pApp->m_nAddedDocCount--; CDocument::OnCloseDocument(); }