제어 문자 작업
Contents
[
Hide
]
Microsoft Word문서에는 특별한 의미가 있는 다양한 문자가 포함될 수 있습니다. 일반적으로 서식 지정 목적으로 사용되며 일반 모드에서는 그려지지 않습니다. 표준 도구 모음에 있는 서식 표시 표시/숨기기 단추를 클릭하면 표시 표시를 할 수 있습니다.
때로는 텍스트에 문자를 추가하거나 제거해야 할 수도 있습니다. 예를 들어 문서에서 프로그래밍 방식으로 텍스트를 가져올 때Aspose.Words은 대부분의 컨트롤 문자를 보존하므로 이 텍스트로 작업해야 하는 경우 문자를 제거하거나 대체해야 합니다.
ControlChar클래스는 문서에서 자주 발생하는 제어 문자를 나타내는 상수의 저장소입니다. 동일한 상수의 문자 및 문자열 버전을 모두 제공합니다. 예를 들어 문자열LineBreak과 문자LineBreakChar은 동일한 값을 갖습니다.
당신이 제어 문자를 처리 할 때마다이 클래스를 사용합니다.
다음 코드 예제에서는 컨트롤 문자를 사용하는 방법을 보여 줍니다:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(UseControlCharacters.class); | |
// Open the document. | |
Document doc = new Document(); | |
DocumentBuilder builder = new DocumentBuilder(doc); | |
builder.write("This is First Line"); | |
builder.write(ControlChar.CR); | |
builder.write("This is Second Line"); | |
builder.write(ControlChar.CR_LF); | |
doc.save(dataDir + "output.doc"); |