docx

Is there any way to generate a thumbnail image of a DOCX file?

泄露秘密 提交于 2019-12-04 08:10:05
I have done this using "pay" tools like ASPOSE, but I was curious if there are any open source tools out there that will do this. I am sure there may be tools out there to do that, but if you can get the file into a format that can then be rasterized easily, it may be worth exploring that. eg converting the work doc to pdf then thumbnailing that. 来源: https://stackoverflow.com/questions/5921761/is-there-any-way-to-generate-a-thumbnail-image-of-a-docx-file

Corrupt document after calling AddAlternativeFormatImportPart using OpenXml

两盒软妹~` 提交于 2019-12-04 08:07:52
I am trying to create an AddAlternativeFormatImportPart in a .docx file in order to reference it in the document via an AltChunk. the problem is that the code below causes the docx file to read as corrupted by Word and cannot be opened. string html = "some html code." string altChunkId = "html234"; var document = WordprocessingDocument.Open(inMemoryPackage, true); var mainPart = document.MainDocumentPart.Document; var mainDocumentPart = document.MainDocumentPart; AlternativeFormatImportPart chunk = mainDocumentPart.AddAlternativeFormatImportPart (AlternativeFormatImportPartType.Xhtml,

微服务之间调用控制器注解类型的差异

给你一囗甜甜゛ 提交于 2019-12-04 07:30:22
今天在一个业务服务通过Feign调用文件服务上传文件时遇到了几个问题: 1. 提示http请求头过大的问题; 此时需要修改bootstrap.yml,加入 server: max-http-header-size: 10000000 用以放大尺寸 2. 调用方法时提示404,无返回结果; 解决方法:把控制器的注解由@Controller变为@RestController,就可以 被调用方具体代码如下: @Slf4j @RestController @RequestMapping("/image") public class ImageController { private static List<String> allowUploadSuffixes = new ArrayList<>(Arrays.asList("png", "jpg", "jpeg", "zip", "pdf", "xls", "xlsx", "rar", "doc", "docx")); @Autowired private UploadFileEntityMapper uploadFileEntityMapper; @RequestMapping(value = "/uploadBase64", method = RequestMethod.POST) @ApiOperation(value =

Python读取word文档(python-docx包)

。_饼干妹妹 提交于 2019-12-04 06:55:39
最近想统计word文档中的一些信息,人工统计的话。。。三天三夜吧 python 不愧是万能语言,发现有一个包叫做 docx,非常好用,具体查看官方文档: https://python-docx.readthedocs.io/en/latest/index.html (v0.8.6) 还有一个是 win32com 包,这个包安装步骤如下: http://jingyan.baidu.com/article/d3b74d64c853081f77e60929.html 安装好 win32com之后安装 docx包: pip install python-docx import docx from win32com import client as wc import matplotlib.pyplot as plt from collections import Counter import os # 首先将doc转换成docx word = wc.Dispatch( "Word.Application" ) # 找到word路径 + 文件名 ,即可打开文件 full_path = 'C:\\Users\\ASUS\\Desktop\\test.docx' doc = word.Documents.Open(full_path) # 使用参数16表示将doc转换成docx

C# 设置Word文档中图片的大小

爷,独闯天下 提交于 2019-12-04 06:48:40
在创建Word文档时,我们经常需要向文档中插入图片,但插入图片的大小有时候可能会太大或太小,这时候我们就需要对图片的大小进行调整,使得图片与文章更加协调、美观。这篇文章将介绍如何使用 Free Spire.Doc 组件和C#在Word文档中对新添加的图片和已有的图片进行大小设置。 在使用以下代码前需要创建一个C#应用程序并引用Spire.Doc.dll到工程中。 对新添加的图片进行大小设置 //创建Document实例 Document document = new Document(); //添加节和段落 Section s = document.AddSection(); Paragraph p = s.AddParagraph(); //添加图片到段落 DocPicture Pic = p.AppendPicture(Image.FromFile(@"MickeyMouse.jpg")); picture.TextWrappingStyle = TextWrappingStyle.Square; picture.HorizontalPosition = 180f; picture.VerticalPosition = 60f; //设置图片的大小 Pic.Width = 120f; Pic.Height = 170f; //保存文档 document.SaveToFile(

C# to replace strings of text in a docx

喜你入骨 提交于 2019-12-04 05:35:25
Using C#, is there a good way to find and replace a text string in a docx file without having word installed on that machine? Yes, using Open XML . Here's an article which addresses your specific question: Creating a Simple Search and Replace Utility for Word 2007 Open XML Format Documents You may also try Aspose.Words for .NET in order to find and replace text in Word document . This component doesn't require MS Office to be installed. The API is quite simple and easy to use and implement. Disclosure: I work as developer evangelist at Aspose. 来源: https://stackoverflow.com/questions/3375811/c

highlighting text in Docx using c#

倖福魔咒の 提交于 2019-12-04 02:04:12
问题 I need to highlight a sentence in docx file, I have this code, and its working fine for many documents , but i noticed that for some document the text inside the document is set word by word, not whole sentence, I mean each word with its own Run, so when searching for that sentence, it is not found because it is word by word in the docx. NOTE: I am working with Arabic text. private void HighLightText_userSentence(Paragraph paragraph, string text, string title, string author, decimal

Open xml replace text from word file and return memory stream using MVC

拜拜、爱过 提交于 2019-12-03 20:57:59
I have an word file that contain my specified pattern text {pattern} and I want to replace those pattern with new my string which was read from database. So I used open xml read stream from my docx template file the replace my pattern string then returned to stream which support to download file without create a temporary file. But when I opened it generated me error on docx file. Below is my example code public ActionResult SearchAndReplace(string FilePath) { MemoryStream mem = new MemoryStream(System.IO.File.ReadAllBytes(FilePath)); using (WordprocessingDocument wordDoc =

How can I save an edited Word document with Python?

二次信任 提交于 2019-12-03 20:54:37
I am attempting to create a script which can extract the XML from a Word document, modify it, and finally save the new Word document, all using Python. Here's the code I used, which was effectively stolen from here : import zipfile import os import tempfile import shutil def getXml(docxFilename): zip = zipfile.ZipFile(open(docxFilename,"rb")) xmlString = str(zip.read("word/document.xml")) return xmlString def createNewDocx(originalDocx,xmlContent,newFilename): tmpDir = tempfile.mkdtemp() zip = zipfile.ZipFile(open(originalDocx,"rb")) zip.extractall(tmpDir) with open(os.path.join(tmpDir,"word

DocX clone table and insert at index

白昼怎懂夜的黑 提交于 2019-12-03 20:12:26
问题 I am using C# to make a simple Windows app using Novacode to manipulate a Word document. I have a source table in my Word document that I want to clone. I am able to find the source table okay using this code: Table sourceTable = document.Tables[3]; I can see by the rows and columns that this is in fact the table that I want to clone. I have a string in my Word doc that right after it I want to insert my cloned source table. In fact, I may need to insert it more than once. I don't know how to