• 请不要在回答技术问题时复制粘贴 AI 生成的内容
iSNN
V2EX  ›  程序员

请教各位上传文件后在 web 直接查看有什么好的方案吗

  •  
  •   iSNN · May 26, 2021 · 4382 views
    This topic created in 1990 days ago, the information mentioned may be changed or developed.

    img 和 pdf 都好解决,其中还有 office 文件

    目前就是 office 文件有点麻烦,先想的是转成 pdf,用了 spire 相关的来转,但是中文全是白框,但是服务器上的中文都是正常显示的

    不知各位大佬们有没有什么好的办法

    17 replies  •  2021-05-28 18:47:46 +08:00
    yakumo520
    yakumo520
    May 26, 2021
    1
    白框是编码字符集不对,检查一下 pdf 转 word 比较成熟,多看看吧
    iSNN
    iSNN
    OP
    May 26, 2021
    2
    @yakumo520 服务器上命令行打开文件显示中文是正常的,你说的哪个字符集就不知道了...
    wyx119911
    wyx119911
    May 26, 2021
    3
    office 想预览花钱买服务吧,自己做效果不行的
    DonaldY
    DonaldY
    May 26, 2021
    4
    白框可能是识别不了字体(没有对应的字体),excel 可转 html
    libreoffice 可以试试
    iSNN
    iSNN
    OP
    May 26, 2021
    5
    @wyx119911 看到微软有个 view.officeapps.live.com/op/embed.aspx 接口,不知道能不能商用。

    或者老哥能推荐比较靠谱的接口吗
    renmu123
    renmu123
    May 26, 2021 via Android
    6
    ie 支持 word 预览(笑)
    jtacm
    jtacm
    May 26, 2021
    7
    libreoffice 可以把 Office 转成 PDF
    0044200420
    0044200420
    May 26, 2021
    8
    后端转换 pdf
    vueli
    vueli
    May 27, 2021
    9
    我记得有个微软的一个接口, 在线转换阅读. 找不到了, 我可以肯定有
    h4de5
    h4de5
    May 27, 2021
    10
    iSNN
    iSNN
    OP
    May 27, 2021
    11
    @vueli 5L 的接口,但是可商用吗...
    iSNN
    iSNN
    OP
    May 27, 2021
    12
    @DonaldY libreoffice 有上方 v 友所说的字符集问题的,虽然我从表现看是字符问题,但没确定,因为服务器上打开中文的文件是正常的
    DonaldY
    DonaldY
    May 27, 2021
    13
    @iSNN 字符集指什么?
    MilkShake
    MilkShake
    May 27, 2021
    14
    libreoffice
    image72
    image72
    May 28, 2021
    15
    使用 google docs 或者 office 365 在线预览
    ···
    <iframe src="https://docs.google.com/gview?url=http://remote.url.tld/path/to/document.doc&embedded=true"></iframe>

    <iframe src='https://view.officeapps.live.com/op/embed.aspx?src=http://remote.url.tld/path/to/document.doc' width='1366px' height='623px' frameborder='0'>This is an embedded <a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office.com/webapps'>Office Online</a>.</iframe>
    ···

    Convert Word documents (.docx files) to HTML

    mammoth.js
    MarioLuo
    MarioLuo
    May 28, 2021 via Android
    16
    可搭建独立的文件预览服务,使用: https://github.com/kekingcn/kkFileView
    iSNN
    iSNN
    OP
    May 28, 2021
    17
    @MarioLuo 谢谢老哥,我昨晚也看到这个项目了,很好用。开源大法好,根据业务需求也修改了一些地方
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1358 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 17:11 · PVG 01:11 · LAX 09:11 · JFK 12:11
    ♥ Do have faith in what you're doing.