Convert PDF to Word
This sample demonstrates how to convert a PDF to a Microsoft Office Word document using SolidFramework.
It is recommended that you have already reviewed the Getting Started sample, since that includes Licensing and Framework initialization code required to make this sample run.
				
				1
				2
				3
				4
				5
				6
				7
				8
				9
				10
				11
				12
				13
				14
				15
				16
				17
				18
				19
				20
				21
				22
				23
				24
				25
				26
				27
				28
				29
				30
				31
				32
				33
				34
				35
				36
				37
				38
				39
				40
				41
				42
				43
				44
				45
				46
				47
				48
				49
				50
				51
				52
				53
				54
			
			
				
				using System;
				using SolidFramework.Converters;
				using SolidFramework.Converters.Plumbing;
				 
				namespace CSharp_Tutorials
				{
				    public static partial class Tutorials
				    {
				        public static bool ConvertPdfToWord(string pdfPath, string outputPath)
				        {
				            // Create a PdfToWordConverter
				            using (var converter = new PdfToWordConverter()) 
				            {
				                // Add the PDF file to convert
				                converter.AddSourceFile(pdfPath);
				 
				                // Optional: Set PdfToWordConverter options to your liking
				                converter.HeaderAndFooterMode = HeaderAndFooterMode.Detect;
				                converter.ReconstructionMode = ReconstructionMode.Flowing;
				                converter.OutputType = WordDocumentType.DocX;
				 
				                // Optional: Add a progress/warning handler
				                double nextPercentToLog = 25;
				                converter.Progress += (sender, progress) =>
				                {
				                    double percent = progress.Progress * 100.0  / progress.MaxProgress;
				                    if (percent < nextPercentToLog || (percent > 70 && nextPercentToLog < 30)) { return; }
				                    Console.WriteLine(progress.StatusDescription + " " + percent + "%");
				                    nextPercentToLog = percent > 70 ? 25 : nextPercentToLog + 25;
				                };
				 
				                Console.WriteLine("Converting " + pdfPath + " to " + outputPath);
				 
				                // Convert the file
				                var result = converter.ConvertTo(outputPath, true);
				 
				                // Check if it was successful
				                if (result != ConversionStatus.Success)
				                {
				                    Console.WriteLine("Converting " + pdfPath + " to " + outputPath + " failed with status: " + result);
				                    Console.WriteLine();
				                    return false;
				                }
				            }
				            Console.WriteLine("Successfully converted " + pdfPath + " to " + outputPath);
				            Console.WriteLine();
				            return true;
				        }
				    }
				}
				 
			
		
				
				1
				2
				3
				4
				5
				6
				7
				8
				9
				10
				11
				12
				13
				14
				15
				16
				17
				18
				19
				20
				21
				22
				23
				24
				25
				26
				27
				28
				29
				30
				31
				32
				33
				34
				35
				36
				37
				38
				39
				40
				41
				42
				43
				44
				45
				46
				47
				48
				49
				50
				51
				52
				53
				54
				55
				56
				57
			
			
				
				Imports System
				Imports SolidFramework.Converters
				Imports SolidFramework.Converters.Plumbing
				 
				Namespace VBNet_Tutorials
				    Partial Module Tutorials
				        Function ConvertPdfToWord(ByVal pdfPath As String, ByVal outputPath As String) As Boolean
				 
				            ' Create a PdfToWordConverter
				            Using converter As PdfToWordConverter = New PdfToWordConverter()
				 
				                ' Add the PDF file to convert
				                converter.AddSourceFile(pdfPath)
				 
				                ' Optional Set PdfToWordConverter options to your liking
				                converter.HeaderAndFooterMode = HeaderAndFooterMode.Detect
				                converter.ReconstructionMode = ReconstructionMode.Flowing
				                converter.OutputType = WordDocumentType.DocX
				 
				                ' Optional Add a progress/warning handler
				                Dim nextPercentToLog As Double = 25
				                AddHandler converter.Progress,
				                Sub(sender, progress)
				                    Dim percent As Double = progress.Progress * 100.0 / progress.MaxProgress
				 
				                    If percent < nextPercentToLog OrElse (percent > 70 AndAlso nextPercentToLog < 30) Then
				                        Return
				                    End If
				 
				                    Console.WriteLine(progress.StatusDescription & " " + percent.ToString() & "%")
				                    nextPercentToLog = If(percent > 70, 25, nextPercentToLog + 25)
				                End Sub
				 
				                Console.WriteLine("Converting " & pdfPath & " to " & outputPath)
				 
				                ' Convert the file
				                Dim result As ConversionStatus = converter.ConvertTo(outputPath, True)
				 
				                ' Check if it was successful
				                If result <> ConversionStatus.Success Then
				                    Console.WriteLine("Converting " & pdfPath & " to " & outputPath & " failed with status: " & result)
				                    Console.WriteLine()
				                    Return False
				                End If
				            End Using
				 
				            Console.WriteLine("Successfully converted " & pdfPath & " to " & outputPath)
				            Console.WriteLine()
				            Return True
				        End Function
				 
				    End Module
				End Namespace
				 
			
		
				
				1
				2
				3
				4
				5
				6
				7
				8
				9
				10
				11
				12
				13
				14
				15
				16
				17
				18
				19
				20
				21
				22
				23
				24
				25
				26
				27
				28
				29
				30
				31
				32
				33
				34
				35
				36
				37
				38
				39
				40
				41
				42
				43
				44
				45
				46
			
			
				
				#include "Tutorials.h"
				 
				using namespace SolidFramework::Converters::Plumbing;
				using namespace SolidFramework::Converters;
				 
				bool ConvertPdfToWord(const wstring & pdfPath, const wstring & outputPath)
				{
				    // Create a PdfToWordConverter
				    auto converter = make_shared<PdfToWordConverter>();
				 
				    // Add the PDF file to convert
				    converter->AddSourceFile(pdfPath);
				    
				    // Optional: Set PdfToWordConverter options to your liking
				    converter->SetHeaderAndFooterMode(HeaderAndFooterMode::Detect);
				    converter->SetReconstructionMode(ReconstructionMode::Flowing);
				    converter->SetOutputType(WordDocumentType::DocX);
				 
				    // Optional: Add a progress/warning handler
				    double nextPercentToLog = 25;
				    converter->OnProgress = [&nextPercentToLog] (SolidFramework::ProgressEventArgsPtr progress)
				    {
				        const double percent = progress->GetProgress() * 100.0  / progress->GetMaxProgress();
				        if (percent < nextPercentToLog || (percent > 70 && nextPercentToLog < 30)) { return; }
				        wcout << progress->GetStatusDescription() << L" " << percent  << L"%" << endl;
				        nextPercentToLog = percent > 70 ? 25 : nextPercentToLog + 25;
				    };
				 
				    wcout << L"Converting " << pdfPath << L" to " << outputPath << endl;
				 
				    // Convert the file
				    auto result = converter->ConvertTo(outputPath, true);
				 
				    // Check if it was successful
				    if (result != ConversionStatus::Success)
				    {
				        wcout << L"Converting " << pdfPath << L" to " << outputPath << L" failed with status: " << (int)result << endl << endl;
				        return false;
				    }
				    wcout << L"Successfully converted " << pdfPath << L" to " << outputPath << endl << endl;
				    return true;
				}
				 
			
		