Convert PDF to HTML
The code below shows you how to convert a PDF file to an HTML page.
This sample requires a Professional license.
C#
using System; using System.IO; using SolidFramework.Converters.Plumbing; using SolidFramework.Converters; namespace PDFtoHTML { class Program { [STAThread] static void Main(string[] args) { // Call your Solid Documents License SolidFramework.License.Import(@"C:\MyFolder\license.xml"); // Set the location of your the file you want to convert String pdfPath = @"C:\YourFolder\yourpdf.pdf"; // Set the file extension you are creating String htmlFile= Path.ChangeExtension(pdfPath, ".html"); //*PDF to HTML*// using (PdfToHtmlConverter converter = new PdfToHtmlConverter()) { // Add the selected file to the converter converter.AddSourceFile(pdfPath); // Convert any graphics to Image Files converter.GraphicsAsImages = true; // Set the file type for the images converter.ImageType = ImageDocumentType.Png; //Other image formats are availabe i.e JPG, TIFF, Bitmap // Automatically detect page orientation and rotate if required converter.AutoRotate = true; // Convert the file converter.ConvertTo(htmlFile, true); // Show the status of the PDF file in the Console Window SolidFramework.Converters.Plumbing.ConversionStatus status = converter.ConvertTo(htmlFile, true); if (status != ConversionStatus.Success) { Console.WriteLine(status); Console.ReadKey(); } } } } }
C++
#include "stdafx.h" #include "SolidFramework.h" #include <iostream> using namespace std; void DoProgress(SolidFramework::ProgressEventArgsPtr args) { // Not implemented } void DoWarning(SolidFramework::WarningEventArgsPtr args) { // Not implemented } class PDFtoHTMLConverter : public SolidFramework::Converters::PdfToHtmlConverterBase { public: void FireProgress(SolidFramework::ProgressEventArgsPtr args) override { DoProgress(args); }; void FireWarning(SolidFramework::WarningEventArgsPtr args) override { DoWarning(args); }; }; int _tmain(int argc, _TCHAR* argv[]) { // Enter your License code goes here SolidFramework::License::Import(L"C:\\MyFolder\\license.xml"); // Create a PDF to Word Converter called converter PDFtoHTMLConverter *converter = new PDFtoHTMLConverter(); SolidFramework::Converters::CustomData *pData = NULL; pData = new SolidFramework::Converters::CustomData(); pData->Converter = converter; pData->Data = nullptr; converter->setCustomData(pData); // Add the PDF file to convert. converter->AddSourceFile(L"C:\\YourFolder\\yourpdf.pdf"); converter->setOutputDirectory(L"C:\\MyFolder"); // Set how images are reconstructed converter->setGraphicsAsImages(true); // Set the file type for the images converter->setImageType(SolidFramework::Converters::Plumbing::ImageDocumentType::Png); // Automatically detect page orientation and rotate if required converter->setAutoRotate(true); //Start the Conversion cout << "Starting conversion." << endl; converter->Convert(); SolidFramework::Converters::Plumbing::ConversionStatus status = converter->getResults()->getItem(0)->getStatus(); if (status != SolidFramework::Converters::Plumbing::ConversionStatus::Success) { cout << "Conversion failed." << endl; } else { cout << "Conversion succeeded." << endl; } converter->Dispose(); cout << "Press <Enter> to exit." << endl; cin.get(); return 0; }
VB.Net
Imports System.IO Imports SolidFramework.Converters.Plumbing Module PDFtoHTML Sub Main() ' Call your Solid Documents License SolidFramework.License.Import("C:\MyFolder\license.xml") 'Define a variable for your source file Dim sPdfPath As String ' Define a String for the output file Dim htmlPath As String ' Define your Solid Framework Converter Dim myConverter As SolidFramework.Converters.PdfToHtmlConverter ' Set the converter myConverter = New SolidFramework.Converters.PdfToHtmlConverter ' Set your file path sPdfPath = "C:\YourFolder\filepdf.pdf" ' Set your output file and location htmlPath = Path.ChangeExtension(sPdfPath, ".html") ' Add files to convert. myConverter.AddSourceFile(sPdfPath) ' Set the preferred conversion properties ' Convert any graphics to Image Files myConverter.GraphicsAsImages = True ' Set the file type for the images //Other image formats are availabe i.e JPG, TIFF, Bitmap etc myConverter.ImageType = ImageDocumentType.Png ' Automatically detect page orientation and rotate if required myConverter.AutoRotate = True ' Convert the File. myConverter.ConvertTo(htmlPath, True) ' Clean up myConverter.Dispose() End Sub End Module