Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code to merge pdf files? 1

Status
Not open for further replies.

TiltingCode

Programmer
Apr 10, 2009
61
0
0
US
Does anyone know of any C# code to merge pdf files? For instance I have some docx files I'll be converting to pdfs. I'll then combine these new pdf files with existing pdf files. The new and current pdf files will be combined in a different order. For instance in a folder I have the following files:
1.docx
2.docx
3.pdf
4.pdf
5.docx
6.pdf
7.docx

I'll be converting the docx files to pdf files through Word so I'll now have seven pdf files. Now I want to create one pdf file consisting of all seven pdf files one after another in the order provided above.

I found some C# code I thought would the trick but all it did was make the first pdf file bigger and I couldn't see where the second had been merged with it (attached to the end of the first pdf).

I do not want to convert the pdfs to docx as I am worried how the new docx files will be formatted in the merge process.

Any help will be greatly apprciated.
 
I found the itextsharp.dll and saved it in C:\Windows\System32 but when I tied to register it I got the message:

The module "C:\Windows\System32\itextsharp.dll" was loaded but the entry-point DllRegisterServer was not found.

Make sure that "C:Windows\System32\itextsharp.dll" is a valid DLL or OCX file and then try it again.


I also went to the file and clicked on Properties and noticed a message at the bottom of the General tab:

This file cam from another computer and might be blocked to help protect this computer.


I click on the "Unblock" button and the message along with the button become disabled. However, none of this works. I've tried everything in a different order and reboot everytime.

My C# code never recognizes the namespace.

Can someone please explain what is going on?!
 
Not sure that the DLL has to be registered. What I did was to put the DLL in the Bin folder then referenced it.

Then in your .cs file you use

Code:
using iTextSharp.text;
using iTextSharp.text.pdf;

That should be it.

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top