Knowledgebase (2330)
Children categories
Different from Word and Excel, PDF enables people to attach various files in it. For the convenience of both protecting the confidential files and avoiding the PDF too large, PDF also allows developers to remove any attachment. This section will introduce a solution to remove attachments from PDF via a PDF component in C#, VB.NET.
Spire.PDF for .NET, a .NET component with rich capabilities in manipulating PDF, enables you to quickly remove attachments from your PDF document. Now please see below picture and view the whole attachments remove solution after it.

In the solution, first you need a decision procedure to see whether this PDF file has any attachment, then, remove attachments. There are two situations here. One is to remove all the attachments. You can call this method: Document.Attachments.Clear(). The other is to remove a certain attachment or attachments. You can remove them either by pointing file name for example filename=="e-iceblue.html " or by the file extension such as filename.Contains(".html"). Below solution directly find the PDF via file name. Please remember to download Spire.PDF for .NET before performing the project.
using Spire.Pdf;
using Spire.Pdf.Attachments;
using System;
using System.Windows.Forms;
namespace RemoveAttachments
{
class Program
{
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "PDF document(*.pdf)|*.pdf";
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(dialog.FileName);
PdfAttachmentCollection attachments = doc.Attachments;
PdfAttachment attachment = null;
if (doc.Attachments.Count > 0)
{
foreach (PdfAttachment oneAttachment in doc.Attachments)
{
string filename = oneAttachment.FileName;
if (filename == "excel.xlsx")
{
attachment = oneAttachment;
break;
}
}
}
if (attachment != null)
{
doc.Attachments.Remove(attachment);
}
doc.SaveToFile("test.pdf");
System.Diagnostics.Process.Start("test.pdf");
}
}
}
}
Imports Spire.Pdf
Imports Spire.Pdf.Attachments
Imports System.Windows.Forms
Namespace RemoveAttachments
Class Program
Private Sub button1_Click(sender As Object, e As EventArgs)
Dim dialog As New OpenFileDialog()
dialog.Filter = "PDF document(*.pdf)|*.pdf"
Dim result As DialogResult = dialog.ShowDialog()
If result = DialogResult.OK Then
Dim doc As New PdfDocument()
doc.LoadFromFile(dialog.FileName)
Dim attachments As PdfAttachmentCollection = doc.Attachments
Dim attachment As PdfAttachment = Nothing
If doc.Attachments.Count > 0 Then
For Each oneAttachment As PdfAttachment In doc.Attachments
Dim filename As String = oneAttachment.FileName
If filename = "excel.xlsx" Then
attachment = oneAttachment
Exit For
End If
Next
End If
If attachment IsNot Nothing Then
doc.Attachments.Remove(attachment)
End If
doc.SaveToFile("test.pdf")
System.Diagnostics.Process.Start("test.pdf")
End If
End Sub
End Class
End Namespace
Spire.PDF is a .NET PDF component, which enables users to perform a wide range of PDF processing tasks directly, such as generate, read, write and modify PDF document in WPF, .NET and Silverlight.
Payment method we accept
We accept all the online payments supported by Paypal or 2Checkout. And we also accept the other payments. Such as Bank/Wire transfer, PO, Check/Money Order etc.
Online Payment Process
Paypal
- Choose your item and click the button "BUY."
- Enter the coupon code if you have.
- In the "Please select Payment Method", Choose Paypal.
- Proceed the payment by using Paypal.
2Checkout
- Choose your item and click the button "BUY."
- In the "Please select Payment Method", Choose 2Checkout.
- Proceed the payment by using 2Checkout.
- Enter the coupon code if you have.
Purchase Order payment Process
- Customer sends inquiry and insists to purchase via Purchase Order
- We send the product quotation sheet
- Customer confirms and send purchase order sheet
- We confirm and sends customer Bank information
- Customer Pay via Bank Transfer
- We check payment and send license file once we confirm the payment
- We Send Invoice to customer
Purchase Security
It is 100% secure to do business with us. The Payment platform we utilize is Paypal and 2Checkout. They are the most trusted global online payment system in the world. The order of your private information, such as credit card number, addresses and so on will never be disclosed without your specific permission. Over the years, there have not been one single complaint so far against the account security.
How and When will the ordered software be sent out
Once you complete the online order, our support team will send the license file to your registered email address via email directly; usually it is less than 18 hours.
Regular file we provide
We provide the regular file including quotation sheet, sales contract and invoice to our customers. Please contact our sales team according to your own requirements.
Refund Policy
We hold the 14-day money back guarantee if our products cannot work normally with error or bug. But sometimes the software doesn't work well due to improper operation. We strongly suggest you contact our support team for help first with detailed problem description. In addition, we do not accept gratuitous refund and the purchase with discount.
Overview
We always very thank for long-term support from our customers and would like consider more for customer to get our product with a more acceptable price. Therefore, we launch a discount system for offering customers the best value for money.
No Discount After Sale
We are not able to provide discounts once the order finished due to the cost involved to refund the partial payment. It is very important to contact our sales team(sales@e-iceblue.com) for coupon code before purchasing our products.
Purchase Quantity
You will get 12% off discount automatically to buy at least 3 same licenses (no license type limit) of any products in our store.
Competitive Discount
We offer 30% discount for customers who would like to switch to use E-iceblue products from other component vendors. Also, we are very appreciated if you share your views or opinions to help us improve our products.
For getting the competitive discount, you need to follow the following principles.
- It is not available to or through resellers.
- Just one time for one address or company.
- We must verify if you have used the products of our competitors before, so please share with us the invoice or any other document that proves you were/are using a similar product.
- We will ask for reasons why you would like to use our products rather than your current products.
For applying the competitive discount, you need to send a request to our sales team. Please show the following points in your post:
- The product you are using right now
- The reason you would like to have a change
- The proof you purchase the products from our competitors.
Our staff will send you the coupon code after reviewing and approving your request.
Share your Story with others via Video about using our products
If you have tried our product and found it useful, you are welcomed to make a video by sharing your reviews or steps by using our product. Then send it to sales@e-iceblue.com for us to review it. We will offer you a competitive discount for purchasing our product.
For More Discount
- Certain Discount-Purchase through reseller in your country
- 5% to 8% Discount-Write and publish review of our products on your website or professional reviews website
- 2% to 5% discount-Share our company link on your website or facebook
Discount for Non-Profit Organizations
If you are non-profit, educational organizations or government agency, please send a discount request to our sales team. Please provide all of your organization details in the request, including organization name, local address, website, Email address etc. After checking your request, our staff will send you the coupon code.
If you still have questions, please don’t hesitate to contact our sales team. We will reply you within 1 business day.