当前位置: 首页>>代码示例>>C++>>正文


C++ CPDF_Page::ParseContent方法代码示例

本文整理汇总了C++中CPDF_Page::ParseContent方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Page::ParseContent方法的具体用法?C++ CPDF_Page::ParseContent怎么用?C++ CPDF_Page::ParseContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPDF_Page的用法示例。


在下文中一共展示了CPDF_Page::ParseContent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CPDFDocumentFromFPDFDocument

DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
                                         int page_index,
                                         double width,
                                         double height) {
  CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
  if (!pDoc)
    return nullptr;

  if (page_index < 0)
    page_index = 0;
  if (pDoc->GetPageCount() < page_index)
    page_index = pDoc->GetPageCount();

  CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);
  if (!pPageDict)
    return NULL;
  CPDF_Array* pMediaBoxArray = new CPDF_Array;
  pMediaBoxArray->Add(new CPDF_Number(0));
  pMediaBoxArray->Add(new CPDF_Number(0));
  pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width)));
  pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height)));

  pPageDict->SetAt("MediaBox", pMediaBoxArray);
  pPageDict->SetAt("Rotate", new CPDF_Number(0));
  pPageDict->SetAt("Resources", new CPDF_Dictionary);

  CPDF_Page* pPage = new CPDF_Page;
  pPage->Load(pDoc, pPageDict);
  pPage->ParseContent();

  return pPage;
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例2: PDF_GetPageText_Unicode

void PDF_GetPageText_Unicode(CFX_WideStringArray& lines, CPDF_Document* pDoc, CPDF_Dictionary* pPage,
                             int iMinWidth, FX_DWORD flags)
{
    lines.RemoveAll();
    if (pPage == NULL) {
        return;
    }
    CPDF_Page page;
    page.Load(pDoc, pPage);
    CPDF_ParseOptions options;
    options.m_bTextOnly = TRUE;
    options.m_bSeparateForm = FALSE;
    page.ParseContent(&options);
    CFX_FloatRect page_bbox = page.GetPageBBox();
    if (flags & PDF2TXT_AUTO_ROTATE) {
        CheckRotate(page, page_bbox);
    }
    CTextPage texts;
    texts.m_bAutoWidth = flags & PDF2TXT_AUTO_WIDTH;
    texts.m_bKeepColumn = flags & PDF2TXT_KEEP_COLUMN;
    texts.m_bBreakSpace = TRUE;
    FX_POSITION pos = page.GetFirstObjectPosition();
    while (pos) {
        CPDF_PageObject* pObject = page.GetNextObject(pos);
        if (!(flags & PDF2TXT_INCLUDE_INVISIBLE)) {
            CFX_FloatRect rect(pObject->m_Left, pObject->m_Bottom, pObject->m_Right, pObject->m_Top);
            if (!page_bbox.Contains(rect)) {
                continue;
            }
        }
        texts.ProcessObject(pObject);
    }
    texts.WriteOutput(lines, iMinWidth);
}
开发者ID:151706061,项目名称:PDFium,代码行数:34,代码来源:fpdf_text.cpp

示例3: GetContentsRect

FX_BOOL GetContentsRect( CPDF_Document * pDoc, CPDF_Dictionary* pDict, CPDF_RectArray * pRectArray )
{
    CPDF_Page* pPDFPage = FX_NEW CPDF_Page;
    pPDFPage->Load( pDoc, pDict, FALSE );
    pPDFPage->ParseContent();

    FX_POSITION pos = pPDFPage->GetFirstObjectPosition();
    
    while (pos)
    {
        CPDF_PageObject* pPageObject = pPDFPage->GetNextObject(pos);
        if (!pPageObject)continue;
        
        CPDF_Rect rc;
        rc.left = pPageObject->m_Left;
        rc.right = pPageObject->m_Right;
        rc.bottom = pPageObject->m_Bottom;
        rc.top = pPageObject->m_Top;
        
        if (IsValiableRect(rc, pDict->GetRect("MediaBox")))
        {
            pRectArray->Add(rc);
        }
    }
    
    delete pPDFPage;
    return TRUE;
}
开发者ID:azunite,项目名称:pdfium_ch,代码行数:28,代码来源:fpdf_flatten.cpp

示例4:

DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index, double width, double height)
{
    if (!document)
        return NULL;

//	CPDF_Parser* pParser = (CPDF_Parser*)document;
    CPDF_Document* pDoc = (CPDF_Document*)document;
    if(page_index < 0)
        page_index = 0;
    if(pDoc->GetPageCount()<page_index)
        page_index = pDoc->GetPageCount();
//	if (page_index < 0 || page_index >= pDoc->GetPageCount()) 
//		return NULL;

    CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);
    if(!pPageDict)
        return NULL;
    CPDF_Array* pMediaBoxArray = FX_NEW CPDF_Array;
    pMediaBoxArray->Add(FX_NEW CPDF_Number(0));
    pMediaBoxArray->Add(FX_NEW CPDF_Number(0));
    pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(width)));
    pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(height)));

    pPageDict->SetAt("MediaBox", pMediaBoxArray);
    pPageDict->SetAt("Rotate", FX_NEW CPDF_Number(0));
    pPageDict->SetAt("Resources", FX_NEW CPDF_Dictionary);

    CPDF_Page* pPage = FX_NEW CPDF_Page;
    pPage->Load(pDoc,pPageDict);
    pPage->ParseContent();

    return pPage;
}
开发者ID:azunite,项目名称:pdfium_ch,代码行数:33,代码来源:fpdfeditpage.cpp

示例5: PDF_GetTextStream_Unicode

void PDF_GetTextStream_Unicode(CFX_WideTextBuf& buffer, CPDF_Document* pDoc, CPDF_Dictionary* pPage, FX_DWORD flags)
{
    buffer.EstimateSize(0, 10240);
    CPDF_Page page;
    page.Load(pDoc, pPage);
    CPDF_ParseOptions options;
    options.m_bTextOnly = TRUE;
    options.m_bSeparateForm = FALSE;
    page.ParseContent(&options);
    _PDF_GetTextStream_Unicode(buffer, &page, TRUE, NULL);
}
开发者ID:151706061,项目名称:PDFium,代码行数:11,代码来源:fpdf_text.cpp

示例6:

DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index)
{
    if (document == NULL) return NULL;
    if (page_index < 0 || page_index >= FPDF_GetPageCount(document)) return NULL;

    CPDF_Document* pDoc = (CPDF_Document*)document;
    if (pDoc == NULL) return NULL;
    CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
    if (pDict == NULL) return NULL;
    CPDF_Page* pPage = new CPDF_Page;
    pPage->Load(pDoc, pDict);
    pPage->ParseContent();
    return pPage;
}
开发者ID:mariospr,项目名称:chromium-browser,代码行数:14,代码来源:fpdfview.cpp

示例7: 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;
}
开发者ID:mcanthony,项目名称:libpdf,代码行数:46,代码来源:Document.cpp

示例8: catch

DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index)
{
    if (document == NULL) return NULL;
    if (page_index < 0 || page_index >= FPDF_GetPageCount(document)) return NULL;
//	CPDF_Parser* pParser = (CPDF_Parser*)document;
    CPDF_Document* pDoc = (CPDF_Document*)document;
    if (pDoc == NULL) return NULL;
    CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
    if (pDict == NULL) return NULL;
    CPDF_Page* pPage = FX_NEW CPDF_Page;
    pPage->Load(pDoc, pDict);
    try {
        pPage->ParseContent();
    }
    catch (...) {
        delete pPage;
        return NULL;
    }

//	CheckUnSupportError(pDoc, 0);

    return pPage;
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例9: PDF_GetFirstTextLine_Unicode

CFX_WideString PDF_GetFirstTextLine_Unicode(CPDF_Document* pDoc, CPDF_Dictionary* pPage)
{
    CFX_WideTextBuf buffer;
    buffer.EstimateSize(0, 1024);
    CPDF_Page page;
    page.Load(pDoc, pPage);
    CPDF_ParseOptions options;
    options.m_bTextOnly = TRUE;
    options.m_bSeparateForm = FALSE;
    page.ParseContent(&options);
    CPDF_TextStream textstream(buffer, FALSE, NULL);
    FX_POSITION pos = page.GetFirstObjectPosition();
    while (pos) {
        CPDF_PageObject* pObject = page.GetNextObject(pos);
        if (pObject->m_Type != PDFPAGE_TEXT) {
            continue;
        }
        if (textstream.ProcessObject((CPDF_TextObject*)pObject, TRUE)) {
            break;
        }
    }
    return buffer.GetWideString();
}
开发者ID:151706061,项目名称:PDFium,代码行数:23,代码来源:fpdf_text_search.cpp

示例10: 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;
}
开发者ID:mcanthony,项目名称:libpdf,代码行数:62,代码来源:Document.cpp


注:本文中的CPDF_Page::ParseContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。