void CCatalog::AddPageLabel(unsigned int unPageNum, CDictObject* pPageLabel) { CDictObject* pLabels = (CDictObject*)Get("PageLabels"); if (!pLabels) { pLabels = new CDictObject(); if (!pLabels) return; Add("PageLabels", pLabels); } CArrayObject* pNums = (CArrayObject*)pLabels->Get("Nums"); if (!pNums) { pNums = new CArrayObject(); if (!pNums) return; pLabels->Add("Nums", pNums); } pNums->Add(unPageNum); pNums->Add(pPageLabel); }
void CImageDict::LoadMask(NSImages::CPixJbig2* pPix, unsigned int unWidth, unsigned int unHeight) { CImageDict* pMask = new CImageDict(m_pXref, m_pDocument); if (!pMask) return; pMask->SetStream(m_pXref, new CMemoryStream()); CJbig2Global* pJbig2Global = m_pDocument->GetJbig2Global(); pJbig2Global->AddImage(pPix, pMask->GetStream()); pMask->Add("Type", "XObject"); pMask->Add("Subtype", "Image"); pMask->Add("Width", unWidth); pMask->Add("Height", unHeight); pMask->Add("BitsPerComponent", 1); pMask->Add("ImageMask", true); pMask->SetFilter(STREAM_FILTER_JBIG2_DECODE); CArrayObject* pDecodeParams = new CArrayObject(); CDictObject* pParams = new CDictObject(); pDecodeParams->Add(pParams); pParams->Add("JBIG2Globals", pJbig2Global); pMask->Add("DecodeParms", pDecodeParams); Add("Mask", pMask); }
void CImageDict::LoadCCITT4(const wchar_t* wsTempFile, unsigned int unWidth, unsigned int unHeight) { CImageFileStream* pStream = new CImageFileStream(); if (!pStream) return; pStream->OpenFile(wsTempFile); SetStream(m_pXref, pStream); Add("Type", "XObject"); Add("Subtype", "Image"); Add("Height", unHeight); Add("Width", unWidth); Add("ColorSpace", "DeviceGray"); Add("BitsPerComponent", 1); CArrayObject* pDecodeParams = new CArrayObject(); CDictObject* pParams = new CDictObject(); pDecodeParams->Add(pParams); pParams->Add("K", 0); pParams->Add("Columns", unWidth); pParams->Add("EncodedByteAlign", true); Add("DecodeParams", pDecodeParams); SetFilter(STREAM_FILTER_CCITT_DECODE); }
void CImageDict::LoadBW(NSImages::CPixJbig2* pPix, unsigned int unWidth, unsigned int unHeight) { SetStream(m_pXref, new CMemoryStream()); CJbig2Global* pJbig2Global = m_pDocument->GetJbig2Global(); pJbig2Global->AddImage(pPix, GetStream()); Add("Type", "XObject"); Add("Subtype", "Image"); Add("Height", unHeight); Add("Width", unWidth); Add("ColorSpace", "DeviceGray"); Add("BitsPerComponent", 1); SetFilter(STREAM_FILTER_JBIG2_DECODE); CArrayObject* pDecodeParams = new CArrayObject(); CDictObject* pParams = new CDictObject(); pDecodeParams->Add(pParams); pParams->Add("JBIG2Globals", pJbig2Global); Add("DecodeParms", pDecodeParams); }
void CDocument::PrepareEncryption() { CEncrypt* pEncrypt = m_pEncryptDict->GetEncrypt(); if (!pEncrypt) return; m_pEncryptDict->Prepare(m_pInfo, m_pXref); CArrayObject* pID = (CArrayObject*)m_pTrailer->Get("ID"); if (!pID) { pID = new CArrayObject(); m_pTrailer->Add("ID", pID); } else pID->Clear(); pID->Add(new CBinaryObject(pEncrypt->m_anEncryptID, 16)); pID->Add(new CBinaryObject(pEncrypt->m_anEncryptID, 16)); }
bool CDocument::CreateNew() { Close(); m_pXref = new CXref(this, 0); if (!m_pXref) return false; m_pTrailer = m_pXref->GetTrailer(); if (!m_pTrailer) return false; m_pCatalog = new CCatalog(m_pXref); if (!m_pCatalog) return false; m_pCatalog->SetPageMode(pagemode_UseNone); m_pCatalog->SetPageLayout(pagelayout_OneColumn); m_pPageTree = m_pCatalog->GetRoot(); if (!m_pPageTree) return false; m_pInfo = new CInfoDict(m_pXref); if (!m_pInfo) return false; m_pInfo->SetCreationTime(); std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvCompanyName); if (sApplication.empty()) sApplication = NSSystemUtils::gc_EnvCompanyNameDefault; std::string sApplicationA = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sApplication); m_pInfo->SetInfo(InfoProducer, sApplicationA.c_str()); CMetadata* pMetadata = m_pCatalog->AddMetadata(m_pXref, m_pInfo); if (IsPDFA()) { CArrayObject* pID = (CArrayObject*)m_pTrailer->Get("ID"); if (!pID) { BYTE arrId[16]; CEncryptDict::CreateId(m_pInfo, m_pXref, (BYTE*)arrId); pID = new CArrayObject(); m_pTrailer->Add("ID", pID); pID->Add(new CBinaryObject(arrId, 16)); pID->Add(new CBinaryObject(arrId, 16)); } } m_nCurPageNum = -1; m_vPages.clear(); m_vExtGrStates.clear(); m_vFillAlpha.clear(); m_vStrokeAlpha.clear(); m_pTransparencyGroup = NULL; return true; }