PDF SDK Documentation

Comprehensive Guide for Developers: Features, Integration, and API Reference

Loading...
Searching...
No Matches
text_edit.h
1// Copyright (c) 2009-2025 Avanquest Software. All rights reserved.
2
3#ifndef PDFSDK_CXX_TEXT_EDIT_H_INCLUDED_
4#define PDFSDK_CXX_TEXT_EDIT_H_INCLUDED_
5
6#include <pdfsdk/cxx/element.h>
7#include <pdfsdk/cxx/math.h>
8#include <pdfsdk/cxx/text_run.h>
9#include <pdfsdk/text_edit.h>
10
11#include "forward_declarations.h"
12#include "wrapper_base.h"
13
14namespace PDF {
15namespace TextEdit {
16
17class CharIterator;
18class Layout;
19class TextBlock;
20class TextCommand;
21
25class Layout : public detail::RefCountedHandle<PDTLayout> {
26public:
32 static Layout BuildForPage(const Page& page);
33
40 static Layout BuildForFormXObject(const Document& doc, const XObject& xform);
41
47 TextBlock NewTextBlock(size_t index);
48
54 void InsertTextBlock(size_t index, const TextBlock& text_block);
55
60 void RemoveTextBlock(size_t index);
61
66 size_t GetNumTextBlocks() const;
67
73 TextBlock GetTextBlock(size_t index) const;
74
80 size_t FindTextBlockIndex(const TextBlock& text_block) const;
81
87
93
99 CharIterator GetCharIterAtPoint(const PointF& point) const;
100
107 CharIterator GetCharIterForItem(const TextRun& text_run, size_t char_index) const;
108
115 CharIterator GetCharIterForItemAtPoint(const TextRun& text_run, const PointF& point) const;
116
117 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(Layout, PDTLayout)
118};
119
123class TextBlock : public detail::RefCountedHandle<PDTTextBlock> {
124public:
130 bool Equals(const TextBlock& that) const;
131
136 PointF GetPosition() const;
137
142 SizeF GetSize() const;
143
148 float GetRotation() const;
149
154 bool IsReflected() const;
155
160 RectF GetBBox() const;
161
167 CharIterator GetCharBegin(const Layout& text_layout) const;
168
174 CharIterator GetCharEnd(const Layout& text_layout) const;
175
181
186 bool IsExplicitWidth() const;
187
192 void SetExplicitWidth(bool value);
193
194 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(TextBlock, PDTTextBlock)
195};
196
200class CharIterator : public detail::RefCountedHandle<PDTCharIterator> {
201public:
207
213
219
224 CharIterator GetParaEnd() const;
225
231
236 CharIterator GetLineEnd() const;
237
243
248 CharIterator GetWordEnd() const;
249
255
260 CharIterator GetSpanEnd() const;
261
266 CharIterator GetAbove() const;
267
273 CharIterator GetAboveAtPage(const Layout& prev_page_text_layout) const;
274
279 CharIterator GetBelow() const;
280
286 CharIterator GetBelowAtPage(const Layout& next_page_text_layout) const;
287
292 CharIterator Copy() const;
293
297 void MoveNext();
298
302 void MovePrev();
303
308 void Move(int n);
309
315 int Distance(const CharIterator& that) const;
316
322 bool Less(const CharIterator& that) const;
323
329 bool Equal(const CharIterator& that) const;
330
335 std::wstring GetUnicodeChar() const;
336
341 size_t GetPageIndex() const;
342
347 Quad GetQuad() const;
348
353 Quad GetOutlineQuad() const;
354
359 TextBlock GetTextBlock() const;
360
366
372
378
383 Matrix GetTransform() const;
384
389 TextRun GetTextRun() const;
390
391 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(CharIterator, PDTCharIterator)
392};
393
399class TextCommand : public detail::RefCountedHandle<PDTTextCommand> {
400public:
409
419 static TextCommand InsertText(Document doc, CharIterator pos, const PDTFontAttrs& font_attrs, const std::wstring& chars);
420
431 static TextCommand ReplaceText(Document doc, CharIterator beg, CharIterator end, const PDTFontAttrs& font_attrs, const std::wstring& chars);
432
442 static TextCommand ChangeFont(Document doc, CharIterator beg, CharIterator end, PDAtom font_family, PDAtom font_format);
443
452 static TextCommand ChangeFontStyle(Document doc, CharIterator beg, CharIterator end, PDFontStyle font_style);
453
462 static TextCommand ChangeFontSize(Document doc, CharIterator beg, CharIterator end, float font_size);
463
472 static TextCommand ChangeFontColor(Document doc, CharIterator beg, CharIterator end, PDColorValue font_color);
473
484
495 static TextCommand ChangeHorzScaling(Document doc, CharIterator begin, CharIterator end, float horz_scaling);
496
506 static TextCommand ChangeCharSpacing(Document doc, CharIterator begin, CharIterator end, float char_spacing);
507
516 static TextCommand ChangeParaAttrs(Document doc, CharIterator iter, const PDTParaAttrs& para_attrs);
517
529 static TextCommand NewTextBlock(Document doc, Layout layout, const PointF& page_point, const PDTFontAttrs& font_attrs, const PDTParaAttrs& para_attrs);
530
538 static TextCommand DeleteTextBlock(Document doc, Layout layout, const TextBlock& block);
539
548
555 static TextCommand UpdateTextBlocks(Document doc, Layout layout);
556
565 static TextCommand MoveTextBlock(Document doc, Layout layout, size_t block_index, const PointF& pos);
566
577 static TextCommand RotateTextBlock(Document doc, Layout layout, size_t block_index, float radians);
578
588 static TextCommand ScaleTextBlock(Document doc, Layout layout, size_t block_index, const SizeF& size);
589
599 static TextCommand ResizeTextBlock(Document doc, Layout layout, size_t block_index, const SizeF& size);
600
610 static TextCommand SyncWithContent(Document doc, Layout layout, size_t block_index, bool on_top);
611
622
633 static TextCommand ChangeListLevel(Document doc, CharIterator begin, CharIterator end, int change);
634
638 void Redo();
639
643 void Undo();
644
649 bool IsFontSubstituted() const;
650
651 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(TextCommand, PDTTextCommand)
652};
653
654inline Layout Layout::BuildForPage(const Page& page) {
655 Layout text_layout;
656 PDF_CHECK_SUCCESS_X(PDPageBuildTextLayout(page.get(), &text_layout));
657 return text_layout;
658}
659
660inline Layout Layout::BuildForFormXObject(const Document& doc, const XObject& xform) {
661 Layout text_layout;
662 PDF_CHECK_SUCCESS_X(PDEFormXObjectBuildTextLayout(doc.get(), xform.get(), &text_layout));
663 return text_layout;
664}
665
666inline TextBlock Layout::NewTextBlock(size_t index) {
667 TextBlock text_block;
668 PDF_CHECK_SUCCESS_X(PDTLayoutNewTextBlock(m_handle, index, &text_block));
669 return text_block;
670}
671
672inline void Layout::InsertTextBlock(size_t index, const TextBlock& text_block) {
673 PDF_CHECK_SUCCESS_X(PDTLayoutInsertTextBlock(m_handle, index, text_block.get()));
674}
675
676inline void Layout::RemoveTextBlock(size_t index) {
677 PDF_CHECK_SUCCESS_X(PDTLayoutRemoveTextBlock(m_handle, index));
678}
679
680inline size_t Layout::GetNumTextBlocks() const {
681 size_t num_blocks = 0;
682 PDF_CHECK_SUCCESS_X(PDTLayoutGetNumTextBlocks(m_handle, &num_blocks));
683 return num_blocks;
684}
685
686inline TextBlock Layout::GetTextBlock(size_t index) const {
687 TextBlock text_block;
688 PDF_CHECK_SUCCESS_X(PDTLayoutGetTextBlock(m_handle, index, &text_block));
689 return text_block;
690}
691
692inline size_t Layout::FindTextBlockIndex(const TextBlock& text_block) const {
693 size_t index = kPDPageIndexNull;
694 PDF_CHECK_SUCCESS_X(PDTLayoutGetTextBlockIndex(m_handle, text_block.get(), &index));
695 return index;
696}
697
699 CharIterator char_begin;
700 PDF_CHECK_SUCCESS_X(PDTCharIteratorAtBeginPage(m_handle, &char_begin));
701 return char_begin;
702}
703
705 CharIterator char_end;
706 PDF_CHECK_SUCCESS_X(PDTCharIteratorAtEndPage(m_handle, &char_end));
707 return char_end;
708}
709
711 CharIterator char_iter;
712 PDF_CHECK_SUCCESS_X(PDTCharIteratorAtPoint(m_handle, &point, &char_iter));
713 return char_iter;
714}
715
716inline CharIterator Layout::GetCharIterForItem(const TextRun& text_run, size_t char_index) const {
717 CharIterator char_iter;
718 PDF_CHECK_SUCCESS_X(PDTCharIteratorForItem(m_handle, text_run.get(), char_index, &char_iter));
719 return char_iter;
720}
721
722inline CharIterator Layout::GetCharIterForItemAtPoint(const TextRun& text_run, const PointF& point) const {
723 CharIterator char_iter;
724 PDF_CHECK_SUCCESS_X(PDTCharIteratorForItemAtPoint(m_handle, text_run.get(), &point, &char_iter));
725 return char_iter;
726}
727
728inline bool TextBlock::Equals(const TextBlock& that) const {
729 return PDTTextBlockEqual(m_handle, that.get());
730}
731
733 PointF position;
734 PDF_CHECK_SUCCESS_X(PDTTextBlockGetPosition(m_handle, &position));
735 return position;
736}
737
738inline SizeF TextBlock::GetSize() const {
739 SizeF size;
740 PDF_CHECK_SUCCESS_X(PDTTextBlockGetSize(m_handle, &size));
741 return size;
742}
743
744inline float TextBlock::GetRotation() const {
745 float rotation = 0.f;
746 PDF_CHECK_SUCCESS_X(PDTTextBlockGetRotate(m_handle, &rotation));
747 return rotation;
748}
749
750inline bool TextBlock::IsReflected() const {
751 bool reflected = false;
752 PDF_CHECK_SUCCESS_X(PDTTextBlockIsReflected(m_handle, &reflected));
753 return reflected;
754}
755
756inline RectF TextBlock::GetBBox() const {
757 RectF bbox;
758 PDF_CHECK_SUCCESS_X(PDTTextBlockGetBBox(m_handle, &bbox));
759 return bbox;
760}
761
762inline CharIterator TextBlock::GetCharBegin(const Layout& text_layout) const {
763 CharIterator char_begin;
764 PDF_CHECK_SUCCESS_X(PDTTextBlockGetCharBegin(text_layout.get(), m_handle, &char_begin));
765 return char_begin;
766}
767
768inline CharIterator TextBlock::GetCharEnd(const Layout& text_layout) const {
769 CharIterator char_end;
770 PDF_CHECK_SUCCESS_X(PDTTextBlockGetCharEnd(text_layout.get(), m_handle, &char_end));
771 return char_end;
772}
773
775 Element text_object;
776 PDF_CHECK_SUCCESS_X(PDTTextBlockCreateTextElement(m_handle, &text_object));
777 return text_object;
778}
779
780inline bool TextBlock::IsExplicitWidth() const {
781 bool value = false;
782 PDF_CHECK_SUCCESS_X(PDTTextBlockIsExplicitWidth(m_handle, &value));
783 return value;
784}
785
786inline void TextBlock::SetExplicitWidth(bool value) {
787 PDF_CHECK_SUCCESS_X(PDTTextBlockSetExplicitWidth(m_handle, value));
788}
789
791 CharIterator char_iter;
792 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetBlockBegin(m_handle, &char_iter));
793 return char_iter;
794}
795
797 CharIterator char_iter;
798 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetBlockEnd(m_handle, &char_iter));
799 return char_iter;
800}
801
803 CharIterator char_iter;
804 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetParaBegin(m_handle, &char_iter));
805 return char_iter;
806}
807
809 CharIterator char_iter;
810 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetParaEnd(m_handle, &char_iter));
811 return char_iter;
812}
813
815 CharIterator char_iter;
816 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetLineBegin(m_handle, &char_iter));
817 return char_iter;
818}
819
821 CharIterator char_iter;
822 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetLineEnd(m_handle, &char_iter));
823 return char_iter;
824}
825
827 CharIterator char_iter;
828 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetWordBegin(m_handle, &char_iter));
829 return char_iter;
830}
831
833 CharIterator char_iter;
834 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetWordEnd(m_handle, &char_iter));
835 return char_iter;
836}
837
839 CharIterator char_iter;
840 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetSpanBegin(m_handle, &char_iter));
841 return char_iter;
842}
843
845 CharIterator char_iter;
846 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetSpanEnd(m_handle, &char_iter));
847 return char_iter;
848}
849
851 CharIterator char_iter;
852 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetAbove(m_handle, &char_iter));
853 return char_iter;
854}
855
856inline CharIterator CharIterator::GetAboveAtPage(const Layout& prev_page_text_layout) const {
857 CharIterator char_iter;
858 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetAboveAtPage(m_handle, prev_page_text_layout.get(), &char_iter));
859 return char_iter;
860}
861
863 CharIterator char_iter;
864 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetBelow(m_handle, &char_iter));
865 return char_iter;
866}
867
868inline CharIterator CharIterator::GetBelowAtPage(const Layout& next_page_text_layout) const {
869 CharIterator char_iter;
870 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetBelowAtPage(m_handle, next_page_text_layout.get(), &char_iter));
871 return char_iter;
872}
873
875 CharIterator copy;
876 PDF_CHECK_SUCCESS_X(PDTCharIteratorCopy(m_handle, &copy));
877 return copy;
878}
879
881 PDF_CHECK_SUCCESS_X(PDTCharIteratorIncrement(m_handle));
882}
883
885 PDF_CHECK_SUCCESS_X(PDTCharIteratorDecrement(m_handle));
886}
887
888inline void CharIterator::Move(int n) {
889 PDF_CHECK_SUCCESS_X(PDTCharIteratorAdvance(m_handle, n));
890}
891
892inline int CharIterator::Distance(const CharIterator& that) const {
893 int dist = 0;
894 PDF_CHECK_SUCCESS_X(PDTCharIteratorDistance(m_handle, that.get(), &dist));
895 return dist;
896}
897
898inline bool CharIterator::Less(const CharIterator& that) const {
899 bool less = false;
900 PDF_CHECK_SUCCESS_X(PDTCharIteratorLess(m_handle, that.get(), &less));
901 return less;
902}
903
904inline bool CharIterator::Equal(const CharIterator& that) const {
905 bool equal = false;
906 PDF_CHECK_SUCCESS_X(PDTCharIteratorEqual(m_handle, that.get(), &equal));
907 return equal;
908}
909
910inline std::wstring CharIterator::GetUnicodeChar() const {
911 return ::PDF::detail::GetWstringProperty(PDTCharIteratorGetUnicode, m_handle);
912}
913
914inline size_t CharIterator::GetPageIndex() const {
915 size_t page_index = kPDPageIndexNull;
916 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetPageIndex(m_handle, &page_index));
917 return page_index;
918}
919
921 Quad quad;
922 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetQuad(m_handle, &quad));
923 return quad;
924}
925
927 Quad quad;
928 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetOutlineQuad(m_handle, &quad));
929 return quad;
930}
931
933 TextBlock text_block;
934 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetTextBlock(m_handle, &text_block));
935 return text_block;
936}
937
939 PDTFontAttrs font_attrs;
940 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetFontAttrs(m_handle, &font_attrs));
941 return font_attrs;
942}
943
945 PDTParaAttrs para_attrs;
946 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetParaAttrs(m_handle, &para_attrs));
947 return para_attrs;
948}
949
951 PDTListAttrs list_attrs;
952 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetListAttrs(m_handle, &list_attrs));
953 return list_attrs;
954}
955
957 Matrix matrix;
958 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetTransform(m_handle, &matrix));
959 return matrix;
960}
961
963 TextRun text_run;
964 PDF_CHECK_SUCCESS_X(PDTCharIteratorGetTextItem(m_handle, &text_run));
965 return text_run;
966}
967
969 TextCommand text_command;
970 PDF_CHECK_SUCCESS_X(PDTCreateDeleteTextCommand(doc.get(), beg.get(), end.get(), &text_command));
971 return text_command;
972}
973
974inline TextCommand TextCommand::InsertText(Document doc, CharIterator pos, const PDTFontAttrs& font_attrs, const std::wstring& chars) {
975 TextCommand text_command;
976 PDF_CHECK_SUCCESS_X(PDTCreateInsertTextCommand(doc.get(), pos.get(), &font_attrs, chars.data(), chars.size(), &text_command));
977 return text_command;
978}
979
980inline TextCommand TextCommand::ReplaceText(Document doc, CharIterator beg, CharIterator end, const PDTFontAttrs& font_attrs, const std::wstring& chars) {
981 TextCommand text_command;
982 PDF_CHECK_SUCCESS_X(PDTCreateReplaceTextCommand(doc.get(), beg.get(), end.get(), &font_attrs, chars.data(), chars.size(), &text_command));
983 return text_command;
984}
985
986inline TextCommand TextCommand::ChangeFont(Document doc, CharIterator beg, CharIterator end, PDAtom font_family, PDAtom font_format) {
987 TextCommand text_command;
988 PDF_CHECK_SUCCESS_X(PDTCreateChangeFontCommand(doc.get(), beg.get(), end.get(), font_family, font_format, &text_command));
989 return text_command;
990}
991
992inline TextCommand TextCommand::ChangeFontStyle(Document doc, CharIterator beg, CharIterator end, PDFontStyle font_style) {
993 TextCommand text_command;
994 PDF_CHECK_SUCCESS_X(PDTCreateChangeFontStyleCommand(doc.get(), beg.get(), end.get(), font_style, &text_command));
995 return text_command;
996}
997
999 TextCommand text_command;
1000 PDF_CHECK_SUCCESS_X(PDTCreateChangeFontSizeCommand(doc.get(), beg.get(), end.get(), font_size, &text_command));
1001 return text_command;
1002}
1003
1004inline TextCommand TextCommand::ChangeFontColor(Document doc, CharIterator beg, CharIterator end, PDColorValue font_color) {
1005 TextCommand text_command;
1006 PDF_CHECK_SUCCESS_X(PDTCreateChangeFontColorCommand(doc.get(), beg.get(), end.get(), font_color, &text_command));
1007 return text_command;
1008}
1009
1011 TextCommand text_command;
1012 PDF_CHECK_SUCCESS_X(PDTCreateChangeEscapementCommand(doc.get(), begin.get(), end.get(), escapment, &text_command));
1013 return text_command;
1014}
1015
1017 TextCommand text_command;
1018 PDF_CHECK_SUCCESS_X(PDTCreateChangeHorzScalingCommand(doc.get(), begin.get(), end.get(), horz_scaling, &text_command));
1019 return text_command;
1020}
1021
1023 TextCommand text_command;
1024 PDF_CHECK_SUCCESS_X(PDTCreateChangeCharSpacingCommand(doc.get(), begin.get(), end.get(), char_spacing, &text_command));
1025 return text_command;
1026}
1027
1029 TextCommand text_command;
1030 PDF_CHECK_SUCCESS_X(PDTCreateChangeParaAttrsCommand(doc.get(), iter.get(), &para_attrs, &text_command));
1031 return text_command;
1032}
1033
1034inline TextCommand TextCommand::NewTextBlock(Document doc, Layout layout, const PointF& page_point, const PDTFontAttrs& font_attrs, const PDTParaAttrs& para_attrs) {
1035 TextCommand text_command;
1036 PDF_CHECK_SUCCESS_X(PDTCreateNewTextBlockCommand(doc.get(), layout.get(), &page_point, &font_attrs, &para_attrs, &text_command));
1037 return text_command;
1038}
1039
1041 TextCommand text_command;
1042 PDF_CHECK_SUCCESS_X(PDTCreateDeleteTextBlockCommand(doc.get(), layout.get(), block.get(), &text_command));
1043 return text_command;
1044}
1045
1047 TextCommand text_command;
1048 PDF_CHECK_SUCCESS_X(PDTCreateMergeTextBlocksCommand(doc.get(), begin.get(), end.get(), &text_command));
1049 return text_command;
1050}
1051
1053 TextCommand text_command;
1054 PDF_CHECK_SUCCESS_X(PDTCreateUpdateTextBlocksCommand(doc.get(), layout.get(), &text_command));
1055 return text_command;
1056}
1057
1058inline TextCommand TextCommand::MoveTextBlock(Document doc, Layout layout, size_t block_index, const PointF& pos) {
1059 TextCommand text_command;
1060 PDF_CHECK_SUCCESS_X(PDTCreateMoveTextBlockCommand(doc.get(), layout.get(), block_index, &pos, &text_command));
1061 return text_command;
1062}
1063
1064inline TextCommand TextCommand::RotateTextBlock(Document doc, Layout layout, size_t block_index, float radians) {
1065 TextCommand text_command;
1066 PDF_CHECK_SUCCESS_X(PDTCreateRotateTextBlockCommand(doc.get(), layout.get(), block_index, radians, &text_command));
1067 return text_command;
1068}
1069
1070inline TextCommand TextCommand::ScaleTextBlock(Document doc, Layout layout, size_t block_index, const SizeF& size) {
1071 TextCommand text_command;
1072 PDF_CHECK_SUCCESS_X(PDTCreateScaleTextBlockCommand(doc.get(), layout.get(), block_index, &size, &text_command));
1073 return text_command;
1074}
1075
1076inline TextCommand TextCommand::ResizeTextBlock(Document doc, Layout layout, size_t block_index, const SizeF& size) {
1077 TextCommand text_command;
1078 PDF_CHECK_SUCCESS_X(PDTCreateResizeTextBlockCommand(doc.get(), layout.get(), block_index, &size, &text_command));
1079 return text_command;
1080}
1081
1082inline TextCommand TextCommand::SyncWithContent(Document doc, Layout layout, size_t block_index, bool on_top) {
1083 TextCommand text_command;
1084 PDF_CHECK_SUCCESS_X(PDTCreateSyncWithContentCommand(doc.get(), layout.get(), block_index, on_top, &text_command));
1085 return text_command;
1086}
1087
1089 TextCommand text_command;
1090 PDF_CHECK_SUCCESS_X(PDTCreateChangeListStyleCommand(doc.get(), begin.get(), end.get(), &style, &text_command));
1091 return text_command;
1092}
1093
1095 TextCommand text_command;
1096 PDF_CHECK_SUCCESS_X(PDTCreateChangeListLevelCommand(doc.get(), begin.get(), end.get(), change, &text_command));
1097 return text_command;
1098}
1099
1100inline void TextCommand::Redo() {
1101 PDF_CHECK_SUCCESS_X(PDTTextCommandDo(m_handle));
1102}
1103
1104inline void TextCommand::Undo() {
1105 PDF_CHECK_SUCCESS_X(PDTTextCommandUndo(m_handle));
1106}
1107
1109 bool fontSubstituted = false;
1110 PDF_CHECK_SUCCESS_X(PDTTextCommandIsFontSubstituted(m_handle, &fontSubstituted));
1111 return fontSubstituted;
1112}
1113
1114} // namespace TextEdit
1115} // namespace PDF
1116
1117#endif // PDFSDK_CXX_TEXT_EDIT_H_INCLUDED_
Represents a PDF document.
Definition document.h:22
Represents a PDF content element.
Definition element.h:19
Represents a leaf node (Page Object).
Definition page.h:20
The CharIterator class represents an iterator to a character in a Layout.
Definition text_edit.h:200
size_t GetPageIndex() const
Gets the page index of the current iterator.
Definition text_edit.h:914
CharIterator GetLineBegin() const
Gets the iterator to the beginning of the current line.
Definition text_edit.h:814
PDTListAttrs GetListAttrs() const
Gets the list attributes of the current character.
Definition text_edit.h:950
int Distance(const CharIterator &that) const
Calculates the distance between the current iterator and another iterator.
Definition text_edit.h:892
CharIterator GetWordEnd() const
Gets the iterator to the end of the current word.
Definition text_edit.h:832
PDTParaAttrs GetParaAttrs() const
Gets the paragraph attributes of the current character.
Definition text_edit.h:944
CharIterator GetAboveAtPage(const Layout &prev_page_text_layout) const
Gets the iterator to the character above the current character on the previous page.
Definition text_edit.h:856
CharIterator GetBelowAtPage(const Layout &next_page_text_layout) const
Gets the iterator to the character below the current character on the next page.
Definition text_edit.h:868
Matrix GetTransform() const
Gets the transformation matrix of the current character.
Definition text_edit.h:956
void Move(int n)
Moves the iterator by the specified number of characters.
Definition text_edit.h:888
CharIterator GetLineEnd() const
Gets the iterator to the end of the current line.
Definition text_edit.h:820
void MoveNext()
Moves the iterator to the next character.
Definition text_edit.h:880
bool Less(const CharIterator &that) const
Checks if the current iterator is less than another iterator.
Definition text_edit.h:898
void MovePrev()
Moves the iterator to the previous character.
Definition text_edit.h:884
CharIterator GetParaBegin() const
Gets the iterator to the beginning of the current paragraph.
Definition text_edit.h:802
CharIterator GetBlockEnd() const
Gets the iterator to the end of the current block.
Definition text_edit.h:796
Quad GetOutlineQuad() const
Gets the quad representing the outline of the current character.
Definition text_edit.h:926
CharIterator GetParaEnd() const
Gets the iterator to the end of the current paragraph.
Definition text_edit.h:808
CharIterator GetSpanBegin() const
Gets the iterator to the beginning of the current span.
Definition text_edit.h:838
std::wstring GetUnicodeChar() const
Gets the Unicode character at the current iterator position.
Definition text_edit.h:910
CharIterator GetBlockBegin() const
Gets the iterator to the beginning of the current block.
Definition text_edit.h:790
Quad GetQuad() const
Gets the quad representing the bounding box of the current character.
Definition text_edit.h:920
TextRun GetTextRun() const
Gets the TextRun containing the current character.
Definition text_edit.h:962
CharIterator GetBelow() const
Gets the iterator to the character below the current character.
Definition text_edit.h:862
CharIterator Copy() const
Creates a copy of the current iterator.
Definition text_edit.h:874
CharIterator GetAbove() const
Gets the iterator to the character above the current character.
Definition text_edit.h:850
CharIterator GetSpanEnd() const
Gets the iterator to the end of the current span.
Definition text_edit.h:844
CharIterator GetWordBegin() const
Gets the iterator to the beginning of the current word.
Definition text_edit.h:826
PDTFontAttrs GetFontAttrs() const
Gets the font attributes of the current character.
Definition text_edit.h:938
TextBlock GetTextBlock() const
Gets the TextBlock containing the current character.
Definition text_edit.h:932
bool Equal(const CharIterator &that) const
Checks if the current iterator is equal to another iterator.
Definition text_edit.h:904
The Layout class represents a text layout in a PDF document.
Definition text_edit.h:25
TextBlock GetTextBlock(size_t index) const
Gets the TextBlock at the specified index.
Definition text_edit.h:686
static Layout BuildForPage(const Page &page)
Builds a Layout object for a specific page.
Definition text_edit.h:654
CharIterator GetCharIterAtPoint(const PointF &point) const
Gets an iterator to the character at the specified point in the Layout.
Definition text_edit.h:710
TextBlock NewTextBlock(size_t index)
Creates a new TextBlock at the specified index.
Definition text_edit.h:666
size_t FindTextBlockIndex(const TextBlock &text_block) const
Finds the index of the specified TextBlock in the Layout.
Definition text_edit.h:692
void InsertTextBlock(size_t index, const TextBlock &text_block)
Inserts a TextBlock at the specified index.
Definition text_edit.h:672
void RemoveTextBlock(size_t index)
Removes the TextBlock at the specified index.
Definition text_edit.h:676
CharIterator GetCharIterForItem(const TextRun &text_run, size_t char_index) const
Gets an iterator to the character at the specified index within a TextRun in the Layout.
Definition text_edit.h:716
CharIterator GetCharsEnd() const
Gets an iterator to the end of the characters in the Layout.
Definition text_edit.h:704
size_t GetNumTextBlocks() const
Gets the number of TextBlocks in the Layout.
Definition text_edit.h:680
CharIterator GetCharsBegin() const
Gets an iterator to the beginning of the characters in the Layout.
Definition text_edit.h:698
CharIterator GetCharIterForItemAtPoint(const TextRun &text_run, const PointF &point) const
Gets an iterator to the character at the specified point within a TextRun in the Layout.
Definition text_edit.h:722
static Layout BuildForFormXObject(const Document &doc, const XObject &xform)
Builds a Layout object for a specific form XObject.
Definition text_edit.h:660
The TextBlock class represents a block of text in a Layout.
Definition text_edit.h:123
CharIterator GetCharEnd(const Layout &text_layout) const
Gets an iterator to the end of the characters in the TextBlock.
Definition text_edit.h:768
bool IsExplicitWidth() const
Checks if the TextBlock has an explicit width.
Definition text_edit.h:780
Element CreateTextElement() const
Creates a TextElement from the TextBlock.
Definition text_edit.h:774
bool Equals(const TextBlock &that) const
Checks if the current TextBlock is equal to another TextBlock.
Definition text_edit.h:728
bool IsReflected() const
Checks if the TextBlock is reflected.
Definition text_edit.h:750
void SetExplicitWidth(bool value)
Sets whether the TextBlock has an explicit width.
Definition text_edit.h:786
PointF GetPosition() const
Gets the position of the TextBlock.
Definition text_edit.h:732
float GetRotation() const
Gets the rotation angle of the TextBlock.
Definition text_edit.h:744
RectF GetBBox() const
Gets the bounding box of the TextBlock.
Definition text_edit.h:756
SizeF GetSize() const
Gets the size of the TextBlock.
Definition text_edit.h:738
CharIterator GetCharBegin(const Layout &text_layout) const
Gets an iterator to the beginning of the characters in the TextBlock.
Definition text_edit.h:762
The TextCommand class represents a command that can be performed on text in a Layout....
Definition text_edit.h:399
static TextCommand RotateTextBlock(Document doc, Layout layout, size_t block_index, float radians)
Rotates a text block by a specified angle and returns the command.
Definition text_edit.h:1064
static TextCommand ChangeCharSpacing(Document doc, CharIterator begin, CharIterator end, float char_spacing)
Changes the character spacing of text within a specified range and returns the command.
Definition text_edit.h:1022
static TextCommand ChangeFontStyle(Document doc, CharIterator beg, CharIterator end, PDFontStyle font_style)
Changes the font style of text within a specified range and returns the command.
Definition text_edit.h:992
static TextCommand ChangeFont(Document doc, CharIterator beg, CharIterator end, PDAtom font_family, PDAtom font_format)
Changes the font of text within a specified range and returns the command.
Definition text_edit.h:986
static TextCommand DeleteText(Document doc, CharIterator beg, CharIterator end)
Deletes the text within a specified range and returns the command.
Definition text_edit.h:968
static TextCommand ChangeListStyle(Document doc, CharIterator begin, CharIterator end, const PDTListLevelStyle &style)
Changes the list style of text within a specified range and returns the command.
Definition text_edit.h:1088
static TextCommand InsertText(Document doc, CharIterator pos, const PDTFontAttrs &font_attrs, const std::wstring &chars)
Inserts the specified text at the position and returns the command.
Definition text_edit.h:974
void Undo()
Undoes the applied text command.
Definition text_edit.h:1104
static TextCommand SyncWithContent(Document doc, Layout layout, size_t block_index, bool on_top)
Synchronizes a text block with its content and returns the command.
Definition text_edit.h:1082
static TextCommand ChangeFontColor(Document doc, CharIterator beg, CharIterator end, PDColorValue font_color)
Changes the font color of text within a specified range and returns the command.
Definition text_edit.h:1004
bool IsFontSubstituted() const
Checks if the font was substituted during the text command.
Definition text_edit.h:1108
static TextCommand NewTextBlock(Document doc, Layout layout, const PointF &page_point, const PDTFontAttrs &font_attrs, const PDTParaAttrs &para_attrs)
Creates a new text block at a specified position and returns the command.
Definition text_edit.h:1034
static TextCommand UpdateTextBlocks(Document doc, Layout layout)
Updates all text blocks in a Layout and returns the command.
Definition text_edit.h:1052
void Redo()
Redoes the applied text command.
Definition text_edit.h:1100
static TextCommand MoveTextBlock(Document doc, Layout layout, size_t block_index, const PointF &pos)
Moves a text block to a new position and returns the command.
Definition text_edit.h:1058
static TextCommand ResizeTextBlock(Document doc, Layout layout, size_t block_index, const SizeF &size)
Resizes a text block to a new size and returns the command.
Definition text_edit.h:1076
static TextCommand ScaleTextBlock(Document doc, Layout layout, size_t block_index, const SizeF &size)
Scales a text block to a new size and returns the command.
Definition text_edit.h:1070
static TextCommand ChangeEscapement(Document doc, CharIterator begin, CharIterator end, PDTEscapement escapment)
Changes the escapement (vertical location relative to the baseline, also known as superscript or subs...
Definition text_edit.h:1010
static TextCommand MergeTextBlocks(Document doc, CharIterator begin, CharIterator end)
Merges multiple text blocks into a single text block and returns the command.
Definition text_edit.h:1046
static TextCommand ChangeListLevel(Document doc, CharIterator begin, CharIterator end, int change)
Changes the list level of text within a specified range and returns the command. This refers to adjus...
Definition text_edit.h:1094
static TextCommand ChangeParaAttrs(Document doc, CharIterator iter, const PDTParaAttrs &para_attrs)
Changes the paragraph attributes of text for a specific paragraph and returns the command.
Definition text_edit.h:1028
static TextCommand ChangeHorzScaling(Document doc, CharIterator begin, CharIterator end, float horz_scaling)
Changes the horizontal scaling (horizontal stretch) of text within a specified range and returns the ...
Definition text_edit.h:1016
static TextCommand ChangeFontSize(Document doc, CharIterator beg, CharIterator end, float font_size)
Changes the font size of text within a specified range and returns the command.
Definition text_edit.h:998
static TextCommand DeleteTextBlock(Document doc, Layout layout, const TextBlock &block)
Deletes a text block from a Layout and returns the command.
Definition text_edit.h:1040
static TextCommand ReplaceText(Document doc, CharIterator beg, CharIterator end, const PDTFontAttrs &font_attrs, const std::wstring &chars)
Replaces text within a specified range and returns the command.
Definition text_edit.h:980
Represents a text run in a PDF document.
Definition text_run.h:19
Represents an XObject in a PDF document.
Definition xobject.h:22
Definition math.h:1053
Definition math.h:132
Definition math.h:838
Definition math.h:545
Definition math.h:313
Definition text_edit.h:42
Definition text_edit.h:109
Definition text_edit.h:90
Definition text_edit.h:68
Text Edit API.
PDTEscapement
Defines the vertical position of text relative to the baseline.
Definition text_edit.h:36