Convert PDF to DOCX with Preserve Graphics and Images in C# and .NET
In the modern world of data processing and workflow automation, the need to quickly and efficiently convert PDF files into editable Microsoft Word (DOCX) documents is becoming increasingly in demand. It is especially valuable when all the graphic elements and images are saved. This greatly simplifies the work with the final documents, making them more convenient for editing and further use.
In this article, we will take a closer look at how to implement PDF to DOCX conversion, saving graphics and images using the powerful SautinSoft PDF Focus .NET library is a high—level commercial tool for working with PDF in an environment .NET.
Programmers and developers can integrate this functionality into their own workflow automation applications, management accounting systems, and corporate portals. This allows for automatic document processing without the need for manual copying or editing.
What is this code useful for:
- Editing official documents: when it is necessary to amend a PDF with complex graphics or diagrams.
- Automatic transfer of information: for example, when preparing reports, presentations or preparing for printing.
- Processing large amounts of documents: automating conversion processes to speed up work in businesses, banks, law firms, and educational institutions.
- Archiving and long-term storage: creation of editable copies of unique formats for later use.
The use of such code provides ample opportunities for automation and acceleration of document flow within the organization.
Complete code
using System;
using System.IO;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
// Before starting, we recommend to get a free key:
// https://sautinsoft.com/start-for-free/
// Apply the key here:
// SautinSoft.PdfFocus.SetLicense("...");
string pdfFile = Path.GetFullPath(@"..\..\..\text and graphics.pdf");
string wordFile = "Result.docx";
//Convert PDF file to Text file
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
f.OpenPdf(pdfFile);
//This property indicating whether to load vector graphics from PDF or skip it. Default value: true.
f.PreserveGraphics = false;
//This property indicating whether to load images from PDF or skip them. Default value: true.
f.PreserveImages = false;
if (f.PageCount > 0)
{
int result = f.ToWord(wordFile);
//Show Text document
if (result == 0)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(wordFile) { UseShellExecute = true });
}
}
}
}
}
Imports System
Imports System.IO
Namespace Sample
Friend Class Sample
Shared Sub Main(ByVal args() As String)
' Before starting, we recommend to get a free key:
' https://sautinsoft.com/start-for-free/
' Apply the key here
' SautinSoft.PdfFocus.SetLicense("...");
Dim pdfFile As String = Path.GetFullPath("..\..\..\text and graphics.pdf")
Dim wordFile As String = "Result.docx"
'Convert PDF file to Text file
Dim f As New SautinSoft.PdfFocus()
f.OpenPdf(pdfFile)
'This property indicating whether to load vector graphics from PDF or skip it. Default value: true.
f.PreserveGraphics = True
'This property indicating whether to load images from PDF or skip them. Default value: true.
f.PreserveImages = False
If f.PageCount > 0 Then
Dim result As Integer = f.ToWord(wordFile)
'Show Text document
If result = 0 Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(wordFile) With {.UseShellExecute = True})
End If
End If
End Sub
End Class
End Namespace
If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below: