本文整理汇总了C++中CPDF_Page::StartParse方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Page::StartParse方法的具体用法?C++ CPDF_Page::StartParse怎么用?C++ CPDF_Page::StartParse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Page
的用法示例。
在下文中一共展示了CPDF_Page::StartParse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPageNumWords
FX_BOOL Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
ASSERT(m_pDocument != NULL);
if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
CPDF_Document* pDocument = m_pDocument->GetDocument();
ASSERT(pDocument != NULL);
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
{
sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
return FALSE;
}
CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
if (!pPageDict) return FALSE;
CPDF_Page page;
page.Load(pDocument, pPageDict);
page.StartParse();
page.ParseContent();
FX_POSITION pos = page.GetFirstObjectPosition();
int nWords = 0;
while (pos)
{
if (CPDF_PageObject* pPageObj = page.GetNextObject(pos))
{
if (pPageObj->m_Type == PDFPAGE_TEXT)
{
CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj;
nWords += CountWords(pTextObj);
}
}
}
vRet = nWords;
return TRUE;
}
示例2: getPageNthWord
FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
ASSERT(m_pDocument != NULL);
if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0;
bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true;
CPDF_Document* pDocument = m_pDocument->GetDocument();
if (!pDocument) return FALSE;
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
{
sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
return FALSE;
}
CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
if (!pPageDict) return FALSE;
CPDF_Page page;
page.Load(pDocument, pPageDict);
page.StartParse();
page.ParseContent();
FX_POSITION pos = page.GetFirstObjectPosition();
int nWords = 0;
CFX_WideString swRet;
while (pos)
{
if (CPDF_PageObject* pPageObj = page.GetNextObject(pos))
{
if (pPageObj->m_Type == PDFPAGE_TEXT)
{
int nObjWords = CountWords((CPDF_TextObject*)pPageObj);
if (nWords + nObjWords >= nWordNo)
{
swRet = GetObjWordStr((CPDF_TextObject*)pPageObj, nWordNo - nWords);
break;
}
nWords += nObjWords;
}
}
}
if (bStrip)
{
swRet.TrimLeft();
swRet.TrimRight();
}
vRet = swRet.c_str();
return TRUE;
}