mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Create SplitPage
This commit is contained in:
@ -54,14 +54,14 @@
|
|||||||
((PdfWriter::CArrayObject*)pObj)->Add(oVal);\
|
((PdfWriter::CArrayObject*)pObj)->Add(oVal);\
|
||||||
}
|
}
|
||||||
|
|
||||||
void DictToCDictObject(Object* obj, PdfWriter::CObjectBase* pObj, bool bBinary, const std::string& sKey, bool bUnicode = false)
|
void DictToCDictObject(Object* obj, PdfWriter::CObjectBase* pObj, const std::string& sKey)
|
||||||
{
|
{
|
||||||
Object oTemp;
|
Object oTemp;
|
||||||
switch (obj->getType())
|
switch (obj->getType())
|
||||||
{
|
{
|
||||||
case objBool:
|
case objBool:
|
||||||
{
|
{
|
||||||
bool b = obj->getBool();
|
bool b = obj->getBool() == gTrue;
|
||||||
AddToObject(b)
|
AddToObject(b)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -77,21 +77,20 @@ void DictToCDictObject(Object* obj, PdfWriter::CObjectBase* pObj, bool bBinary,
|
|||||||
}
|
}
|
||||||
case objString:
|
case objString:
|
||||||
{
|
{
|
||||||
if (bBinary)
|
GString* str = obj->getString();
|
||||||
|
if (str->isBinary())
|
||||||
{
|
{
|
||||||
GString* str = obj->getString();
|
|
||||||
int nLength = str->getLength();
|
int nLength = str->getLength();
|
||||||
BYTE* arrId = new BYTE[nLength];
|
BYTE* arrId = new BYTE[nLength];
|
||||||
for (int nIndex = 0; nIndex < nLength; ++nIndex)
|
for (int nIndex = 0; nIndex < nLength; ++nIndex)
|
||||||
arrId[nIndex] = str->getChar(nIndex);
|
arrId[nIndex] = str->getChar(nIndex);
|
||||||
AddToObject(new PdfWriter::CBinaryObject(arrId, nLength));
|
AddToObject(new PdfWriter::CBinaryObject(arrId, nLength, false));
|
||||||
RELEASEARRAYOBJECTS(arrId);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextString* s = new TextString(obj->getString());
|
TextString* s = new TextString(str);
|
||||||
std::string sValue = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
std::string sValue = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
||||||
AddToObject(new PdfWriter::CStringObject(sValue.c_str(), bUnicode))
|
AddToObject(new PdfWriter::CStringObject(sValue.c_str(), !s->isPDFDocEncoding()))
|
||||||
delete s;
|
delete s;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -113,7 +112,7 @@ void DictToCDictObject(Object* obj, PdfWriter::CObjectBase* pObj, bool bBinary,
|
|||||||
for (int nIndex = 0; nIndex < obj->arrayGetLength(); ++nIndex)
|
for (int nIndex = 0; nIndex < obj->arrayGetLength(); ++nIndex)
|
||||||
{
|
{
|
||||||
obj->arrayGetNF(nIndex, &oTemp);
|
obj->arrayGetNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pArray, bBinary, "", bUnicode);
|
DictToCDictObject(&oTemp, pArray, "");
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -126,7 +125,7 @@ void DictToCDictObject(Object* obj, PdfWriter::CObjectBase* pObj, bool bBinary,
|
|||||||
{
|
{
|
||||||
char* chKey = obj->dictGetKey(nIndex);
|
char* chKey = obj->dictGetKey(nIndex);
|
||||||
obj->dictGetValNF(nIndex, &oTemp);
|
obj->dictGetValNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pDict, bBinary, chKey, bUnicode);
|
DictToCDictObject(&oTemp, pDict, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -150,6 +149,106 @@ void DictToCDictObject(Object* obj, PdfWriter::CObjectBase* pObj, bool bBinary,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PdfWriter::CObjectBase* DictToCDictObject2(Object* obj, PdfWriter::CObjectBase* pObj, const std::string& sKey, PdfWriter::CDocument* pDoc, XRef* xref, bool bNeedAdd)
|
||||||
|
{
|
||||||
|
PdfWriter::CObjectBase* pBase = NULL;
|
||||||
|
Object oTemp;
|
||||||
|
switch (obj->getType())
|
||||||
|
{
|
||||||
|
case objBool:
|
||||||
|
{
|
||||||
|
pBase = new PdfWriter::CBoolObject(obj->getBool() == gTrue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objInt:
|
||||||
|
{
|
||||||
|
pBase = new PdfWriter::CNumberObject(obj->getInt());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objReal:
|
||||||
|
{
|
||||||
|
pBase = new PdfWriter::CRealObject(obj->getReal());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objString:
|
||||||
|
{
|
||||||
|
GString* str = obj->getString();
|
||||||
|
if (str->isBinary())
|
||||||
|
{
|
||||||
|
int nLength = str->getLength();
|
||||||
|
BYTE* arrId = new BYTE[nLength];
|
||||||
|
for (int nIndex = 0; nIndex < nLength; ++nIndex)
|
||||||
|
arrId[nIndex] = str->getChar(nIndex);
|
||||||
|
pBase = new PdfWriter::CBinaryObject(arrId, nLength, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TextString* s = new TextString(str);
|
||||||
|
std::string sValue = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
||||||
|
pBase = new PdfWriter::CStringObject(sValue.c_str(), !s->isPDFDocEncoding());
|
||||||
|
delete s;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objName:
|
||||||
|
{
|
||||||
|
pBase = new PdfWriter::CNameObject(obj->getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objNull:
|
||||||
|
{
|
||||||
|
pBase = new PdfWriter::CNullObject();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objArray:
|
||||||
|
{
|
||||||
|
PdfWriter::CArrayObject* pArray = new PdfWriter::CArrayObject();
|
||||||
|
for (int nIndex = 0; nIndex < obj->arrayGetLength(); ++nIndex)
|
||||||
|
{
|
||||||
|
obj->arrayGetNF(nIndex, &oTemp);
|
||||||
|
DictToCDictObject2(&oTemp, pArray, "", pDoc, xref, false);
|
||||||
|
oTemp.free();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objDict:
|
||||||
|
{
|
||||||
|
PdfWriter::CDictObject* pDict = new PdfWriter::CDictObject();
|
||||||
|
for (int nIndex = 0; nIndex < obj->dictGetLength(); ++nIndex)
|
||||||
|
{
|
||||||
|
char* chKey = obj->dictGetKey(nIndex);
|
||||||
|
obj->dictGetValNF(nIndex, &oTemp);
|
||||||
|
DictToCDictObject2(&oTemp, pDict, chKey, pDoc, xref, false);
|
||||||
|
oTemp.free();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objRef:
|
||||||
|
{
|
||||||
|
obj->fetch(xref, &oTemp);
|
||||||
|
pBase = DictToCDictObject2(&oTemp, pObj, "", pDoc, xref, true);
|
||||||
|
oTemp.free();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objNone:
|
||||||
|
{
|
||||||
|
pBase = new PdfWriter::CNameObject("None");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objStream:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case objCmd:
|
||||||
|
case objError:
|
||||||
|
case objEOF:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (bNeedAdd)
|
||||||
|
pDoc->AddObject(pBase);
|
||||||
|
AddToObject(pBase)
|
||||||
|
return pBase;
|
||||||
|
}
|
||||||
PdfWriter::CDictObject* GetWidgetParent(PDFDoc* pdfDoc, PdfWriter::CDocument* pDoc, Object* pParentRef)
|
PdfWriter::CDictObject* GetWidgetParent(PDFDoc* pdfDoc, PdfWriter::CDocument* pDoc, Object* pParentRef)
|
||||||
{
|
{
|
||||||
if (!pParentRef || !pParentRef->isRef() || !pdfDoc)
|
if (!pParentRef || !pParentRef->isRef() || !pdfDoc)
|
||||||
@ -193,7 +292,7 @@ PdfWriter::CDictObject* GetWidgetParent(PDFDoc* pdfDoc, PdfWriter::CDocument* pD
|
|||||||
}
|
}
|
||||||
Object oTemp;
|
Object oTemp;
|
||||||
oParent.dictGetValNF(i, &oTemp);
|
oParent.dictGetValNF(i, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pParent, false, chKey);
|
DictToCDictObject(&oTemp, pParent, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +384,7 @@ HRESULT _ChangePassword(const std::wstring& wsPath, const std::wstring& wsPasswo
|
|||||||
{
|
{
|
||||||
Object oT;
|
Object oT;
|
||||||
oTemp.arrayGetNF(nIndex, &oT);
|
oTemp.arrayGetNF(nIndex, &oT);
|
||||||
DictToCDictObject(&oT, pObj, false, "");
|
DictToCDictObject(&oT, pObj, "");
|
||||||
oT.free();
|
oT.free();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -299,7 +398,7 @@ HRESULT _ChangePassword(const std::wstring& wsPath, const std::wstring& wsPasswo
|
|||||||
Object oT;
|
Object oT;
|
||||||
char* chKey = oTemp.dictGetKey(nIndex);
|
char* chKey = oTemp.dictGetKey(nIndex);
|
||||||
oTemp.dictGetValNF(nIndex, &oT);
|
oTemp.dictGetValNF(nIndex, &oT);
|
||||||
DictToCDictObject(&oT, pObj, false, chKey);
|
DictToCDictObject(&oT, pObj, chKey);
|
||||||
oT.free();
|
oT.free();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -338,7 +437,7 @@ HRESULT _ChangePassword(const std::wstring& wsPath, const std::wstring& wsPasswo
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pDict->getValNF(nIndex, &oT);
|
pDict->getValNF(nIndex, &oT);
|
||||||
DictToCDictObject(&oT, pObj, false, chKey);
|
DictToCDictObject(&oT, pObj, chKey);
|
||||||
oT.free();
|
oT.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +471,7 @@ HRESULT _ChangePassword(const std::wstring& wsPath, const std::wstring& wsPasswo
|
|||||||
if (strcmp("Root", chKey) == 0 || strcmp("Info", chKey) == 0)
|
if (strcmp("Root", chKey) == 0 || strcmp("Info", chKey) == 0)
|
||||||
{
|
{
|
||||||
trailerDict->dictGetValNF(nIndex, &oTemp);
|
trailerDict->dictGetValNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pTrailer, true, chKey);
|
DictToCDictObject(&oTemp, pTrailer, chKey);
|
||||||
}
|
}
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
@ -578,7 +677,7 @@ CPdfEditor::CPdfEditor(const std::wstring& _wsSrcFile, const std::wstring& _wsPa
|
|||||||
Object oTemp;
|
Object oTemp;
|
||||||
char* chKey2 = oTemp2.dictGetKey(nIndex2);
|
char* chKey2 = oTemp2.dictGetKey(nIndex2);
|
||||||
oTemp2.dictGetVal(nIndex2, &oTemp);
|
oTemp2.dictGetVal(nIndex2, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pDR, false, chKey2);
|
DictToCDictObject(&oTemp, pDR, chKey2);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
oTemp2.free();
|
oTemp2.free();
|
||||||
@ -588,7 +687,7 @@ CPdfEditor::CPdfEditor(const std::wstring& _wsSrcFile, const std::wstring& _wsPa
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
oAcroForm.dictGetValNF(nIndex, &oTemp2);
|
oAcroForm.dictGetValNF(nIndex, &oTemp2);
|
||||||
DictToCDictObject(&oTemp2, pAcroForm, false, chKey);
|
DictToCDictObject(&oTemp2, pAcroForm, chKey);
|
||||||
oTemp2.free();
|
oTemp2.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,7 +700,7 @@ CPdfEditor::CPdfEditor(const std::wstring& _wsSrcFile, const std::wstring& _wsPa
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
catDict.dictGetValNF(nIndex, &oAcroForm);
|
catDict.dictGetValNF(nIndex, &oAcroForm);
|
||||||
DictToCDictObject(&oAcroForm, pCatalog, false, chKey);
|
DictToCDictObject(&oAcroForm, pCatalog, chKey);
|
||||||
oAcroForm.free();
|
oAcroForm.free();
|
||||||
}
|
}
|
||||||
catDict.free();
|
catDict.free();
|
||||||
@ -659,7 +758,7 @@ CPdfEditor::CPdfEditor(const std::wstring& _wsSrcFile, const std::wstring& _wsPa
|
|||||||
Object oTemp;
|
Object oTemp;
|
||||||
char* chKey = encrypt.dictGetKey(nIndex);
|
char* chKey = encrypt.dictGetKey(nIndex);
|
||||||
encrypt.dictGetValNF(nIndex, &oTemp);
|
encrypt.dictGetValNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pEncryptDict, true, chKey);
|
DictToCDictObject(&oTemp, pEncryptDict, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -670,7 +769,7 @@ CPdfEditor::CPdfEditor(const std::wstring& _wsSrcFile, const std::wstring& _wsPa
|
|||||||
encrypt.free();
|
encrypt.free();
|
||||||
|
|
||||||
if (pTrailerDict->dictLookup("ID", &ID) && ID.isArray() && ID.arrayGet(0, &ID1) && ID1.isString())
|
if (pTrailerDict->dictLookup("ID", &ID) && ID.isArray() && ID.arrayGet(0, &ID1) && ID1.isString())
|
||||||
DictToCDictObject(&ID1, pEncryptDict, true, "ID");
|
DictToCDictObject(&ID1, pEncryptDict, "ID");
|
||||||
ID.free(); ID1.free();
|
ID.free(); ID1.free();
|
||||||
|
|
||||||
xref->onEncrypted();
|
xref->onEncrypted();
|
||||||
@ -731,7 +830,7 @@ void CPdfEditor::Close()
|
|||||||
Object oTemp;
|
Object oTemp;
|
||||||
char* chKey = trailerDict->dictGetKey(nIndex);
|
char* chKey = trailerDict->dictGetKey(nIndex);
|
||||||
trailerDict->dictGetValNF(nIndex, &oTemp);
|
trailerDict->dictGetValNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pTrailer, true, chKey);
|
DictToCDictObject(&oTemp, pTrailer, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -764,7 +863,7 @@ void CPdfEditor::Close()
|
|||||||
Object oTemp;
|
Object oTemp;
|
||||||
char* chKey = info.dictGetKey(nIndex);
|
char* chKey = info.dictGetKey(nIndex);
|
||||||
info.dictGetValNF(nIndex, &oTemp);
|
info.dictGetValNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pInfoDict, true, chKey);
|
DictToCDictObject(&oTemp, pInfoDict, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
pInfoDict->SetTime(PdfWriter::InfoModaDate);
|
pInfoDict->SetTime(PdfWriter::InfoModaDate);
|
||||||
@ -851,7 +950,7 @@ void CPdfEditor::GetPageTree(XRef* xref, Object* pPagesRefObj, PdfWriter::CPageT
|
|||||||
oTemp.dictGetVal(nIndex, &oRes);
|
oTemp.dictGetVal(nIndex, &oRes);
|
||||||
else
|
else
|
||||||
oTemp.dictGetValNF(nIndex, &oRes);
|
oTemp.dictGetValNF(nIndex, &oRes);
|
||||||
DictToCDictObject(&oRes, pDict, false, chKey2);
|
DictToCDictObject(&oRes, pDict, chKey2);
|
||||||
oRes.free();
|
oRes.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,7 +970,7 @@ void CPdfEditor::GetPageTree(XRef* xref, Object* pPagesRefObj, PdfWriter::CPageT
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
pagesObj.dictGetValNF(nIndex, &oTemp);
|
pagesObj.dictGetValNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pPageT, false, chKey);
|
DictToCDictObject(&oTemp, pPageT, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
pDoc->CreatePageTree(pXref, pPageT);
|
pDoc->CreatePageTree(pXref, pPageT);
|
||||||
@ -966,7 +1065,7 @@ bool CPdfEditor::EditPage(int nPageIndex, bool bSet)
|
|||||||
oTemp.dictGetVal(nIndex, &oRes);
|
oTemp.dictGetVal(nIndex, &oRes);
|
||||||
else
|
else
|
||||||
oTemp.dictGetValNF(nIndex, &oRes);
|
oTemp.dictGetValNF(nIndex, &oRes);
|
||||||
DictToCDictObject(&oRes, pDict, false, chKey2);
|
DictToCDictObject(&oRes, pDict, chKey2);
|
||||||
oRes.free();
|
oRes.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -989,7 +1088,7 @@ bool CPdfEditor::EditPage(int nPageIndex, bool bSet)
|
|||||||
{
|
{
|
||||||
Object oAnnot;
|
Object oAnnot;
|
||||||
oTemp.arrayGetNF(nIndex, &oAnnot);
|
oTemp.arrayGetNF(nIndex, &oAnnot);
|
||||||
DictToCDictObject(&oAnnot, pArray, false, "");
|
DictToCDictObject(&oAnnot, pArray, "");
|
||||||
oAnnot.free();
|
oAnnot.free();
|
||||||
}
|
}
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
@ -1005,7 +1104,7 @@ bool CPdfEditor::EditPage(int nPageIndex, bool bSet)
|
|||||||
{
|
{
|
||||||
if (pageObj.dictGetVal(nIndex, &oTemp)->isArray())
|
if (pageObj.dictGetVal(nIndex, &oTemp)->isArray())
|
||||||
{
|
{
|
||||||
DictToCDictObject(&oTemp, pPage, true, chKey);
|
DictToCDictObject(&oTemp, pPage, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1021,7 +1120,7 @@ bool CPdfEditor::EditPage(int nPageIndex, bool bSet)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
pageObj.dictGetValNF(nIndex, &oTemp);
|
pageObj.dictGetValNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pPage, true, chKey);
|
DictToCDictObject(&oTemp, pPage, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
pPage->Fix();
|
pPage->Fix();
|
||||||
@ -1052,6 +1151,121 @@ bool CPdfEditor::EditPage(int nPageIndex, bool bSet)
|
|||||||
RELEASEOBJECT(pXref);
|
RELEASEOBJECT(pXref);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool CPdfEditor::SplitPage(int nPageIndex)
|
||||||
|
{
|
||||||
|
PDFDoc* pPDFDocument = pReader->GetPDFDocument();
|
||||||
|
PdfWriter::CDocument* pDoc = pWriter->GetDocument();
|
||||||
|
if (!pPDFDocument || !pDoc)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
XRef* xref = pPDFDocument->getXRef();
|
||||||
|
Catalog* pCatalog = pPDFDocument->getCatalog();
|
||||||
|
if (!xref || !pCatalog)
|
||||||
|
return false;
|
||||||
|
std::pair<int, int> pPageRef = pDoc->GetPageRef(nPageIndex);
|
||||||
|
if (pPageRef.first == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
HRESULT nRes = pWriter->NewPage();
|
||||||
|
if (nRes == S_FALSE)
|
||||||
|
return false;
|
||||||
|
PdfWriter::CPage* pPage = pWriter->GetPage();
|
||||||
|
if (!pPage)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Получение объекта страницы
|
||||||
|
Object pageRefObj, pageObj;
|
||||||
|
pageRefObj.initRef(pPageRef.first, pPageRef.second);
|
||||||
|
if (!pageRefObj.fetch(xref, &pageObj) || !pageObj.isDict())
|
||||||
|
{
|
||||||
|
pageObj.free();
|
||||||
|
pageRefObj.free();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pageRefObj.free();
|
||||||
|
|
||||||
|
// Воспроизведение словаря страницы из reader для writer
|
||||||
|
for (int nIndex = 0; nIndex < pageObj.dictGetLength(); ++nIndex)
|
||||||
|
{
|
||||||
|
Object oTemp;
|
||||||
|
char* chKey = pageObj.dictGetKey(nIndex);
|
||||||
|
if (strcmp("Resources", chKey) == 0)
|
||||||
|
{
|
||||||
|
if (pageObj.dictGetVal(nIndex, &oTemp)->isDict())
|
||||||
|
{
|
||||||
|
PdfWriter::CResourcesDict* pDict = new PdfWriter::CResourcesDict(NULL, true, false);
|
||||||
|
pPage->Add("Resources", pDict);
|
||||||
|
for (int nIndex = 0; nIndex < oTemp.dictGetLength(); ++nIndex)
|
||||||
|
{
|
||||||
|
Object oRes;
|
||||||
|
char* chKey2 = oTemp.dictGetKey(nIndex);
|
||||||
|
if (strcmp("Font", chKey2) == 0 || strcmp("ExtGState", chKey2) == 0 || strcmp("XObject", chKey2) == 0 || strcmp("Shading", chKey2) == 0 || strcmp("Pattern", chKey2) == 0)
|
||||||
|
oTemp.dictGetVal(nIndex, &oRes);
|
||||||
|
else
|
||||||
|
oTemp.dictGetValNF(nIndex, &oRes);
|
||||||
|
DictToCDictObject2(&oRes, pDict, chKey2, pDoc, xref, false);
|
||||||
|
oRes.free();
|
||||||
|
}
|
||||||
|
|
||||||
|
oTemp.free();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oTemp.free();
|
||||||
|
pageObj.dictGetValNF(nIndex, &oTemp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp("Annots", chKey) == 0)
|
||||||
|
{
|
||||||
|
if (pageObj.dictGetVal(nIndex, &oTemp)->isArray())
|
||||||
|
{
|
||||||
|
PdfWriter::CArrayObject* pArray = new PdfWriter::CArrayObject();
|
||||||
|
pPage->Add("Annots", pArray);
|
||||||
|
for (int nIndex = 0; nIndex < oTemp.arrayGetLength(); ++nIndex)
|
||||||
|
{
|
||||||
|
Object oAnnot;
|
||||||
|
oTemp.arrayGetNF(nIndex, &oAnnot);
|
||||||
|
DictToCDictObject2(&oAnnot, pArray, "", pDoc, xref, false);
|
||||||
|
oAnnot.free();
|
||||||
|
}
|
||||||
|
oTemp.free();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oTemp.free();
|
||||||
|
pageObj.dictGetValNF(nIndex, &oTemp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp("Contents", chKey) == 0)
|
||||||
|
{
|
||||||
|
if (pageObj.dictGetVal(nIndex, &oTemp)->isArray())
|
||||||
|
{
|
||||||
|
DictToCDictObject2(&oTemp, pPage, chKey, pDoc, xref, false);
|
||||||
|
oTemp.free();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oTemp.free();
|
||||||
|
pageObj.dictGetValNF(nIndex, &oTemp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp("Parent", chKey) == 0)
|
||||||
|
{
|
||||||
|
pageObj.dictGetValNF(nIndex, &oTemp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pageObj.dictGetValNF(nIndex, &oTemp);
|
||||||
|
DictToCDictObject2(&oTemp, pPage, chKey, pDoc, xref, false);
|
||||||
|
oTemp.free();
|
||||||
|
}
|
||||||
|
pPage->Fix();
|
||||||
|
pageObj.free();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
bool CPdfEditor::DeletePage(int nPageIndex)
|
bool CPdfEditor::DeletePage(int nPageIndex)
|
||||||
{
|
{
|
||||||
return pWriter->GetDocument()->DeletePage(nPageIndex);
|
return pWriter->GetDocument()->DeletePage(nPageIndex);
|
||||||
@ -1235,7 +1449,6 @@ bool CPdfEditor::EditAnnot(int nPageIndex, int nID)
|
|||||||
|
|
||||||
for (int nIndex = 0; nIndex < oAnnot.dictGetLength(); ++nIndex)
|
for (int nIndex = 0; nIndex < oAnnot.dictGetLength(); ++nIndex)
|
||||||
{
|
{
|
||||||
bool bUnicode = false;
|
|
||||||
char* chKey = oAnnot.dictGetKey(nIndex);
|
char* chKey = oAnnot.dictGetKey(nIndex);
|
||||||
if (!strcmp("Popup", chKey))
|
if (!strcmp("Popup", chKey))
|
||||||
{
|
{
|
||||||
@ -1282,11 +1495,9 @@ bool CPdfEditor::EditAnnot(int nPageIndex, int nID)
|
|||||||
}
|
}
|
||||||
oParentRef.free();
|
oParentRef.free();
|
||||||
}
|
}
|
||||||
else if (!strcmp("Opt", chKey))
|
|
||||||
bUnicode = true;
|
|
||||||
Object oTemp;
|
Object oTemp;
|
||||||
oAnnot.dictGetValNF(nIndex, &oTemp);
|
oAnnot.dictGetValNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pAnnot, false, chKey, bUnicode);
|
DictToCDictObject(&oTemp, pAnnot, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1311,7 +1522,7 @@ bool CPdfEditor::EditAnnot(int nPageIndex, int nID)
|
|||||||
{
|
{
|
||||||
char* chKey = pODict->getKey(nIndex);
|
char* chKey = pODict->getKey(nIndex);
|
||||||
pODict->getValNF(nIndex, &oTemp);
|
pODict->getValNF(nIndex, &oTemp);
|
||||||
DictToCDictObject(&oTemp, pAPN, false, chKey);
|
DictToCDictObject(&oTemp, pAPN, chKey);
|
||||||
oTemp.free();
|
oTemp.free();
|
||||||
}
|
}
|
||||||
int nLength = 0;
|
int nLength = 0;
|
||||||
|
|||||||
@ -45,6 +45,7 @@ public:
|
|||||||
int GetError();
|
int GetError();
|
||||||
void Close();
|
void Close();
|
||||||
bool EditPage(int nPageIndex, bool bSet = true);
|
bool EditPage(int nPageIndex, bool bSet = true);
|
||||||
|
bool SplitPage(int nPageIndex);
|
||||||
bool DeletePage(int nPageIndex);
|
bool DeletePage(int nPageIndex);
|
||||||
bool AddPage(int nPageIndex);
|
bool AddPage(int nPageIndex);
|
||||||
bool EditAnnot(int nPageIndex, int nID);
|
bool EditAnnot(int nPageIndex, int nID);
|
||||||
|
|||||||
@ -51,6 +51,7 @@ public:
|
|||||||
int GetError() { return 0; }
|
int GetError() { return 0; }
|
||||||
void Close() {}
|
void Close() {}
|
||||||
bool EditPage(int nPageIndex, bool bSet = true) { return false; }
|
bool EditPage(int nPageIndex, bool bSet = true) { return false; }
|
||||||
|
bool SplitPage(int nPageIndex) { return false; }
|
||||||
bool DeletePage(int nPageIndex) { return false; }
|
bool DeletePage(int nPageIndex) { return false; }
|
||||||
bool AddPage(int nPageIndex) { return false; }
|
bool AddPage(int nPageIndex) { return false; }
|
||||||
bool EditAnnot(int nPageIndex, int nID) { return false; }
|
bool EditAnnot(int nPageIndex, int nID) { return false; }
|
||||||
@ -166,6 +167,12 @@ bool CPdfFile::AddPage(int nPageIndex)
|
|||||||
return false;
|
return false;
|
||||||
return m_pInternal->pEditor->AddPage(nPageIndex);
|
return m_pInternal->pEditor->AddPage(nPageIndex);
|
||||||
}
|
}
|
||||||
|
bool CPdfFile::SplitPage(int nPageIndex)
|
||||||
|
{
|
||||||
|
if (!m_pInternal->pEditor)
|
||||||
|
return false;
|
||||||
|
return m_pInternal->pEditor->SplitPage(nPageIndex);
|
||||||
|
}
|
||||||
HRESULT CPdfFile::ChangePassword(const std::wstring& wsPath, const std::wstring& wsPassword)
|
HRESULT CPdfFile::ChangePassword(const std::wstring& wsPath, const std::wstring& wsPassword)
|
||||||
{
|
{
|
||||||
RELEASEOBJECT(m_pInternal->pWriter);
|
RELEASEOBJECT(m_pInternal->pWriter);
|
||||||
|
|||||||
@ -97,6 +97,7 @@ public:
|
|||||||
bool EditPage (int nPageIndex);
|
bool EditPage (int nPageIndex);
|
||||||
bool DeletePage (int nPageIndex);
|
bool DeletePage (int nPageIndex);
|
||||||
bool AddPage (int nPageIndex);
|
bool AddPage (int nPageIndex);
|
||||||
|
bool SplitPage (int nPageIndex);
|
||||||
HRESULT ChangePassword(const std::wstring& wsPath, const std::wstring& wsPassword = L"");
|
HRESULT ChangePassword(const std::wstring& wsPath, const std::wstring& wsPassword = L"");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -1289,6 +1289,10 @@ namespace PdfWriter
|
|||||||
m_pCurImage = pImage;
|
m_pCurImage = pImage;
|
||||||
m_vImages.push_back({wsImagePath, nAlpha, pImage});
|
m_vImages.push_back({wsImagePath, nAlpha, pImage});
|
||||||
}
|
}
|
||||||
|
void CDocument::AddObject(CObjectBase* pObj)
|
||||||
|
{
|
||||||
|
m_pXref->Add(pObj);
|
||||||
|
}
|
||||||
bool CDocument::CheckFieldName(CFieldBase* pField, const std::string& sName)
|
bool CDocument::CheckFieldName(CFieldBase* pField, const std::string& sName)
|
||||||
{
|
{
|
||||||
CFieldBase* pBase = m_mFields[sName];
|
CFieldBase* pBase = m_mFields[sName];
|
||||||
|
|||||||
@ -92,6 +92,7 @@ namespace PdfWriter
|
|||||||
class CFieldBase;
|
class CFieldBase;
|
||||||
class CStreamData;
|
class CStreamData;
|
||||||
class CXObject;
|
class CXObject;
|
||||||
|
class CObjectBase;
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
// CDocument
|
// CDocument
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
@ -195,6 +196,7 @@ namespace PdfWriter
|
|||||||
CPage* AddPage(int nPageIndex);
|
CPage* AddPage(int nPageIndex);
|
||||||
bool DeletePage(int nPageIndex);
|
bool DeletePage(int nPageIndex);
|
||||||
bool AddToFile(CXref* pXref, CDictObject* pTrailer, CXref* pInfoXref, CInfoDict* pInfo);
|
bool AddToFile(CXref* pXref, CDictObject* pTrailer, CXref* pInfoXref, CInfoDict* pInfo);
|
||||||
|
void AddObject(CObjectBase* pObj);
|
||||||
void Sign(const TRect& oRect, CImageDict* pImage, ICertificate* pCert);
|
void Sign(const TRect& oRect, CImageDict* pImage, ICertificate* pCert);
|
||||||
std::wstring GetEditPdfPath() { return m_wsFilePath; }
|
std::wstring GetEditPdfPath() { return m_wsFilePath; }
|
||||||
bool EditAnnot (CXref* pXref, CAnnotation* pAnnot, int nID);
|
bool EditAnnot (CXref* pXref, CAnnotation* pAnnot, int nID);
|
||||||
|
|||||||
@ -167,18 +167,18 @@ namespace PdfWriter
|
|||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
// CBinaryObject
|
// CBinaryObject
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
CBinaryObject::CBinaryObject(const BYTE* pValue, unsigned int unLen)
|
CBinaryObject::CBinaryObject(BYTE* pValue, unsigned int unLen, bool bCopy)
|
||||||
{
|
{
|
||||||
m_pValue = NULL;
|
m_pValue = NULL;
|
||||||
m_unLen = 0;
|
m_unLen = 0;
|
||||||
Set(pValue, unLen);
|
Set(pValue, unLen, bCopy);
|
||||||
}
|
}
|
||||||
CBinaryObject::~CBinaryObject()
|
CBinaryObject::~CBinaryObject()
|
||||||
{
|
{
|
||||||
if (m_pValue)
|
if (m_pValue)
|
||||||
delete[] m_pValue;
|
delete[] m_pValue;
|
||||||
}
|
}
|
||||||
void CBinaryObject::Set(const BYTE* pValue, unsigned int unLen)
|
void CBinaryObject::Set(BYTE* pValue, unsigned int unLen, bool bCopy)
|
||||||
{
|
{
|
||||||
unLen = std::min((unsigned int)LIMIT_MAX_STRING_LEN, unLen);
|
unLen = std::min((unsigned int)LIMIT_MAX_STRING_LEN, unLen);
|
||||||
if (m_pValue)
|
if (m_pValue)
|
||||||
@ -192,9 +192,13 @@ namespace PdfWriter
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_unLen = unLen;
|
m_unLen = unLen;
|
||||||
m_pValue = new BYTE[unLen];
|
if (bCopy)
|
||||||
|
{
|
||||||
MemCpy(m_pValue, pValue, unLen);
|
m_pValue = new BYTE[unLen];
|
||||||
|
MemCpy(m_pValue, pValue, unLen);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_pValue = pValue;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
// CProxyObject
|
// CProxyObject
|
||||||
|
|||||||
@ -338,9 +338,9 @@ namespace PdfWriter
|
|||||||
class CBinaryObject : public CObjectBase
|
class CBinaryObject : public CObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBinaryObject(const BYTE* pValue, unsigned int unLen);
|
CBinaryObject(BYTE* pValue, unsigned int unLen, bool bCopy = true);
|
||||||
~CBinaryObject();
|
~CBinaryObject();
|
||||||
void Set(const BYTE* pValue, unsigned int unLen);
|
void Set(BYTE* pValue, unsigned int unLen, bool bCopy = true);
|
||||||
BYTE* GetValue() const
|
BYTE* GetValue() const
|
||||||
{
|
{
|
||||||
return m_pValue;
|
return m_pValue;
|
||||||
|
|||||||
@ -134,6 +134,7 @@ GString::GString() {
|
|||||||
s = NULL;
|
s = NULL;
|
||||||
resize(length = 0);
|
resize(length = 0);
|
||||||
s[0] = '\0';
|
s[0] = '\0';
|
||||||
|
bBinary = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GString::GString(const char *sA) {
|
GString::GString(const char *sA) {
|
||||||
@ -142,13 +143,15 @@ GString::GString(const char *sA) {
|
|||||||
s = NULL;
|
s = NULL;
|
||||||
resize(length = n);
|
resize(length = n);
|
||||||
memcpy(s, sA, n + 1);
|
memcpy(s, sA, n + 1);
|
||||||
|
bBinary = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GString::GString(const char *sA, int lengthA) {
|
GString::GString(const char *sA, int lengthA, bool _bBinary) {
|
||||||
s = NULL;
|
s = NULL;
|
||||||
resize(length = lengthA);
|
resize(length = lengthA);
|
||||||
memcpy(s, sA, length * sizeof(char));
|
memcpy(s, sA, length * sizeof(char));
|
||||||
s[length] = '\0';
|
s[length] = '\0';
|
||||||
|
bBinary = _bBinary;
|
||||||
}
|
}
|
||||||
|
|
||||||
GString::GString(GString *str, int idx, int lengthA) {
|
GString::GString(GString *str, int idx, int lengthA) {
|
||||||
@ -156,12 +159,14 @@ GString::GString(GString *str, int idx, int lengthA) {
|
|||||||
resize(length = lengthA);
|
resize(length = lengthA);
|
||||||
memcpy(s, str->getCString() + idx, length);
|
memcpy(s, str->getCString() + idx, length);
|
||||||
s[length] = '\0';
|
s[length] = '\0';
|
||||||
|
bBinary = str->bBinary;
|
||||||
}
|
}
|
||||||
|
|
||||||
GString::GString(GString *str) {
|
GString::GString(GString *str) {
|
||||||
s = NULL;
|
s = NULL;
|
||||||
resize(length = str->getLength());
|
resize(length = str->getLength());
|
||||||
memcpy(s, str->getCString(), length + 1);
|
memcpy(s, str->getCString(), length + 1);
|
||||||
|
bBinary = str->bBinary;
|
||||||
}
|
}
|
||||||
|
|
||||||
GString::GString(GString *str1, GString *str2) {
|
GString::GString(GString *str1, GString *str2) {
|
||||||
@ -175,6 +180,7 @@ GString::GString(GString *str1, GString *str2) {
|
|||||||
resize(length = n1 + n2);
|
resize(length = n1 + n2);
|
||||||
memcpy(s, str1->getCString(), n1);
|
memcpy(s, str1->getCString(), n1);
|
||||||
memcpy(s + n1, str2->getCString(), n2 + 1);
|
memcpy(s + n1, str2->getCString(), n2 + 1);
|
||||||
|
bBinary = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GString *GString::fromInt(int x) {
|
GString *GString::fromInt(int x) {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
// Create a string from <lengthA> chars at <sA>. This string
|
// Create a string from <lengthA> chars at <sA>. This string
|
||||||
// can contain null characters.
|
// can contain null characters.
|
||||||
GString(const char *sA, int lengthA);
|
GString(const char *sA, int lengthA, bool _bBinary = false);
|
||||||
|
|
||||||
// Create a string from <lengthA> chars at <idx> in <str>.
|
// Create a string from <lengthA> chars at <idx> in <str>.
|
||||||
GString(GString *str, int idx, int lengthA);
|
GString(GString *str, int idx, int lengthA);
|
||||||
@ -120,8 +120,11 @@ public:
|
|||||||
int cmp(const char *sA);
|
int cmp(const char *sA);
|
||||||
int cmpN(const char *sA, int n);
|
int cmpN(const char *sA, int n);
|
||||||
|
|
||||||
|
bool isBinary() { return bBinary; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool bBinary;
|
||||||
int length;
|
int length;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
|
|||||||
@ -455,7 +455,7 @@ Object *Lexer::getObj(Object *obj) {
|
|||||||
if (++m == 2) {
|
if (++m == 2) {
|
||||||
if (n == tokBufSize) {
|
if (n == tokBufSize) {
|
||||||
if (!s)
|
if (!s)
|
||||||
s = new GString(tokBuf, tokBufSize);
|
s = new GString(tokBuf, tokBufSize, true);
|
||||||
else
|
else
|
||||||
s->append(tokBuf, tokBufSize);
|
s->append(tokBuf, tokBufSize);
|
||||||
p = tokBuf;
|
p = tokBuf;
|
||||||
@ -469,7 +469,7 @@ Object *Lexer::getObj(Object *obj) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!s)
|
if (!s)
|
||||||
s = new GString(tokBuf, n);
|
s = new GString(tokBuf, n, true);
|
||||||
else
|
else
|
||||||
s->append(tokBuf, n);
|
s->append(tokBuf, n);
|
||||||
if (m == 1)
|
if (m == 1)
|
||||||
|
|||||||
@ -25,16 +25,19 @@
|
|||||||
TextString::TextString() {
|
TextString::TextString() {
|
||||||
u = NULL;
|
u = NULL;
|
||||||
len = size = 0;
|
len = size = 0;
|
||||||
|
bPDFDocEncoding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextString::TextString(GString *s) {
|
TextString::TextString(GString *s) {
|
||||||
u = NULL;
|
u = NULL;
|
||||||
len = size = 0;
|
len = size = 0;
|
||||||
|
bPDFDocEncoding = true;
|
||||||
append(s);
|
append(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextString::TextString(TextString *s) {
|
TextString::TextString(TextString *s) {
|
||||||
len = size = s->len;
|
len = size = s->len;
|
||||||
|
bPDFDocEncoding = s->bPDFDocEncoding;
|
||||||
if (len) {
|
if (len) {
|
||||||
u = (Unicode *)gmallocn(size, sizeof(Unicode));
|
u = (Unicode *)gmallocn(size, sizeof(Unicode));
|
||||||
memcpy(u, s->u, len * sizeof(Unicode));
|
memcpy(u, s->u, len * sizeof(Unicode));
|
||||||
@ -90,6 +93,7 @@ TextString *TextString::insert(int idx, GString *s) {
|
|||||||
// look for a UTF-16BE BOM
|
// look for a UTF-16BE BOM
|
||||||
if ((s->getChar(0) & 0xff) == 0xfe &&
|
if ((s->getChar(0) & 0xff) == 0xfe &&
|
||||||
(s->getChar(1) & 0xff) == 0xff) {
|
(s->getChar(1) & 0xff) == 0xff) {
|
||||||
|
bPDFDocEncoding = false;
|
||||||
i = 2;
|
i = 2;
|
||||||
n = 0;
|
n = 0;
|
||||||
while (getUTF16BE(s, &i, uBuf + n)) {
|
while (getUTF16BE(s, &i, uBuf + n)) {
|
||||||
@ -109,6 +113,7 @@ TextString *TextString::insert(int idx, GString *s) {
|
|||||||
// PDF files use it)
|
// PDF files use it)
|
||||||
} else if ((s->getChar(0) & 0xff) == 0xff &&
|
} else if ((s->getChar(0) & 0xff) == 0xff &&
|
||||||
(s->getChar(1) & 0xff) == 0xfe) {
|
(s->getChar(1) & 0xff) == 0xfe) {
|
||||||
|
bPDFDocEncoding = false;
|
||||||
i = 2;
|
i = 2;
|
||||||
n = 0;
|
n = 0;
|
||||||
while (getUTF16LE(s, &i, uBuf + n)) {
|
while (getUTF16LE(s, &i, uBuf + n)) {
|
||||||
@ -127,6 +132,7 @@ TextString *TextString::insert(int idx, GString *s) {
|
|||||||
} else if ((s->getChar(0) & 0xff) == 0xef &&
|
} else if ((s->getChar(0) & 0xff) == 0xef &&
|
||||||
(s->getChar(1) & 0xff) == 0xbb &&
|
(s->getChar(1) & 0xff) == 0xbb &&
|
||||||
(s->getChar(2) & 0xff) == 0xbf) {
|
(s->getChar(2) & 0xff) == 0xbf) {
|
||||||
|
bPDFDocEncoding = false;
|
||||||
i = 3;
|
i = 3;
|
||||||
n = 0;
|
n = 0;
|
||||||
while (getUTF8(s, &i, uBuf + n)) {
|
while (getUTF8(s, &i, uBuf + n)) {
|
||||||
@ -143,6 +149,7 @@ TextString *TextString::insert(int idx, GString *s) {
|
|||||||
|
|
||||||
// otherwise, use PDFDocEncoding
|
// otherwise, use PDFDocEncoding
|
||||||
} else {
|
} else {
|
||||||
|
bPDFDocEncoding = true;
|
||||||
n = s->getLength();
|
n = s->getLength();
|
||||||
expand(n);
|
expand(n);
|
||||||
if (idx < len) {
|
if (idx < len) {
|
||||||
|
|||||||
@ -52,6 +52,7 @@ public:
|
|||||||
// Get the Unicode characters in the TextString.
|
// Get the Unicode characters in the TextString.
|
||||||
int getLength() { return len; }
|
int getLength() { return len; }
|
||||||
Unicode *getUnicode() { return u; }
|
Unicode *getUnicode() { return u; }
|
||||||
|
bool isPDFDocEncoding() { return bPDFDocEncoding; }
|
||||||
|
|
||||||
// Create a PDF text string from a TextString.
|
// Create a PDF text string from a TextString.
|
||||||
GString *toPDFTextString();
|
GString *toPDFTextString();
|
||||||
@ -63,6 +64,7 @@ private:
|
|||||||
|
|
||||||
void expand(int delta);
|
void expand(int delta);
|
||||||
|
|
||||||
|
bool bPDFDocEncoding;
|
||||||
Unicode *u; // NB: not null-terminated
|
Unicode *u; // NB: not null-terminated
|
||||||
int len;
|
int len;
|
||||||
int size;
|
int size;
|
||||||
|
|||||||
@ -350,6 +350,21 @@ TEST_F(CPdfFileTest, VerifySign)
|
|||||||
RELEASEOBJECT(pCertificate);
|
RELEASEOBJECT(pCertificate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CPdfFileTest, SplitPdf)
|
||||||
|
{
|
||||||
|
GTEST_SKIP();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CPdfFileTest, MergePdf)
|
||||||
|
{
|
||||||
|
GTEST_SKIP();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CPdfFileTest, CopyAnotherPdf)
|
||||||
|
{
|
||||||
|
GTEST_SKIP();
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(CPdfFileTest, EditPdf)
|
TEST_F(CPdfFileTest, EditPdf)
|
||||||
{
|
{
|
||||||
GTEST_SKIP();
|
GTEST_SKIP();
|
||||||
|
|||||||
Reference in New Issue
Block a user