Knowledgebase (2330)
Children categories
PDF/A is an ISO-standardized version of the Portable Document Format (PDF) specialized for the digital preservation of electronic documents. It is widely used for long term archiving for PDF format. This article mainly shows how to convert word document (doc and docx) to PDF/A in C# by using Spire.Doc.
Make sure Spire.Doc for .NET Version 5.0.26 (or above) has been installed correctly and then add Spire.Doc.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Doc\Bin\NET4.0\ Spire.Doc.dll".
First, check the original word document that will be converted to PDF/A.
Here comes to the details of how developers convert word document to PDF/A directly by using Spire.Doc:
Step 1: Load a word document from the file.
Document document = new Document(); document.LoadFromFile(@"D:\test.docx",FileFormat.Docx);
Step 2: Sets the Pdf document's Conformance-level to PDF_A1B.
ToPdfParameterList toPdf = new ToPdfParameterList(); toPdf.PdfConformanceLevel = Spire.Pdf.PdfConformanceLevel.Pdf_A1B;
Step 3: Save word document to PDF
document.SaveToFile("result.Pdf",toPdf);
Please check the effective screenshot of the result PDF in PDF/A format.
When dealing with Word documents, sometimes developers need to merge multiple files into a single file. Spire.Doc, especially designed for developers enables you to manipulate doc files easily and flexibly.
There is already a document introducing how to merge doc files. Check it here:
.NET Merge Word - Merge Multiple Word Documents into One in C# and VB.NET
Using the method above, you have to copy sections one by one. But the new method just concatenates them. It has improved and is very easy to use
Step 1: Load the original word file "A Good Man.docx".
document.LoadFromFile("A Good Man.docx", FileFormat.Docx);
Step 2: Merge another word file "Original Word.docx" to the original one.
document.InsertTextFromFile("Original Word.docx", FileFormat.Docx);
Step 3: Save the file.
document.SaveToFile("MergedFile.docx", FileFormat.Docx);
Full code and screenshot:
static void Main(string[] args)
{
Document document = new Document();
document.LoadFromFile("A Good Man.docx", FileFormat.Docx);
document.InsertTextFromFile("Original Word.docx", FileFormat.Docx);
document.SaveToFile("MergedFile.docx", FileFormat.Docx);
System.Diagnostics.Process.Start("MergedFile.docx");
}
Full code and screenshot:
using Spire.Doc;
namespace MergeWord
{
class Program
{
static void Main(string[] args)
{
Document document = new Document();
document.LoadFromFile("A Good Man.docx", FileFormat.Docx);
document.InsertTextFromFile("Original Word.docx", FileFormat.Docx);
document.SaveToFile("MergedFile.docx", FileFormat.Docx);
System.Diagnostics.Process.Start("MergedFile.docx");
}
}
}

Word Marco is widely used to record the operation that needs to be done repeatedly and you can apply it with only a single click. It can save lots of time for you. It is not an easy work to load a word document with Macro in C# and sometimes, you need to remove the Marco in the word documents in C#. This article will focus on demonstrate how to load and save word document with Marco, and clear the Marco by using Spire.Doc in C# in simple lines of codes.
First, download Spire.Doc and install on your system. The Spire.Doc installation is clean, professional and wrapped up in a MSI installer.
Then adds Spire.Doc.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Doc\Bin\NET4.0\ Spire.Doc.dll".
Here comes to the steps.
Step 1: Load and save the document with Marco. Spire.Doc for .NET supports .doc, .docx(Word 97-2003) document with macros and .docm(Word 2007 and Word 2010) document.
//Loading document with macros.
document.LoadFromFile(@"D:\Macros.docm", FileFormat.Docm);
//Save docm file.
document.SaveToFile("Sample.docm", FileFormat.Docm);

Step 2: Clear the Marco in word document. With Spire.Doc, you only need one line of code to remove all the Marcos at one time.
//Removes the macros from the document
document.ClearMacros();
//Save docm file.
document.SaveToFile("Sample.docm", FileFormat.Docm);
Here comes to the screenshot which has removed the Marco in word document.
