ZIP에 출력 쓰기
C++를 통해 TeX 파일 변환 결과를 ZIP으로 저장
TeX는 데이터 마크업 언어이며 출판 세트 시스템으로도 알려진 컴퓨터 조판 시스템의 핵심입니다. 종종 파일 형식이라고도 하지만 실제로는 수학, 기술 및 기타 복잡한 문서를 만드는 데 사용되는 프로그래밍 언어 및 인터프리터 엔진입니다. 그러나 일단 파일이 생성되면 모든 장치 및 플랫폼에서 결과를 사용할 수 있도록 보다 널리 사용되는 형식으로 변환해야 할 수 있습니다.
Aspose.TeX API 솔루션은 TeX 파일을 변환하고 결과를 ZIP 아카이브로 저장하는 기능을 제공합니다. 여기에 제공된 코드 스니펫은 TeX 파일을 PDF로 변환하고 출력을 zip 파일로 저장하는 방법을 보여줍니다. API 변환기는 TeX 파일을 C++ 언어로 변환할 수 있으며 크로스 플랫폼 애플리케이션을 만들거나 C++ 프로젝트에 통합하는 데 사용할 수 있습니다.
예제를 실행하려면 기능이 풍부하고 사용하기 쉬운 C++ 플랫폼용 문서 조작 및 변환 도구인 Aspose.TeX for C++ API가 필요합니다. NuGet 패키지 관리자에서 검색하거나 패키지 관리자 콘솔에서 Install-Package Aspose.TeX 명령을 사용하여 Aspose.TeX API를 설치할 수 있습니다.
Package Manager Console Command
PM> Install-Package Aspose.TeX
여기 코드는 TeX 파일을 변환하고 ZIP 아카이브에 PDF로 저장하는 것입니다. 이러한 변환을 처리하려면 다음 단계를 수행하십시오.
- TeXOptions 클래스의 인스턴스를 만듭니다. OutputWorkingDirectory 속성을 사용하여 출력에 대한 ZIP 아카이브 작업 디렉터리를 지정하는 데 사용합니다.
- OutputConsoleTerminal 클래스를 사용하여 콘솔을 출력 터미널로 지정합니다.
- PdfSaveOptions 클래스를 사용하여 출력 저장 옵션을 정의합니다.
- PdfDevice에 대한 TeXJob() 메서드를 사용하여 TeX에서 PDF로의 변환을 실행합니다.
- 출력을 구체화합니다.
- OutputZipDirectory 클래스를 사용하여 출력 ZIP 아카이브를 마무리합니다. 코드는 프로세스 중에 발생할 수 있는 예외를 처리하기 위해 try-catch 블록을 사용합니다.
출력을 위해 ZIP 디렉토리를 사용하기 위한 C++ 코드
using Aspose::TeX::IO;
using Aspose::TeX::Presentation::Pdf;
using System::IO;
// Open a stream on a ZIP archive that will serve as the input working directory.
{
System::SharedPtr<System::IO::Stream> inZipStream = System::IO::File::Open(System::IO::Path::Combine(RunExamples::InputDirectory, u"zip-in.zip"), System::IO::FileMode::Open);
// Clearing resources under 'using' statement
System::Details::DisposeGuard<1> __dispose_guard_1({ inZipStream});
// ------------------------------------------
try{
System::SharedPtr<System::IO::Stream> outZipStream = System::IO::File::Open(System::IO::Path::Combine(RunExamples::OutputDirectory, u"zip-pdf-out.zip"), System::IO::FileMode::Create);
// Clearing resources under 'using' statement
System::Details::DisposeGuard<1> __dispose_guard_0({ outZipStream});
// ------------------------------------------
try
{
// Create typesetting options for default ObjectTeX format on ObjectTeX engine extension.
System::SharedPtr<TeXOptions> options = TeXOptions::ConsoleAppOptions(TeXConfig::ObjectTeX());
// Specify a ZIP archive working directory for the input.
options->set_InputWorkingDirectory(System::MakeObject<InputZipDirectory>(inZipStream, u"in"));
// Specify a ZIP archive working directory for the output.
options->set_OutputWorkingDirectory(System::MakeObject<OutputZipDirectory>(outZipStream));
// Specify the console as an output terminal.
options->set_TerminalOut(System::MakeObject<OutputConsoleTerminal>());
// Default. Not necessary to specify.
// Create and specify saving options.
options->set_SaveOptions(System::MakeObject<PdfSaveOptions>());
// Run typesetting.
Aspose::TeX::TeX::Typeset(u"hello-world", System::MakeObject<PdfDevice>(), options);
// For the consequent output to look right.
options->get_TerminalOut()->get_Writer()->WriteLine();
// Finalize the output ZIP archive.
(System::DynamicCast<Aspose::TeX::IO::OutputZipDirectory>(options->get_OutputWorkingDirectory()))->Finish();
}
catch(...)
{
__dispose_guard_0.SetCurrentException(std::current_exception());
}
}
catch(...)
{
__dispose_guard_1.SetCurrentException(std::current_exception());
}
}
TeX TeX 파일 형식이란 무엇입니까?
TeX는 실제로 형식이 아닙니다. 동시에 이 언어를 이해하는 것은 프로그래밍 언어이자 인터프리터 엔진입니다. TeX 파일은 LaTeX로 만든 문서입니다. 이 문서에는 그래픽, 표, 기호, 목록, 공식 및 방정식이 포함될 수 있습니다.