diff options
Diffstat (limited to 'fpdfsdk/fpdfedittext.cpp')
-rw-r--r-- | fpdfsdk/fpdfedittext.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp new file mode 100644 index 0000000000..79ca310f7c --- /dev/null +++ b/fpdfsdk/fpdfedittext.cpp @@ -0,0 +1,38 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "public/fpdf_edit.h" + +#include "core/fpdfapi/cpdf_modulemgr.h" +#include "core/fpdfapi/font/cpdf_font.h" +#include "core/fpdfapi/page/cpdf_textobject.h" +#include "fpdfsdk/fsdk_define.h" + +DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewTextObj(FPDF_DOCUMENT document, + FPDF_BYTESTRING font, + float font_size) { + CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) + return nullptr; + + CPDF_Font* pFont = CPDF_Font::GetStockFont(pDoc, CFX_ByteStringC(font)); + if (!pFont) + return nullptr; + + CPDF_TextObject* pTextObj = new CPDF_TextObject; + pTextObj->m_TextState.SetFont(pFont); + pTextObj->m_TextState.SetFontSize(font_size); + pTextObj->DefaultStates(); + return pTextObj; +} + +DLLEXPORT FPDF_BOOL STDCALL FPDFText_SetText(FPDF_PAGEOBJECT text_object, + FPDF_BYTESTRING text) { + if (!text_object) + return false; + + auto pTextObj = reinterpret_cast<CPDF_TextObject*>(text_object); + pTextObj->SetText(CFX_ByteString(text)); + return true; +}
\ No newline at end of file |