npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cute-office-utils

v1.0.7

Published

一款轻量级的 Office 工具库,包括转化 WORD、PPT、EXCEL 转为 PDF,将 Office 指定页面 转为 图片

Readme

CUTE-OFFICE-UTILS

EXCEL/PDF/WORD/PPT 转为PDF 多页面/指定页面转为图片

介绍

一款轻量级的 Office 工具库,包括转化 WORD、PPT、EXCEL 转为 PDF,将 Office 指定页面 转为 图片

gitee 地址 https://gitee.com/luochen-yuntian/cute-office-utils

github 地址 https://github.com/MXY-YT/cute-office-utils


安装教程

一、安装依赖

npm : npm install cute-office-utils

yarn : yarn add cute-office-utils

pnpm : pnpm install cute-office-utils

二、 安装依赖软件 (可按照需求下载指定软件)

1、多页面/指定页面转为图片 所需软件 GraphicsMagick 安装指南

Windows

添加环境变量:

  • C:\Program Files\gs\gs****\bin
  • C:\program files\graphicsmagick-****

注意:当 Ghostscript 版本为 9.53 或更高时可能会出现错误。

Linux (基于 Debian 的系统)
    sudo apt-get update
    sudo apt-get install ghostscript
    sudo apt-get install graphicsmagick
MacOS
    brew update
    brew install gs graphicsmagick

2、Office 转为 PDF 所需软件 下载 LibreOffice

可参考文章 office 转 pdf

使用说明

1、Office 文件转 PDF

import { CuteConvert } from 'cute-office-utils/dist'; 
const cuteConvert = new CuteConvert("D:\\**\\cute-office-utils\\test.pptx") // 文件完整路径
cuteConvert.to_pdf().then(res => {
    console.log(res)
})

执行结果

{
  inputFilePath: 'D:\\**\\cute-office-utils\\test.pptx', // 源文件
  outputFilePath: 'D:\\**\\cute-office-utils\\cuteConvert', // 输出文件路径
  result: {
    success: true, // 执行结果
    message: '命令执行成功', // 执行结果信息
    stdout: 'convert D:\\**\\cute-office-utils\\test.pptx as a Impress document -> D:\\**\\cute-office-utils\\cuteConvert\\test.pdf mpress_pdf_Export\n' +
      'Overwriting: D:\\**\\cute-office-utils\\cuteConvert\\test.pdf\n', // 执行命令信息
    stderr: '' // 执行命令错误信息
  }
}

完整参数示例

import { CuteConvert } from 'cute-office-utils/dist';
const cuteConvert = new CuteConvert("D:\\**\\cute-office-utils\\test.pptx")
cuteConvert.to_pdf({
    debug: true, // 调试模式 (打印到控制台), 默认 true
    output: {
        fileDir: 'D:\\**\\cute-office-utils\\test', // 生成的 PDF文件 文件目录 默认 ./cuteConvert
    }
}).then(res => {
    console.log(res)
})

2、Office 文件 指定页面 转 图片

cuteConvert.to_image().then(res => {
    console.log(res)
})

执行结果

{
  inputFilePath: 'D:\\**\\cute-office-utils\\test.pptx', // 源文件
  outputFilePath: 'D:\\**\\cute-office-utils\\cuteConvert', // 输出文件目录
  result: [ 
     {     
      success: true, // 执行结果
      message: '命令执行成功',  // 执行结果信息
      stdout: '',  // 执行命令输出
      stderr: '' // 执行命令错误信息 
     } 
  ]
}

完整参数示例

const cuteConvert = new CuteConvert("D:\\**\\cute-office-utils\\test.pptx")
cuteConvert.to_image({
    /**
     * 页码 ( 支持 N 、'N-M' 、 [ N, M, ...] )
     *  N: N 页 ( 第 N 页 )
     *  'N-M': N 页到 M 页  ( 包含 N 和 M )
     *  [ N, M, ... ]: 列表中的每一页
     */
    page: [5, 8], // 默认全部页面
    debug: true, // 调试模式 (打印到控制台), 默认 true
    clearCache: true, // 转换完成后是否删除源文件(仅删除中间 PDF文件, 源文件如果是 PDF 文件,则不会删除),默认 true
    dpi: 300, // 分辨率,默认 300
    output: {
        fileDir: 'D:\\**\\cute-office-utils\\test', // 生成的图片 文件目录 默认 ./cuteConvert
        fileName: 'test', // 文件名 默认 原文件名-${页数}
        suffix: 'png', // 后缀名 默认 png
    }
}).then(res => {
    console.log(res)
})

函数

1、to_pdf (Office 转 PDF)

| 参数 | 类型 | 描述 | 默认值 | 是否必须 | 返回值 | 是否异步 | |:--------:|:-------------------:|:---:|:---:|:----:|:-----------------------:|:----:| | option | OfficeToPDFOption | 配置项 | - | 否 | Result<ExecuteResult> | 是 |

    to_pdf(option?: OfficeToPDFOption): Promise<Result<ExecuteResult>>

1、to_image (Office 指定页面 转 图片)

| 参数 | 类型 | 描述 | 默认值 | 是否必须 | 返回值 | 是否异步 | |:--------:|:---------------------:|:---:|:---:|:----:|:-------------------------:|:----:| | option | OfficeToImageOption | 配置项 | - | 否 | Result<ExecuteResult[]> | 是 |

    to_image(option?: OfficeToImageOption): Promise<Result<ExecuteResult[]>>

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

联系作者邮箱 ([email protected]