문서 저장

Aspose.Words에서 수행해야 하는 대부분의 작업은 문서 저장과 관련이 있습니다. 문서 저장Aspose.Words은Document클래스의Save메서드를 제공합니다. 문서는Aspose.Words에서 지원하는 모든 저장 형식으로 저장할 수 있습니다. 지원되는 모든 저장 형식의 목록은SaveFormat열거형을 참조하십시오.

파일에 저장

단순히 파일 이름으로Save방법을 사용합니다. Aspose.Words는 지정한 파일 확장명에서 저장 형식을 결정합니다.

다음 코드 예제에서는 문서를 로드하고 파일에 저장하는 방법을 보여 줍니다:

// 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(LoadAndSave.class);
Document doc = new Document(dataDir+ "Test File (doc).doc");
// Save the finished document to disk.
doc.save(dataDir + "Test File (doc)_out.doc", SaveFormat.PNG);

스트림에 저장

스트림 개체를Save메서드에 전달합니다. 스트림에 저장할 때 저장 형식을 명시적으로 지정해야 합니다.

다음 코드 예제에서는 문서를 스트림에 로드하고 저장하는 방법을 보여 줍니다:

// 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(LoadAndSaveToStream.class);
String inputFile = "Test File (doc).doc";
String outputFile = "output.png";
InputStream in = new FileInputStream(dataDir + inputFile);
OutputStream out = new FileOutputStream(dataDir + outputFile);
Document doc = new Document(in);
// Save the finished document to disk.
doc.save(out, SaveFormat.PNG);

이 예제의 템플릿 파일은 다음에서 다운로드할 수 있습니다 Aspose.Words GitHub.

PCL {#save-a-document-to-pcl}에 저장

Aspose.WordsPCL(프린터 명령 언어)에 문서 저장을 지원합니다. Aspose.Words문서를PCL6(PCL6 강화 또는PCLXL)형식으로 저장할 수 있습니다. PclSaveOptions클래스는PCL형식으로 문서를 저장할 때 추가 옵션을 지정하는 데 사용할 수 있습니다.

다음 코드 예제에서는 저장 옵션을 사용하여 문서를PCL에 저장하는 방법을 보여 줍니다:

// 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(ConvertDocumentToPCL.class);
// Load the document from disk.
Document doc = new Document(dataDir + "Document.doc");
PclSaveOptions saveOptions = new PclSaveOptions();
saveOptions.setSaveFormat(SaveFormat.PCL);
saveOptions.setRasterizeTransformedElements(false);
// Export the document as an PCL file.
doc.save(dataDir + "Document.PclConversion_out.pcl", saveOptions);