docx

PHP: preg_match() not correct

天涯浪子 提交于 2019-12-11 00:09:33
问题 I have the following string: <w:pPr> <w:spacing w:line="240" w:lineRule="exact"/> <w:ind w:left="1890" w:firstLine="360"/> <w:rPr> <w:b/> <w:color w:val="00000A"/> <w:sz w:val="24"/> </w:rPr> </w:pPr> and I am trying to parse the "w:sz w:val" value using preg_match(). So far, I've tried: preg_match('/<w:sz w:val="(\d)"/', $p, $fonts); but this has not worked, and I'm unsure why? Any Ideas? Thank you in advance! 回答1: You were trying to capture only single-digit numbers. Try adding a + to make

Printing Docx without MS Word automation

為{幸葍}努か 提交于 2019-12-10 21:28:10
问题 I'm trying to perform a mail merge between a docx and the database then print the result to a specific printer and that without any Ms Word automation (that is supposed to run server side) I think that Open XML SDK can help with the merge but as far as Printing is concerned, I'm clueless. Any idea ? 回答1: Your question looks quite similar to this one: Printing an OOXML document without MS Word installed Anyway, I had a similar problem and used Open XML SDK to generate the documents starting

Adding a header to docx file with python

◇◆丶佛笑我妖孽 提交于 2019-12-10 18:49:30
问题 I have several hundred word documents for which I need to add a specific header (as in a typical MS Word header/ footer). It is not that the header needs to be modified, these documents just don't contain one. Is there any way to do this with the Python-docx module? I recently discovered it and it seems promising. 回答1: And if the user doesn't have docx package, it can be done through win32 too, using this. ..// import win32com.client if win32com.client.gencache.is_readonly == True: win32com

poi读写doc和docx

♀尐吖头ヾ 提交于 2019-12-10 15:23:57
依赖 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.8</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <version>3.8</version> </dependency> 读 @SpringBootTest public class Docx { @Test public void testDoc() { File file = new File("C:\\Users\\吕厚厚\\Desktop\\aa.doc"); try { FileInputStream fis = new FileInputStream(file); WordExtractor extractor = new WordExtractor(fis); //输出word文档所有的文本 System.out.println(extractor.getText()); fis.close(); } catch (Exception e) { e.printStackTrace(); } } @Test

Save WordprocessingMLPackage to ByteArrayInputStream

眉间皱痕 提交于 2019-12-10 13:58:29
问题 How can I save a org.docx4j.openpackaging.packages.WordprocessingMLPackage instance into ByteArrayInputStream, then It can be downloaded from server. Thanks. 回答1: You cannot save to a ByteArrayInputStream ... ever. A ByteArrayInputStream is an InputStream and you don't / can't write to an InputStream . However you can write something to a ByteArrayOutputStream , get the byte array, and create a ByteArrayInputStream wrapper for the array. (I'm assuming that there is a way to save one of those

c# Find and Replace Text in a Word Document

烂漫一生 提交于 2019-12-10 12:23:12
问题 i want to Create and Manipulate Word Documents Programmatically Using DocX ! and create a word template InvoiceTemplate.docx this is my code : protected void CreateDoc_Click(object sender, EventArgs e) { //Createa docx File DocX gDocument; gDocument = DocX.Load(@Server.MapPath("InvoiceTemplate.docx")); gDocument = CreateInvoiceFromTemplate(DocX.Load(@Server.MapPath("InvoiceTemplate.docx"))); gDocument.SaveAs(@Server.MapPath("~/DocX/NewLoadedShipment.docx")); } private static DocX

openTBS remove image when replace not found

微笑、不失礼 提交于 2019-12-10 11:38:12
问题 How do you remove the image in OpenTBS if the one you are replacing it with does not exist? I have a bit of code that loops through and replaces pics in a table, but sometimes the client will not have the pictures. I tried leaving out the default=current tag but it shows a missing image box("This image cannot currently be displayed"). UPDATE: I thought Skrols answer would work but I couldnt get it to work. I have an image followed by the following tag. [field.p5;ope=changepic;from=’[val]’

docx4j find and replace

佐手、 提交于 2019-12-10 11:28:44
问题 I have docx document with some placeholders. Now I should replace them with other content and save new docx document. I started with docx4j and found this method: public static List<Object> getAllElementFromObject(Object obj, Class<?> toSearch) { List<Object> result = new ArrayList<Object>(); if (obj instanceof JAXBElement) obj = ((JAXBElement<?>) obj).getValue(); if (obj.getClass().equals(toSearch)) result.add(obj); else if (obj instanceof ContentAccessor) { List<?> children = (

Apache POI - Split Word document (docx) to pages

早过忘川 提交于 2019-12-10 10:43:40
问题 I have been trying to segment a docx document to multiple documents based on a predefined criteria. following is my approach to cut it to paragraphs try { FileInputStream in = new FileInputStream(file); XWPFDocument doc = new XWPFDocument(in); List<XWPFParagraph> paragraphs = doc.getParagraphs(); for (int idx = 0; idx < paragraphs.size(); idx++) { XWPFDocument outputDocument = new XWPFDocument(); createParagraphInAnotherDocument(outputDocument, paragraphs.get(idx).getText()); String fullPath

programaticaly embedding Font Family in .docx file

巧了我就是萌 提交于 2019-12-10 10:32:15
问题 I am trying to insert the font family (not system fonts) in the docx file. I am using openxml-sdk to achieve this functionality. Somehow I am able to get the font information from a particular docx file. But not able to embed the font family in the document Is it possible to embed the font in a docx file using code? 回答1: Yes, it trivial for docx. MS Word have check-box for that [http://www.howtogeek.com/howto/microsoft-office/embed-true-type-fonts-in-word-and-powerpoint-2007-documents/]. To