mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Get FormField text
This commit is contained in:
@ -34,6 +34,7 @@
|
||||
#include "PdfReader.h"
|
||||
|
||||
#include "../DesktopEditor/common/File.h"
|
||||
#include "../HtmlRenderer/include/HTMLRendererText.h"
|
||||
#include "lib/xpdf/PDFDoc.h"
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
@ -814,7 +815,14 @@ BYTE* CPdfFile::GetWidgets()
|
||||
{
|
||||
if (!m_pInternal->pReader)
|
||||
return NULL;
|
||||
return m_pInternal->pReader->GetWidgets();
|
||||
|
||||
NSHtmlRenderer::CHTMLRendererText* pTextRenderer = new NSHtmlRenderer::CHTMLRendererText();
|
||||
pTextRenderer->Init(this, 8);
|
||||
|
||||
BYTE* bRes = m_pInternal->pReader->GetWidgets(pTextRenderer);
|
||||
RELEASEOBJECT(pTextRenderer);
|
||||
|
||||
return bRes;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@ -717,7 +717,7 @@ BYTE* CPdfReader::GetLinks(int nPageIndex)
|
||||
return oLinks.Serialize();
|
||||
}
|
||||
|
||||
BYTE* CPdfReader::GetWidgets()
|
||||
BYTE* CPdfReader::GetWidgets(IRenderer* pRenderer)
|
||||
{
|
||||
if (!m_pPDFDocument || !m_pPDFDocument->getCatalog())
|
||||
return NULL;
|
||||
@ -729,6 +729,23 @@ BYTE* CPdfReader::GetWidgets()
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
|
||||
PdfReader::RendererOutputDev oRendererOut(pRenderer, m_pFontManager, m_pFontList);
|
||||
oRendererOut.NewPDF(m_pPDFDocument->getXRef());
|
||||
oRendererOut.SetBreak(NULL);
|
||||
|
||||
globalParams->setDrawFormFields(gTrue);
|
||||
globalParams->setDrawAnnotations(gFalse);
|
||||
globalParams->setDrawContent(gFalse);
|
||||
|
||||
for (int i = 0, nPage = m_pPDFDocument->getNumPages(); i < nPage; ++i)
|
||||
{
|
||||
m_pPDFDocument->displayPage(&oRendererOut, i + 1, 72.0, 72.0, 0, gFalse, gTrue, gFalse);
|
||||
}
|
||||
|
||||
globalParams->setDrawFormFields(gFalse);
|
||||
globalParams->setDrawAnnotations(gTrue);
|
||||
globalParams->setDrawContent(gTrue);
|
||||
|
||||
for (int i = 0, nNum = pAcroForms->getNumFields(); i < nNum; ++i)
|
||||
{
|
||||
AcroFormField* pField = pAcroForms->getField(i);
|
||||
|
||||
@ -69,7 +69,7 @@ public:
|
||||
|
||||
BYTE* GetStructure();
|
||||
BYTE* GetLinks(int nPageIndex);
|
||||
BYTE* GetWidgets();
|
||||
BYTE* GetWidgets(IRenderer* pRenderer);
|
||||
|
||||
private:
|
||||
PDFDoc* m_pPDFDocument;
|
||||
|
||||
@ -734,6 +734,7 @@ GlobalParams::GlobalParams(const char *cfgFileName) {
|
||||
enablePathSimplification = gFalse;
|
||||
drawAnnotations = gTrue;
|
||||
drawFormFields = gTrue;
|
||||
drawContent = gTrue;
|
||||
overprintPreview = gFalse;
|
||||
paperColor = new GString("#ffffff");
|
||||
matteColor = new GString("#808080");
|
||||
@ -3158,6 +3159,15 @@ GBool GlobalParams::getDrawFormFields() {
|
||||
return draw;
|
||||
}
|
||||
|
||||
GBool GlobalParams::getDrawContent() {
|
||||
GBool draw;
|
||||
|
||||
lockGlobalParams;
|
||||
draw = drawContent;
|
||||
unlockGlobalParams;
|
||||
return draw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GString *GlobalParams::getPaperColor() {
|
||||
@ -3704,12 +3714,24 @@ void GlobalParams::setScreenWhiteThreshold(double thresh) {
|
||||
unlockGlobalParams;
|
||||
}
|
||||
|
||||
void GlobalParams::setDrawAnnotations(GBool draw) {
|
||||
lockGlobalParams;
|
||||
drawAnnotations = draw;
|
||||
unlockGlobalParams;
|
||||
}
|
||||
|
||||
void GlobalParams::setDrawFormFields(GBool draw) {
|
||||
lockGlobalParams;
|
||||
drawFormFields = draw;
|
||||
unlockGlobalParams;
|
||||
}
|
||||
|
||||
void GlobalParams::setDrawContent(GBool draw) {
|
||||
lockGlobalParams;
|
||||
drawContent = draw;
|
||||
unlockGlobalParams;
|
||||
}
|
||||
|
||||
void GlobalParams::setOverprintPreview(GBool preview) {
|
||||
lockGlobalParams;
|
||||
overprintPreview = preview;
|
||||
|
||||
@ -325,6 +325,7 @@ public:
|
||||
GBool getEnablePathSimplification();
|
||||
GBool getDrawAnnotations();
|
||||
GBool getDrawFormFields();
|
||||
GBool getDrawContent();
|
||||
GBool getOverprintPreview() { return overprintPreview; }
|
||||
GString *getPaperColor();
|
||||
GString *getMatteColor();
|
||||
@ -391,7 +392,9 @@ public:
|
||||
void setScreenGamma(double gamma);
|
||||
void setScreenBlackThreshold(double thresh);
|
||||
void setScreenWhiteThreshold(double thresh);
|
||||
void setDrawAnnotations(GBool draw);
|
||||
void setDrawFormFields(GBool draw);
|
||||
void setDrawContent(GBool draw);
|
||||
void setOverprintPreview(GBool preview);
|
||||
void setMapNumericCharNames(GBool map);
|
||||
void setMapUnknownCharNames(GBool map);
|
||||
@ -569,6 +572,7 @@ private:
|
||||
enablePathSimplification;
|
||||
GBool drawAnnotations; // draw annotations or not
|
||||
GBool drawFormFields; // draw form fields or not
|
||||
GBool drawContent; // draw content or not
|
||||
GBool overprintPreview; // enable overprint preview
|
||||
GString *paperColor; // paper (page background) color
|
||||
GString *matteColor; // matte (background outside of page) color
|
||||
|
||||
@ -373,7 +373,8 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI,
|
||||
contents.fetch(xref, &obj);
|
||||
if (!obj.isNull()) {
|
||||
gfx->saveState();
|
||||
gfx->display(&contents);
|
||||
if (globalParams->getDrawContent())
|
||||
gfx->display(&contents);
|
||||
gfx->endOfPage();
|
||||
}
|
||||
obj.free();
|
||||
|
||||
Reference in New Issue
Block a user