Node.js에서 Word 문서를 JPEG, PNG 또는 GIF 그림으로 변환합니다.

Node.js에서 Word 문서를 JPG, PNG 또는 GIF 이미지로 변환

이전 기사에서 프로그래밍 방식으로 PDF를 JPG, PNG 및 GIF 형식으로 변환하는 과정을 시연했습니다. 이 블로그 게시물은 Node.Js 이미지 라이브러리를 사용하여 Word를 JPEG, GIF 및 PNG로 변환하는 방법을 알려줍니다. Word는 문서 공유 및 인쇄에 널리 사용되는 형식 중 하나입니다. 우리는 종종 워드 문서를 다른 이미지 형식으로 변환해야 합니다. 필요에 따라 쉽게 유지 관리할 수 있고 유연한 변환 솔루션을 제공하는 이미 개발된 특수 도구를 사용하는 것이 좋습니다. 이 기사에서는 Node.js에서 Word 문서를 JPG, PNG 또는 GIF 이미지로 변환하는 방법을 배웁니다.

이 기사에서는 다음 주제에 대해 설명합니다.

Word to Image Converter REST API 및 Node.js SDK

이 기사에서는 GroupDocs.Conversion Cloud의 Node.js SDK API를 사용하여 Node.js 애플리케이션에서 Word DOCX를 JPEG, PNG 또는 GIF 이미지로 변환합니다. 이 API를 사용하면 문서를 필요한 형식으로 변환할 수 있습니다. Word, Excel, PowerPoint, PDF, HTML, JPG, PNG 및 CAD와 같은 50개 이상의 문서 및 이미지 변환을 지원합니다. 또한 Cloud API용 문서 변환 제품군으로 .NET, Java, PHP, Ruby, Android 및 Python SDK를 제공합니다.

콘솔에서 다음 명령을 사용하여 GroupDocs.Conversion Cloud를 Node.js 애플리케이션에 설치할 수 있습니다.

npm install groupdocs-conversion-cloud

단계와 사용 가능한 코드 예제를 시작하기 전에 대시보드에서 클라이언트 ID와 클라이언트 암호를 얻으십시오. ID와 시크릿이 있으면 아래와 같이 코드를 추가합니다.

# http://api.groupdocs.cloud에서 노드 애플리케이션의 Node.js SDK 가져오기
global.groupdocs_conversion_cloud = require("groupdocs-conversion-cloud");
global.fs = require("fs");

// https://dashboard.groupdocs.cloud에서 clientId 및 clientSecret을 가져옵니다(무료 등록 필요).
global.clientId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
global.clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
global.myStorage = "test-internal-storage";
const config = new groupdocs_conversion_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

Node.js에서 REST API를 사용하여 Word를 JPG 형식으로 변환

아래의 간단한 단계에 따라 Word를 JPEG 이미지 파일로 변환할 수 있습니다.

  1. 업로드 워드 파일을 클라우드에
  2. 변환 Node.js에서 온라인으로 무료로 Word를 JPG 이미지로 변환
  3. 다운로드 변환된 JPG 파일

이미지 업로드

먼저 다음 코드 샘플을 사용하여 단어 파일을 클라우드에 업로드합니다.

// 시스템 드라이브에서 IOStream의 파일을 엽니다.
var resourcesFolder = 'H:\\groupdocs-cloud-data\\sample-file.docx';
// 파일 읽기
fs.readFile(resourcesFolder, (err, fileStream) => {
  // FileApi 구성
  var fileApi = groupdocs_conversion_cloud.FileApi.fromConfig(config);
  // 업로드 파일 요청 생성
  var request = new groupdocs_conversion_cloud.UploadFileRequest("sample-file.docx", fileStream, myStorage);
  // 파일 업로드
  fileApi.uploadFile(request)
    .then(function (response) {
      console.log("Expected response type is FilesUploadResult: " + response.uploaded.length);
    })
    .catch(function (error) {
      console.log("Error: " + error.message);
    });
});

결과적으로 업로드된 워드 파일은 클라우드 대시보드의 파일 섹션에서 사용할 수 있습니다.

Node.js를 사용하여 온라인에서 Word를 JPG 파일로 변환

프로그래밍 방식으로 Word를 JPG 파일로 변환하려면 아래에 언급된 단계를 따르십시오.

  • ConvertApi의 인스턴스 생성
  • ConvertSettings 인스턴스 만들기
  • 워드 파일 경로 설정
  • 형식에 “jpg” 할당
  • 출력 파일 경로 제공
  • ConvertDocumentRequest 만들기
  • ConvertApi.convertDocument() 메서드를 호출하여 결과 얻기

다음 코드 예제는 Node.js에서 REST API를 사용하여 품질 손실 없이 단어를 jpg로 변환하는 방법을 보여줍니다.

// Node.js에서 REST API를 사용하여 Word를 JPG 형식으로 변환하는 방법
const convert = async () => {
  const convertApi = groupdocs_conversion_cloud.ConvertApi.fromKeys(clientId, clientSecret);

  const settings = new groupdocs_conversion_cloud.ConvertSettings();
  settings.storageName = myStorage;
  settings.filePath = "nodejs-testing/sample-file.docx";
  settings.format = "jpg";
  settings.outputPath = "nodejs-testing/sample-file.jpg";

  try {
    // 변환 문서 요청 생성
    const request = new groupdocs_conversion_cloud.ConvertDocumentRequest(settings);
    await convertApi.convertDocument(request);
  }
  catch (err) {
    throw err;
  }
}

convert()
.then(() => {
  console.log("Successfully converted Word Doc to JPG file format.");
})
.catch((err) => {
  console.log("Error occurred while converting the Word document:", err);
})

변환된 파일 다운로드

위의 코드 샘플은 변환된 워드 파일을 클라우드에 저장합니다. 다음 코드 샘플을 사용하여 다운로드할 수 있습니다.

// FileApi를 구성하여 변환된 파일 다운로드
var fileApi = groupdocs_conversion_cloud.FileApi.fromConfig(config);
// 다운로드 파일 요청 생성
let request = new groupdocs_conversion_cloud.DownloadFileRequest("nodejs-testing/sample-file.jpg", myStorage);
// 다운로드 파일 및 응답 유형 스트림
fileApi.downloadFile(request)
    .then(function (response) {
        // 시스템 디렉토리에 파일 저장
        fs.writeFile("H:\\groupdocs-cloud-data\\sample-file.jpg", response, "binary", function (err) { });
        console.log("Expected response type is Stream: " + response.length);
    })
    .catch(function (error) {
        console.log("Error: " + error.message);
    });

고급 옵션을 사용하여 Word를 JPEG 이미지로 변환

몇 가지 고급 설정과 함께 Word to JPEG 고품질 온라인 변환기 API를 사용하여 아래 언급된 단계를 따르십시오.

  • ConvertApi의 인스턴스 생성
  • ConvertSettings 인스턴스 만들기
  • 워드 파일 경로 설정
  • 형식에 “jpeg” 할당
  • 출력 파일 경로 제공
  • JpegConvertOptions 정의
  • 그런 다음 grayscale, fromPage, pagesCount, quality, rotateAngle, usePdf 등과 같은 다양한 변환 설정을 지정합니다.
  • ConvertDocumentRequest 만들기
  • ConvertApi.convertDocument() 메서드를 호출하여 결과 얻기

다음 코드 예제는 고급 변환 옵션을 사용하여 온라인에서 단어를 jpeg 형식으로 변환하는 방법을 보여줍니다.

// 고급 옵션을 사용하여 Word를 JPEG 이미지로 변환하는 방법
const convert_options = async () => {
  const convertApi = groupdocs_conversion_cloud.ConvertApi.fromKeys(clientId, clientSecret);

  const settings = new groupdocs_conversion_cloud.ConvertSettings();
  settings.storageName = myStorage;
  settings.filePath = "nodejs-testing/sample-file.docx";
  settings.format = "jpeg";
  
  convertOptions = new groupdocs_conversion_cloud.JpegConvertOptions()
  convertOptions.grayscale = true;
  convertOptions.fromPage = 1;
  convertOptions.pagesCount = 1;
  convertOptions.quality = 100;
  convertOptions.rotateAngle = 90;
  convertOptions.usePdf = false;

  settings.convertOptions = convertOptions;
  settings.outputPath = "nodejs-testing/sample-file.jpeg";

  try {
    // 변환 문서 요청 생성
    const request = new groupdocs_conversion_cloud.ConvertDocumentRequest(settings);
    await convertApi.convertDocument(request);
  }
  catch (err) {
    throw err;
  }
}

convert_options()
.then(() => {
  console.log("Converted Word to JPEG file online using advanced options.");
})
.catch((err) => {
  console.log("Error occurred while converting the Word file:", err);
})

Node.js를 사용하여 온라인에서 Word를 PNG 이미지로 변환하는 방법

프로그래밍 방식으로 Word를 PNG 파일로 변환하려면 아래에 언급된 단계를 따르십시오.

  • ConvertApi의 인스턴스 생성
  • ConvertSettings 인스턴스 만들기
  • 워드 파일 경로 설정
  • 형식에 “png” 할당
  • 출력 파일 경로 제공
  • ConvertDocumentRequest 만들기
  • ConvertApi.convertDocument() 메서드를 호출하여 결과 얻기

다음 코드 예제는 Node.js에서 REST API를 사용하여 품질 손실 없이 단어를 png로 변환하는 방법을 보여줍니다.

// Node.js를 사용하여 온라인에서 Word를 PNG 이미지로 변환하는 방법
const convert = async () => {
  const convertApi = groupdocs_conversion_cloud.ConvertApi.fromKeys(clientId, clientSecret);

  const settings = new groupdocs_conversion_cloud.ConvertSettings();
  settings.storageName = myStorage;
  settings.filePath = "nodejs-testing/sample-file.docx";
  settings.format = "png";
  settings.outputPath = "nodejs-testing/sample-file.png";

  try {
    // 변환 문서 요청 생성
    const request = new groupdocs_conversion_cloud.ConvertDocumentRequest(settings);
    await convertApi.convertDocument(request);
  }
  catch (err) {
    throw err;
  }
}

convert()
.then(() => {
  console.log("Successfully converted Word to PNG file format.");
})
.catch((err) => {
  console.log("Error occurred while converting the Word document:", err);
})

Node.js를 사용하여 온라인에서 Word를 GIF 파일로 변환하는 방법

프로그래밍 방식으로 Word를 GIF 파일로 변환하려면 아래에 언급된 단계를 따르십시오.

  • ConvertApi의 인스턴스 생성
  • ConvertSettings 인스턴스 만들기
  • 워드 파일 경로 설정
  • 형식에 “gif” 할당
  • 출력 파일 경로 제공
  • ConvertDocumentRequest 만들기
  • ConvertApi.convertDocument() 메서드를 호출하여 결과 얻기

다음 코드 예제는 Node.js에서 REST API를 사용하여 품질 손실 없이 단어를 gif로 변환하는 방법을 보여줍니다.

// Node.js를 사용하여 온라인에서 Word를 GIF 형식으로 변환하는 방법
const convert = async () => {
  const convertApi = groupdocs_conversion_cloud.ConvertApi.fromKeys(clientId, clientSecret);

  const settings = new groupdocs_conversion_cloud.ConvertSettings();
  settings.storageName = myStorage;
  settings.filePath = "nodejs-testing/sample-file.docx";
  settings.format = "gif";
  settings.outputPath = "nodejs-testing/sample-file.gif";

  try {
    // 변환 문서 요청 생성
    const request = new groupdocs_conversion_cloud.ConvertDocumentRequest(settings);
    await convertApi.convertDocument(request);
  }
  catch (err) {
    throw err;
  }
}

convert()
.then(() => {
  console.log("Successfully converted Word to GIF image file.");
})
.catch((err) => {
  console.log("Error occurred while converting the Word document:", err);
})

온라인 워드-이미지 변환기

Word DOC 이미지 파일을 온라인으로 변환하는 방법은 무엇입니까? 다음 word-to-jpg, word-to-jpeg, word-to-png 또는 word-to-gif를 온라인에서 무료로 사용해 보십시오. 위의 API를 사용하여 개발된 to 이미지 변환기.

결론

이것으로 블로그 포스팅을 마칩니다. 다음을 배웠기를 바랍니다.

  • 클라우드에서 단어를 JPG 형식으로 변경하는 방법
  • 고급 옵션을 사용하여 단어를 JPEG로 변환하는 방법
  • 프로그래밍 방식으로 워드 파일을 업로드한 다음 클라우드에서 변환된 파일을 다운로드합니다.
  • 프로그래밍 방식으로 클라우드에서 단어를 png 파일 형식으로 변환합니다.
  • 클라우드에서 단어를 GIF 이미지 형식으로 변환하는 방법

문서를 사용하여 GroupDocs.Conversion Cloud API에 대해 자세히 알아볼 수 있습니다. 또한 브라우저를 통해 직접 API를 시각화하고 상호 작용할 수 있는 API 참조 섹션을 제공합니다.

또한 시작하기 매뉴얼을 읽어 보시기 바랍니다.

Groupdocs.cloud는 때때로 새로운 주제에 대한 블로그 기사를 게시합니다. 최신 업데이트를 위해 연락을 유지하는 것이 중요합니다.

질문하기

무료 지원 포럼을 통해 단어를 이미지 형식으로 변환하는 방법에 대해 질문할 수 있습니다.

FAQ

Node.js에서 Word 문서를 JPG로 어떻게 변환합니까?

Word to JPG를 방문하여 Word 문서를 JPG 파일 형식으로 빠르고 쉽게 변환하는 코드를 배우십시오.

REST API를 사용하여 문서를 JPG로 변환할 수 있습니까?

ConvertApi의 인스턴스를 생성하고, 변환 설정 값을 설정하고, DOCX 문서를 JPG 이미지로 변환하기 위해 ConvertDocumentRequest와 함께 ConvertDocument 메서드를 호출합니다.

온라인에서 무료로 Word를 JPG로 변환하는 방법은 무엇입니까?

온라인에서 무료로 제공되는 Word to JPG 변환기를 사용하면 빠르고 쉽게 Word를 JPG 형식으로 내보낼 수 있습니다. 변환이 완료되면 JPG 파일을 다운로드할 수 있습니다.

무료로 Word 문서를 JPG로 변환하는 방법은 무엇입니까?

  • 무료 온라인 Word to JPG 변환기 열기
  • 파일 드롭 영역 내부를 클릭하여 Word를 업로드하거나 Word 파일을 끌어다 놓습니다.
  • 지금 변환 버튼을 클릭하면 온라인 Word to JPG 변환기 소프트웨어가 Word 파일을 JPG로 변환합니다.
  • 출력 파일의 다운로드 링크는 Word를 JPG 파일로 변환한 후 즉시 사용할 수 있습니다.

Word to JPG 형식 변환기 무료 다운로드 라이브러리를 설치하는 방법은 무엇입니까?

DOC to JPG 변환기Node.js 라이브러리 무료 다운로드를 다운로드하고 설치하여 프로그래밍 방식으로 Word를 JPG 이미지로 생성, 처리 및 변환합니다.

Windows에서 오프라인으로 Word를 JPG로 어떻게 변환합니까?

이 오프라인 Word to JPG 변환기 Windows 소프트웨어를 무료로 다운로드하십시오. 이 온라인 Word DOC 또는 DOCX to JPG 변환기 무료 다운로드 도구는 한 번의 클릭으로 Windows에서 문서를 JPG 사진으로 빠르게 변환합니다.

또한보십시오

자세한 내용은 다음 문서를 참조하십시오.