Fix add not supported annots

This commit is contained in:
Svetlana Kulikova
2025-04-11 11:19:22 +03:00
parent 185be63b27
commit 85c60f172c
3 changed files with 23 additions and 6 deletions

View File

@ -228,7 +228,6 @@ namespace NSOnlineOfficeBinToPdf
int nMaxID = oReader.ReadInt();
std::wstring wsPrefix = oReader.ReadString();
pPdf->MergePages(wsPath, nMaxID, wsPrefix);
RELEASEARRAYOBJECTS(pFile);
break;
}
case AddCommandType::WidgetInfo:

View File

@ -369,8 +369,11 @@ PdfWriter::CObjectBase* DictToCDictObject2(Object* obj, PdfWriter::CDocument* pD
if (obj->dictLookup("Type", &oType)->isName("Annot") && obj->dictLookup("Subtype", &oSubtype)->isName())
{
PdfWriter::CAnnotation* pAnnot = CreateAnnot(obj, &oSubtype, NULL);
pDoc->AddAnnotation(nAddObjToXRef + nStartRefID, pAnnot);
pDict = pAnnot;
if (pAnnot)
{
pDoc->AddAnnotation(nAddObjToXRef + nStartRefID, pAnnot);
pDict = pAnnot;
}
}
oType.free(); oSubtype.free();
@ -1649,12 +1652,27 @@ bool CPdfEditor::SplitPages(const int* arrPageIndex, unsigned int unLength, PDFD
if (pDict->Get("Filter"))
pDict->SetFilter(STREAM_FILTER_ALREADY_DECODE);
}
}
oTemp.free();
}
pPage->Fix();
if (m_nMode == Mode::WriteAppend)
{
pDoc->FixEditPage(pPage);
double dCTM[6] = { 1, 0, 0, 1, 0, 0 };
GetCTM(xref, &pageObj, dCTM);
pPage->StartTransform(dCTM[0], dCTM[1], dCTM[2], dCTM[3], dCTM[4], dCTM[5]);
pPage->SetStrokeColor(0, 0, 0);
pPage->SetFillColor(0, 0, 0);
pPage->SetExtGrState(pDoc->GetExtGState(255, 255));
pPage->BeginText();
pPage->SetCharSpace(0);
pPage->SetTextRenderingMode(PdfWriter::textrenderingmode_Fill);
pPage->SetHorizontalScalling(100);
pPage->EndText();
}
else
m_pWriter->SetNeedAddHelvetica(false); // TODO дописывает шрифт для адекватного редактирования Adobe pdf без текст. Убрать при реализации map шрифтов
pageObj.free();

View File

@ -373,14 +373,14 @@ TEST_F(CPdfFileTest, SplitPdf)
TEST_F(CPdfFileTest, MergePdf)
{
// GTEST_SKIP();
GTEST_SKIP();
LoadFromFile();
ASSERT_TRUE(pdfFile->EditPdf(wsDstFile));
std::wstring wsSplitFile = NSFile::GetProcessDirectory() + L"/test_split.pdf";
pdfFile->MergePages(wsSplitFile);
pdfFile->MergePages(wsSplitFile, 0, L"");
pdfFile->Close();
}
@ -407,7 +407,7 @@ TEST_F(CPdfFileTest, EditPdf)
TEST_F(CPdfFileTest, EditPdfFromBase64)
{
GTEST_SKIP();
//GTEST_SKIP();
NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NSFonts::NSApplicationFontStream::CreateDefaultGlobalMemoryStorage());