I need to use C# programatically to append several preexisting
docx files into a single, long docx file - including special markups like bullets and images. Header and footer information will be stripped out, so those won't be around to cause any problems.
Active4 years, 11 months ago
I can find plenty of information about manipulating an individual
docx file with .NET Framework 3, but nothing easy or obvious about how you would merge files. There is also a third-party program (Acronis.Words) that will do it, but it is prohibitively expensive.
Update:
Picktorrent: guide to automation body of knowledge - Free Search and Download Torrents at search engine. Download Music, TV Shows, Movies, Anime, Software and more.
Automating through Word has been suggested, but my code is going to be running on ASP.NET on an IIS web server, so going out to Word is not an option for me. Sorry for not mentioning that in the first place.
edi9999
11.6k99 gold badges5959 silver badges105105 bronze badges
ShinobiShinobi
7 Answers
In spite of all good suggestions and solutions submitted, I developed an alternative. In my opinion you should avoid using Word in server applications entirely. So I worked with OpenXML, but it did not work with AltChunk. I added text to original body, I receive a List of byte[] instead a List of file names but you can easily change the code to your needs.
I hope this helps you.
GRGodoiGRGodoi
1,19222 gold badges2020 silver badges3434 bronze badges
You don't need to use automation. DOCX files are based on the OpenXML Formats. They are just zip files with a bunch of XML and binary parts (think files) inside. You can open them with the Packaging API (System.IO.Packaging in WindowsBase.dll) and manipulate them with any of the XML classes in the Framework.
Check out OpenXMLDeveloper.org for details.
Rob WindsorRob Windsor
6,24411 gold badge1616 silver badges2323 bronze badges
This is a very late to the original question and quite a bit has change but thought I would share the way I have written my merge logic. This makes use of the Open XML Power Tools
Currently this is working very well in our application. I have changed the code a little because my requirements is that each document that needs to be processed first. So what gets passed in is a DTO object with the template byte array and the various values that need to be replaced. Here is how my code currently looks. Which takes the code a little bit further.
Mike BMike B
I wrote a little test app a while ago to do this. My test app worked with Word 2003 documents (.doc) not .docx, but I imagine the process is the same - I should think all you'd have to change is to use a newer version of the Primary Interop Assembly. This code would look a lot neater with the new C# 4.0 features..
Terence LewisTerence Lewis
You want to use AltChunks and the OpenXml SDK 1.0 (at a minimum, 2.0 if you can). Check out Eric White's blog for more details and just as a great resource!. Here is a code sample that should get you started, if not work immediately.
John Saunders
149k2323 gold badges210210 silver badges372372 bronze badges
Pete SkellyPete Skelly
Its quit complex so the code is outside the scope of a forum post, I'd be writing your App for you, but to sum up.
Trevor
I had made an application in C# to merge RTF files into one doc,Iam hopeful it should work for DOC and DOCX files as well.
Hope this helps!
Sumit GhoshSumit Ghosh
1,89933 gold badges3333 silver badges5858 bronze badges
Not the answer you're looking for? Browse other questions tagged c#openxmldocx or ask your own question.
Active1 year ago
I have 3 folders:
In each folder I have 5 pdf files:
I want that in each folder to have a combined file of those two files:
Any idea? Don't tell to do it manually. This case is just to explain you my problem. Think that I have hundreds of folders. :)Maybe I can use another tool instead of Adobe Acrobat?!
Andrei AndreAndrei Andre
8 Answers
You can do this with a short batch file and pdftk.exe (not pdftk Builder which is the GUI version).
There is no need to install anything.
Preparation
Usage
Update: Version which uses current folder name as file name for generated pdf
Download Free Test Automation Body Of Knowledge Pdf Mergernixdanixda
21.8k1111 gold badges8181 silver badges137137 bronze badges
If you're on Linux (or Mac, or any environment where it is installed), you can use a command-line tool called ghostscript to combine them.
You can also use the following to combine all files in the current folder
You can download ghostscript here. There's a Windows version as well, but I didn't test it.
CacovskyCacovsky
I have used the above solution successfully. However, on my system (Windows 7 64-bit) the code as it is adds the PDFs in (apparently) random order, not alphabetically by filename.
To get it to add files in alphabetic order you will need to add the sort-object parameter to the DIR (aka Get-ChildItem) command (the sort-object takes no parameter here as filename/alphabetically is the default):
Those who have filenames of the form 1.pdf 2.pdf .. 10.pdf etc. rather than 01.pdf 02.pdf . 10.pdf may also like to try a variation of this:
karel
9,8711111 gold badges3535 silver badges4141 bronze badges
Giles HudsonGiles Hudson
There is a new online Advanced PDF Manipulation tool called Sej-da which is still in Beta, which has a myriad of PDF functions (inc ability to merge multiple pdfs). It free & could well help your needs.
![]()
A brief review of its functions was carried out only a couple of weeks ago by Revision 3:
SimonSimon
3,47577 gold badges3333 silver badges5050 bronze badges
Perhaps it is better to use a batch scenario. Create and collect all your pdf files as xxxx.abcdef.pdf.
First part is the so-called batch tag; second part is file identifier (file name). Tags for each back are similar in length and value; name of files come after the point.
For instance your first batch consists of 1111.3425.pdf, 1111.76501.pdf, so on. Your second batch is 22222.1432.pdf, 22222.4398, so on. And so on and so forth for other batches.
Then you can use automated merge software that can deal with thousands of files creating a separate merge for each batch. I found this Dysprosium free software that does not need a command line or a batch script. You can download it as a portable JAR file. It has different automated scenarios; one described in this answer as tagging and one as your required folder separated.
Depending on your hardware you can batch merge thousands of files into pre-destined batches.
Any BodyAny Body
Try PDFMerge. But don't use the initial form where you have to select each file one by one. Instead, wait for the site to check your Java installation, then click on 'Try the PDFMerge Java Applet' link. Once the applet is loaded and allowed to run, click on Choose files button, and you'll be able to select multiple files (to merge into one file).
The merging will be superfast and will be able to handle large number of files as nothing is uploaded into the website. Everything is done in your computer itself using your Java installation.
2005 honda shadow aero repair manual. PS: Sorry if you're looking for an offline software that can be customized to create single PDF files across multiple folders.
ADTCADTC
2,26933 gold badges2222 silver badges4444 bronze badges
If you are on mac you could create an Automator script to achieve this task. Make it as a folder action and simply drop the pdfs into it and see it happen! If you want I can show you how, are you running mac?
Henrik SöderlundHenrik Söderlund
On Linux
I wrote this rather long command line
But it does the job, I tested it, it also works with how many levels of folders you have. Just make sure that you run it a the root of the folder structure.
You need Eduard FlorinescuEduard Florinescu
pdftk and tree for this and on Ubuntu Linux you can install it with apt:
1,35355 gold badges2121 silver badges4141 bronze badges
protected by Community♦Oct 25 '14 at 16:08
Thank you for your interest in this question. El factor aladino pdf. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead? Body Of Knowledge DefinitionNot the answer you're looking for? Browse other questions tagged pdfadobe-acrobat or ask your own question.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |