diff --git a/DesktopEditor/doctrenderer/drawingfile.h b/DesktopEditor/doctrenderer/drawingfile.h index 694bf119c8..7b963820cc 100644 --- a/DesktopEditor/doctrenderer/drawingfile.h +++ b/DesktopEditor/doctrenderer/drawingfile.h @@ -54,6 +54,7 @@ private: IOfficeDrawingFile* m_pFile; int m_nType = -1; + BYTE* m_pPdfText; bool m_bIsExternalFile; @@ -73,12 +74,14 @@ public: m_pImageStorage = NULL; m_pFile = NULL; + m_pPdfText = NULL; m_bIsExternalFile = false; } ~CDrawingFile() { if (!m_bIsExternalFile) RELEASEOBJECT(m_pFile); + RELEASEOBJECT(m_pPdfText); RELEASEOBJECT(m_pTextRenderer); RELEASEOBJECT(m_pFontManager); RELEASEINTERFACE(m_pApplicationFonts); @@ -287,6 +290,12 @@ public: BYTE* GetGlyphs(int nPageIndex) { + if (m_nType == 0) + { + m_pPdfText = ((CPdfFile*)m_pFile)->GetGlyphs(nPageIndex); + return m_pPdfText; + } + if (NULL == m_pTextRenderer) m_pTextRenderer = new NSHtmlRenderer::CHTMLRendererText(); @@ -381,6 +390,7 @@ public: void DestroyTextInfo() { + RELEASEOBJECT(m_pPdfText); RELEASEOBJECT(m_pTextRenderer); } bool IsNeedCMap() diff --git a/PdfFile/PdfFile.cpp b/PdfFile/PdfFile.cpp index 249beee837..8628a7c8c1 100644 --- a/PdfFile/PdfFile.cpp +++ b/PdfFile/PdfFile.cpp @@ -437,6 +437,12 @@ std::wstring CPdfFile::GetEmbeddedFontPath(const std::wstring& wsFontName) return L""; return m_pInternal->pReader->GetFontPath(wsFontName); } +BYTE* CPdfFile::GetGlyphs(int nPageIndex) +{ + if (!m_pInternal->pReader) + return NULL; + return m_pInternal->pReader->GetGlyphs(nPageIndex); +} BYTE* CPdfFile::GetAnnots(int nPageIndex) { if (!m_pInternal->pReader) diff --git a/PdfFile/PdfFile.h b/PdfFile/PdfFile.h index 8c3073a211..37578f8c17 100644 --- a/PdfFile/PdfFile.h +++ b/PdfFile/PdfFile.h @@ -131,6 +131,7 @@ public: BYTE* GetWidgets(); BYTE* GetAnnotEmbeddedFonts(); BYTE* GetAnnotStandardFonts(); + BYTE* GetGlyphs (int nPageIndex); BYTE* GetAnnots (int nPageIndex = -1); BYTE* VerifySign (const std::wstring& sFile, ICertificate* pCertificate, int nWidget = -1); BYTE* GetAPWidget (int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nWidget = -1, const char* sView = NULL, const char* sBView = NULL); diff --git a/PdfFile/PdfReader.cpp b/PdfFile/PdfReader.cpp index ad2d07ed62..282157afb0 100644 --- a/PdfFile/PdfReader.cpp +++ b/PdfFile/PdfReader.cpp @@ -837,7 +837,7 @@ BYTE* CPdfReader::GetStructure() } BYTE* CPdfReader::GetLinks(int nPageIndex) { - if (!m_pPDFDocument) + if (!m_pPDFDocument || !m_pPDFDocument->getCatalog()) return NULL; nPageIndex++; @@ -1409,6 +1409,35 @@ BYTE* CPdfReader::GetButtonIcon(int nBackgroundColor, int nPageIndex, bool bBase oRes.ClearWithoutAttack(); return bRes; } +BYTE* CPdfReader::GetGlyphs(int nPageIndex) +{ + if (!m_pPDFDocument || !m_pPDFDocument->getCatalog()) + return NULL; + + nPageIndex++; + Page* pPage = m_pPDFDocument->getCatalog()->getPage(nPageIndex); + if (!pPage) + return NULL; + + int nRotate = -m_pPDFDocument->getPageRotate(nPageIndex); + + TextOutputControl textOutControl; + textOutControl.mode = textOutRawOrder; + TextOutputDev* pTextOut = new TextOutputDev(NULL, &textOutControl, gFalse); + m_pPDFDocument->displayPage(pTextOut, nPageIndex, 72.0, 72.0, nRotate, gFalse, gTrue, gFalse); + + TextWordList* pWordList = pTextOut->makeWordList(); + for (int i = 0; i < pWordList->getLength(); i++) + { + TextWord* pWord = pWordList->get(i); + if (!pWord) + continue; + } + RELEASEOBJECT(pWordList); + RELEASEOBJECT(pTextOut); + + return NULL; +} void GetPageAnnots(PDFDoc* pdfDoc, NSFonts::IFontManager* pFontManager, PdfReader::CPdfFontList *pFontList, NSWasm::CData& oRes, int nPageIndex) { Page* pPage = pdfDoc->getCatalog()->getPage(nPageIndex + 1); diff --git a/PdfFile/PdfReader.h b/PdfFile/PdfReader.h index 4c16f56429..25aba4508d 100644 --- a/PdfFile/PdfReader.h +++ b/PdfFile/PdfReader.h @@ -76,6 +76,7 @@ public: BYTE* GetLinks(int nPageIndex); BYTE* GetWidgets(); BYTE* GetFonts(bool bStandart); + BYTE* GetGlyphs(int nPageIndex); BYTE* GetAnnots(int nPageIndex = -1); BYTE* GetShapes(int nPageIndex); BYTE* VerifySign(const std::wstring& sFile, ICertificate* pCertificate, int nWidget = -1);