Code Monkey home page Code Monkey logo

start-word2pdf's Introduction

start-word2pdf 帮助文档

快速部署一个word转pdf的应用到阿里云函数计算

部署 & 体验

应用详情

项目部署完成,可以通过invoke命令进行触发/测试:

# 调用
$ s invoke -e '{"word_file":"example.docx"}'

函数调用成功后,生成的 pdf 文件在和 docx 相同的 OSS 目录中,比如这个例子是在 example.pdf。

如果您想 word 转 pdf 同时再加上水印, 需要增加如下相关的参数:

{
    "word_file": "example.docx",  
    "mark_text": "AliyunFC",  // 水印文字, 如果给 PDF 加水印,该参数必填
    "pagesize": [595.275590551181, 841.8897637795275], // 可选参数,默认是 A4 大小, (21*cm, 29.7*cm), 其中 1cm=28.346456692913385
    "font": "Helvetica", // 字体,可选参数, 默认为 Helvetica,  中文字体可选择为 zenhei 或 microhei
    "font_size": 30, // 字体d大小,可选参数, 默认为 30
    "font_color": [0, 0, 0], // 字体颜色,格式为 RGB, 默认为黑色
    "rotate": 30, // 旋转角度, 可选参数, 默认为 0
    "opacity": 0.1, // 透明度, 可选参数, 默认为 0.1, 1 表示不透明
    "density": [198.4251968503937, 283.46456692913387] // 水印密度,水印文字间隔,默认是 [141.73228346456693, 141.73228346456693],即(7*cm, 10*cm),  表示每个水印文字在横坐标和纵坐标的间隔分别是 7cm 和 10cm
}

比如:

$ s invoke -e '{"word_file":"example.docx", "mark_text": "AliyunFC", "rotate":30}'

# 如果是中文水印, font 为 zenhei 或者 microhei
$ s invoke -e '{"word_file":"example.docx", "mark_text": "函数计算", "rotate":30, "font": "zenhei"}'

生成带有水印的 example.pdf 示例:

其他

如果进行二次开发, 有新的依赖 python lib, 可以直接使用如下命令:

$ s build --use-sandbox
# 进入 sandbox 后
$ s-install pip install xxx

# exit 退出, 然后重新 s deploy 即可

开发者社区

您如果有关于错误的反馈或者未来的期待,您可以在 Serverless Devs repo Issues 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:

微信公众号:serverless 微信小助手:xiaojiangwh 钉钉交流群:33947367

start-word2pdf's People

Contributors

rsonghuster avatar anycodes avatar heimanba avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.