Convert URL-PDF from Internet to a Word file using C# and .NET
In today's world, document processing automation plays a key role in improving business efficiency and simplifying workflows. One common scenario is the need to convert PDF documents obtained from the internet into editable Word format. This task is relevant for many organizations facing the need to quickly and accurately extract content for editing, analysis, or archiving. For example, we use the PDF Focus .NET component of the powerful SautinSoft library.
Practical benefits of using the code.
The implemented code automates document processing processes, reducing the likelihood of errors during manual downloading and conversion.
It is useful in automated document management systems, web services, content management systems, and analytics.
What makes the code example unique?
Many articles focus on basic examples: downloading a file separately and then processing it. In contrast, our example demonstrates working directly
with a URL, eliminating the need for intermediate steps. This makes the solution more elegant, faster and easier to integrate into existing systems.
This Console Application shows how to convert a remote PDF (url-link) into a DOCX file.
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 remotePdfUrl = @"https://sautinsoft.com/products/pdf-focus/help/net/developer-guide/data/files/parkmap.pdf";
string pathToWord = @"Result.docx";
//Convert URL-PDF from Internet to a Word file
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
Uri uri = new Uri(remotePdfUrl);
f.OpenPdf(uri);
if (f.PageCount > 0)
{
int result = f.ToWord(pathToWord);
//Show the resulting Word document
if (result == 0)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pathToWord) { UseShellExecute = true });
}
}
}
}
}
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Collections.Generic
Imports SautinSoft
Module Sample
Sub Main()
' Before starting, we recommend to get a free key:
' https://sautinsoft.com/start-for-free/
' Apply the key here
' SautinSoft.PdfFocus.SetLicense("...");
Dim remotePdfUrl As String = "https://sautinsoft.com/products/pdf-focus/help/net/developer-guide/data/files/parkmap.pdf"
Dim pathToWord As String = "Result.docx"
'Convert URL-PDF from Internet to a Word file
Dim f As New SautinSoft.PdfFocus()
Dim uri As New Uri(remotePdfUrl)
f.OpenPdf(uri)
If f.PageCount > 0 Then
Dim result As Integer = f.ToWord(pathToWord)
'Show the resulting Word document
If result = 0 Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(pathToWord) With {.UseShellExecute = True})
End If
End If
End Sub
End Module
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: