docx

Rails: How can I use system zip on Heroku to make a docx from an xml template?

陌路散爱 提交于 2019-12-02 06:40:22
问题 I have this working locally, storing the template files in #{Rails.root}/tmp , using system "cd tmp/template; zip -r ../#{@filename} *" to zip up the files, sending the .docx (zip archive) to S3 and then to the browser. The problem is that Heroku is not finding the files. Before I create the xml file, I am copying the template directory from another location ( system "cp -R support/ser_template tmp/" ). I understand Heroku's read-only filesystem but I can't have #{Process.pid} 's littering my

Forcing the browser to download a docx file in JAVA generates a corrupted document

淺唱寂寞╮ 提交于 2019-12-02 06:33:30
Using JAVA, I'm trying to force the browser to download files. Here is the code I currently use: response.reset(); response.resetBuffer(); response.setContentType(mimeType); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); InputStream in = new FileInputStream(file); OutputStream out = response.getOutputStream(); IOUtils.copy(in, out); out.flush(); out.close(); in.close(); response.flushBuffer(); It works almost well, but when forcing the download of a docx document (MS Office 2007+), the downloaded file is corrupted (at least, that's what MS Office tells

Problem saving edited zip archive (docx)

六眼飞鱼酱① 提交于 2019-12-02 06:25:19
So here is my code: <?php $zip = new ZipArchive; if ($zip->open('test.docx') === TRUE) { $xmlString = $zip->getFromName('word/document.xml'); $xmlString = str_replace('$FIRST_AND_LAST_NAME', 'John Doe', $xmlString); $zip->addFromString('word/document.xml', $xmlString); echo 'ok'; $zip->close(); } else { echo 'failed'; } Its purpose is simple. It opens a test.docx file, searches for all occurences of a string "$FIRST_AND_LAST_NAME" and replaces them with "John Doe". It works perfectly on my Windows development server (the "John Doe" string is in the docuemnt when I open it). It does not work on

what is wrong with this binary file transfer (corrupting docx files)?

时光总嘲笑我的痴心妄想 提交于 2019-12-02 06:14:26
问题 I've been trying to resolve this issue for over a week and could really do with some help. We are using a httprequest to post files to an api. Most files come out ok, but docx files end up corrupted. After much research I'm pretty sure that I'm doing something wrong in the binary post that is adding extra data / bytes to the file. Streams are being closed and I think I've got the boundries and headers right.... Are there any obvious mistakes in the code below? Or would anybody be able to

Retrieve document content with document structure with python-docx

梦想与她 提交于 2019-12-02 05:18:58
问题 I have to retrieve tables and previous/next paragraphs from docx file, but can't imagine how to obtain this with python-docx I can get a list of paragraphs by document.paragraphs I can get a list of tables by document.tables How can I get an ordered list of document elements like this [ Paragraph1, Paragraph2, Table1, Paragraph3, Table3, Paragraph4, ... ]? 回答1: python-docx doesn't yet have API support for this; interestingly, the Microsoft Word API doesn't either. But you can work around this

How to add comments to a .docx XML

匆匆过客 提交于 2019-12-02 04:03:07
At work, we have a word document that we have to edit all the time to pass on to another team, to tell them how to perform some tasks. Since I don't like mindlessly filling out data, and I always look for ways to simplify the tasks I have to do, I decided I would automate this process. After considering a few methods (such as generating a word document from scratch or editing an existing document), I decided to edit the document in-place. I have inserted special tags into the document (specifically, they take the form [SOME_NAME_HERE] ), and I will then parse the document for those special

Word转PDF

本秂侑毒 提交于 2019-12-02 02:49:39
一 .安装libreoffice yum install libreoffice 同时需要安装java运行环境 二.执行命令 将 /home/wordToPdf/wordFiles/目录下的CAS.docx转成pdf存放到 /home/wordToPdf/pdfFiles 目录下: libreoffice --headless --convert-to pdf:writer_pdf_Export /home/wordToPdf/wordFiles/CAS.docx --outdir /home/wordToPdf/pdfFiles 三.代码中执行 利用已有word模板,进行变量替换,生成新的word $PHPWord = new PhpWord(); $tempPlete = $PHPWord->loadTemplate(' /home/wordToPdf/wordFiles/CAS.docx'); $tempPlete->setValue('${p3-9}', '跨国有限公司'); $filename = date('YmdHis').'.docx'; $tempPlete->saveAs('/data/home/lijinyu/www/web/runtime/'.$filename); word转pdf $cmd = "libreoffice --headless -

Get content of docx file which saved in mysql dabase as blob type in php

主宰稳场 提交于 2019-12-02 01:23:47
I am saving docx file as BLOB type in mysql dadabase. after the saveing i am trying to see the content of the file through fetching the content of filed but it is showing some unreadable content.This this is working well for file having extention .doc but i don't know why it is not working for the .docx file.If any answer please help with proper explanation. Make a query to select the data, then put the result in a variable. Use file_put_content to get the docx file. Just be carefull with header. To read it, the process is different from a doc. You have to "unzip" the docx and read the xml

Rails: How can I use system zip on Heroku to make a docx from an xml template?

时光怂恿深爱的人放手 提交于 2019-12-02 01:18:18
I have this working locally, storing the template files in #{Rails.root}/tmp , using system "cd tmp/template; zip -r ../#{@filename} *" to zip up the files, sending the .docx (zip archive) to S3 and then to the browser. The problem is that Heroku is not finding the files. Before I create the xml file, I am copying the template directory from another location ( system "cp -R support/ser_template tmp/" ). I understand Heroku's read-only filesystem but I can't have #{Process.pid} 's littering my filenames (Word requires the xml file to be named document.xml). Is there anyway I can store the

Open Microsoft Word docx file with Java

落花浮王杯 提交于 2019-12-02 00:54:56
问题 How can I open a Microsoft Word docx file in Java? furthermore, how can I open it if it is password protected? For instance, File f = new File("hello.docx"); Please try to avoid responding with things such as "you shouldn't do this." I have a good reason for this, so please stick to the question when you answer. thanks a lot! 回答1: There is Apache POI project for working with MS Office files. DOCX file is just a zip file with series of XML files inside, so you can unzip the file and work with