示例#1
0
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password)
{
	CPDF_Parser* pParser = new CPDF_Parser;
	pParser->SetPassword(password);
	CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size);
	FX_DWORD err_code = pParser->StartParse(pMemFile);
	if (err_code) {
		delete pParser;
		ProcessParseError(err_code);
		return NULL;
	}
	CPDF_Document * pDoc = NULL;
	pDoc = pParser?pParser->GetDocument():NULL;
	CheckUnSupportError(pDoc, err_code);
	return pParser->GetDocument();
}
示例#2
0
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BYTESTRING password)
{
    CPDF_Parser* pParser = FX_NEW CPDF_Parser;
    pParser->SetPassword(password);
    try {
        FX_DWORD err_code = pParser->StartParse((FX_LPCSTR)file_path);
        if (err_code) {
            delete pParser;
            ProcessParseError(err_code);
            return NULL;
        }
    }
    catch (...) {
        delete pParser;
        SetLastError(FPDF_ERR_UNKNOWN);
        return NULL;
    }
    return pParser->GetDocument();
}
示例#3
0
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password)
{
    CPDF_Parser* pParser = FX_NEW CPDF_Parser;
    pParser->SetPassword(password);
    CPDF_CustomAccess* pFile = FX_NEW CPDF_CustomAccess(pFileAccess);
    try {
        FX_DWORD err_code = pParser->StartParse(pFile);
        if (err_code) {
            delete pParser;
            ProcessParseError(err_code);
            return NULL;
        }
        CPDF_Document * pDoc = NULL;
        pDoc = pParser?pParser->GetDocument():NULL;
        CheckUnSupportError(pDoc, err_code);
    }
    catch (...) {
        delete pParser;
        SetLastError(FPDF_ERR_UNKNOWN);
        return NULL;
    }
    return pParser->GetDocument();
}
示例#4
0
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password)
{
    CPDF_Parser* pParser = FX_NEW CPDF_Parser;
    pParser->SetPassword(password);
    try {
        CMemFile* pMemFile = FX_NEW CMemFile((FX_BYTE*)data_buf, size);
        FX_DWORD err_code = pParser->StartParse(pMemFile);
        if (err_code) {
            delete pParser;
            ProcessParseError(err_code);
            return NULL;
        }
        CPDF_Document * pDoc = NULL;
        pDoc = pParser?pParser->GetDocument():NULL;
        CheckUnSupportError(pDoc, err_code);
    }
    catch (...) {
        delete pParser;
        SetLastError(FPDF_ERR_UNKNOWN);
        return NULL;
    }
    return pParser->GetDocument();
}
示例#5
0
DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail,	FPDF_BYTESTRING password)
{
	if (avail == NULL) return NULL;
	CPDF_Parser* pParser = FX_NEW CPDF_Parser;
	pParser->SetPassword(password);

	FX_DWORD err_code = pParser->StartAsynParse(((CFPDF_DataAvail*)avail)->m_pDataAvail->GetFileRead());
	if (err_code) {
		delete pParser;
		ProcessParseError(err_code);
		return NULL;
	}
	((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocument());
	CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS);
	return pParser->GetDocument();
}
示例#6
0
DLLEXPORT FPDF_DOCUMENT STDCALL
FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
  CFPDF_DataAvail* pDataAvail = static_cast<CFPDF_DataAvail*>(avail);
  if (!pDataAvail)
    return nullptr;

  CPDF_Parser* pParser = new CPDF_Parser;
  pParser->SetPassword(password);
  CPDF_Parser::Error error =
      pParser->StartAsyncParse(pDataAvail->m_pDataAvail->GetFileRead());
  if (error != CPDF_Parser::SUCCESS) {
    delete pParser;
    ProcessParseError(error);
    return nullptr;
  }
  pDataAvail->m_pDataAvail->SetDocument(pParser->GetDocument());
  CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS);
  return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
}
示例#7
0
uint32_t CPDF_DataAvail::GetObjectSize(uint32_t objnum, FX_FILESIZE& offset) {
  CPDF_Parser* pParser = m_pDocument->GetParser();
  if (!pParser || !pParser->IsValidObjectNumber(objnum))
    return 0;

  if (pParser->GetObjectType(objnum) == 2)
    objnum = pParser->GetObjectPositionOrZero(objnum);

  if (pParser->GetObjectType(objnum) != 1 &&
      pParser->GetObjectType(objnum) != 255) {
    return 0;
  }

  offset = pParser->GetObjectPositionOrZero(objnum);
  if (offset == 0)
    return 0;

  auto it = pParser->m_SortedOffset.find(offset);
  if (it == pParser->m_SortedOffset.end() ||
      ++it == pParser->m_SortedOffset.end()) {
    return 0;
  }
  return *it - offset;
}