Write PushButton widget to pdf

This commit is contained in:
Svetlana Kulikova
2023-12-12 16:45:19 +03:00
parent ac711129e3
commit 02cce6ff1b
13 changed files with 535 additions and 178 deletions

View File

@ -898,7 +898,37 @@ bool CPdfFile::EditAnnot(int nPageIndex, int nID)
if (sName)
{
if (strcmp("Btn", sName) == 0)
pAnnot = new PdfWriter::CButtonWidget(pXref);
{
bool bPushButton = false;
oFT.free();
int nFf = 0;
if (oAnnot.dictLookup("Ff", &oFT)->isInt())
nFf = oFT.getInt();
if (!nFf)
{
Object oParent, oParent2;
oAnnot.dictLookup("Parent", &oParent);
while (oParent.isDict())
{
if (oParent.dictLookup("Ff", &oFT)->isInt())
{
nFf = oFT.getInt();
break;
}
oFT.free();
oParent.dictLookup("Parent", &oParent2);
oParent.free();
oParent = oParent2;
}
oParent.free();
}
bPushButton = (bool)((nFf >> 16) & 1);
if (bPushButton)
pAnnot = new PdfWriter::CPushButtonWidget(pXref);
else
pAnnot = new PdfWriter::CCheckBoxWidget(pXref);
}
else if (strcmp("Tx", sName) == 0)
pAnnot = new PdfWriter::CTextWidget(pXref);
else if (strcmp("Ch", sName) == 0)
@ -2132,7 +2162,7 @@ HRESULT CPdfFile::AdvancedCommand(IAdvancedCommand* command)
CWidgetsInfo* pCommand = (CWidgetsInfo*)command;
#ifndef BUILDING_WASM_MODULE
if (m_pInternal->bEdit && EditWidgets(pCommand))
return m_pInternal->pWriter->EditWidgetParents(pCommand);
return m_pInternal->pWriter->EditWidgetParents(m_pInternal->pAppFonts, pCommand, m_pInternal->wsTempFolder);
#endif
return S_OK;
}