docx

Nodejs docx-merger plugin “Word found unreadable content”

ぐ巨炮叔叔 提交于 2020-01-06 08:16:07
问题 I'm trying to merge docx files via docx-merger library. Everything is good, except of Microsoft Word's "Word found unreadable content in output.docx. Do you want to recover the contents of this document? If you trust the source of this document, click Yes." message. It opens the document when click to yes, but not the output file, just a buffer. Here is my code: const docxMerger = require('docx-merger'); fs.readdir('input/', (err, bufferFiles) => { var bufferFilesArr = []; bufferFiles.forEach

Possible to Insert page in word document with python-docx?

别等时光非礼了梦想. 提交于 2020-01-05 04:51:26
问题 I just read through the documentation on python-docx. They mention several times that added content is created at the end of the document, but I didn't notice any way to alter this functionality. Does anyone know how to add a new page to a pre-existing document, but make it page 1? Thanks! 回答1: The short answer is the library doesn't support that just yet, although those features are high on the backlog so will be among the next to be implemented. To get it done in the meantime you'll need to

How to read font size and font name in .docx in Apache POI(java)

狂风中的少年 提交于 2020-01-05 01:42:47
问题 Here is my code. XWPFRun run = runlist.get(0); double fontsize = (double)(run.getFontSize()); String fontfamily = (String)run.getFontFamily(); When it read the .docx file it will sometimes return -1 in font size and null in font family. I know that it's because they are default value but I don't want -1 and null I just want the name of that default value. How can I read it? 回答1: The font/character properties on a XWPFRun only return the override details, so settings which are different on

How to get an image (inlineshape) from paragraph python docx

你离开我真会死。 提交于 2020-01-04 06:06:46
问题 I want to read the docx document paragraph by paragraph and if there is a picture (InlineShape), then process it with the text around it. The function Document.inline_shapes will give the list of all inline shapes in the document. But I want to get the one, that appears exactly in the current paragraph if exists... An example of code: from docx import Document doc = Document("test.docx") blip = doc.inline_shapes[0]._inline.graphic.graphicData.pic.blipFill.blip rID = blip.embed document_part =

python docx align both left and right on same line

旧城冷巷雨未停 提交于 2020-01-04 05:51:21
问题 This is my first question on SO and would like to thank you all in advance for any help. I'm pretty new to python, python-docx and programming in general. I am working on a GUI program (using PyQt) to generate a contract in docx format. I have most things working, but here is the problem I am having. I need to align text both left and right on the same line. In word, I believe this is done by changing to a right indent and hitting tab, then adding the text. However, I cannot figure out how to

python docx align both left and right on same line

為{幸葍}努か 提交于 2020-01-04 05:51:01
问题 This is my first question on SO and would like to thank you all in advance for any help. I'm pretty new to python, python-docx and programming in general. I am working on a GUI program (using PyQt) to generate a contract in docx format. I have most things working, but here is the problem I am having. I need to align text both left and right on the same line. In word, I believe this is done by changing to a right indent and hitting tab, then adding the text. However, I cannot figure out how to

Docx4j export style from one .docx and use it in another .docx

纵饮孤独 提交于 2020-01-04 05:38:06
问题 I am creating new Word document with the code below: Tidy tidy = new Tidy(); tidy.setShowWarnings(true); tidy.setInputEncoding("UTF-8"); tidy.setOutputEncoding("UTF-8"); tidy.setXHTML(true); tidy.setMakeClean(true); tidy.setQuoteNbsp(false); WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(); XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage); for (Value v : res.getRules()) { System.out.println(v.toString()); ByteArrayOutputStream ou = new

Resize existing image in DocX using OpenXML sdk

房东的猫 提交于 2020-01-04 04:03:10
问题 Got template docx with image placeholder which replaced by correct picture. private void SetImagePartData(ImagePart imagePart, byte[] data) { if (imagePart != null) { using (var writer = new BinaryWriter(imagePart.GetStream())) { writer.Write(data); } } } but it preserves placeholder size. How to change it to actual image size? Byte array is aqquared from image on server, so size is known. 回答1: If you mean a content control with your placeholder you can use following code I once needed: //Get

Function to get the content of a docx in php

蹲街弑〆低调 提交于 2020-01-03 05:32:05
问题 private function read_docx($filename) { var_dump($filename); $striped_content = ''; $content = ''; $zip = zip_open($filename); if (!$zip || is_numeric($zip)) return false; while ($zip_entry = zip_read($zip)) { if (zip_entry_open($zip, $zip_entry) == FALSE) continue; if (zip_entry_name($zip_entry) != "word/document.xml") continue; $content .= zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); zip_entry_close($zip_entry); }// end while zip_close($zip); $content = str_replace('</w:r></w

why are docx files corrupted by binary post, but .doc and .pdf are fine?

邮差的信 提交于 2020-01-03 05:19:21
问题 I'm posting files to an API in binary format. .pdf and .doc files are fine - they arrive in the system as expected and open up without any problems. But for some reason, .docx files show up as corrupt. Why would that be? Sub PostTheFile(CVFile, fullFilePath, PostToURL) strBoundary = "---------------------------9849436581144108930470211272" strRequestStart = "--" & strBoundary & vbCrlf &_ "Content-Disposition: attachment; name=""file""; filename=""" & CVFile & """" & vbcrlf & vbcrlf