Detecting attachments in a PDF file from C#

Question:Hi guys I'm relatively new hear so wish some of you guys can help me. Do any of you guys have any ideas on how to detect attachment if the PDF has a file attached to it? I tried some software but I can't seem to find the codes to use for this.To the people who are planning to flag this as a duplicate I've read the other threads with similar question and they are without answers and if there are other posts similar to mine that is already answered please kindly give me a link to it. I hope the process could be done within C#, is there any solution on VeryPDF?

Answer:On VeryPDF, there are two software which can help you detect attachment, they are VeryPDF Advanced PDF Tools Command Line Tool and VeryPDF PDF Toolbox Command Line. In our knowledge base, there are many articles about detecting attachment by Advanced PDF Tools Command Line Tool, please have a check. In the following part, I will show you how to detect attachment by VeryPDF PDF Toolbox Command Line. If you need to call this software together with C#, you’d better choose the VeryPDF PDF Toolbox Component for .NET, by which you can also merge PDF, split PDF, remove pages from PDF, fill PDF form, add watermark to PDF, export or edit PDF description information, attach file to PDF, remove attached file from PDF, compress stream objects of PDF, remove PDF passwords, encrypt PDF with password, and repair damaged PDF.  Please check more about this software on homepage, in the following part, let us check how to make it work.

Step 1. Free download PDF Toolbox Component for .NET

  • For uploading and downloading easily, we have compressed it to zip file. When downloading finishes, there will be a zip file. Please extract it to some folder then you can use it normally.
  • When you open unzipped folder, please run "install.bat" as administrator to register "PDFToolBoxCom.dll". Then run "Microsoft Visual Studio 2010", and then choose "Windows Forms Application Visual C#" project and then save the test project.

Step 2. Detecting attachment from PDF together with C#.

  • Here are some code for your reference:
  •     private void button1_Click(object sender, EventArgs e)
       string strExePath =
               PDFToolBoxCom.PDFToolBoxCom p = new PDFToolBoxCom.PDFToolBoxCom();
               string strReturn = p.RunCMD(strExePath + @"\attached.pdf -detachfile -outfile att_dir");       

    Now let us check related parameters and command line:

    pdftoolbox attached.pdf -detachfile -outfile att_dir
    -detachfile      : copy all the attachments from the input PDF into the current folder or to an output directory given after output

By this software and this method, you can detect attachment from C# easily. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Verify Code   If you cannot see the CheckCode image,please refresh the page again!