Drag and drop a MS Word, Excel, PowerPoint, HTML or Image file here. Max file size 3MB.
Your document is being processed. Please wait for a moment.
The conversion is completed. Click download to save it to your computer.
*By using this service, you agree with our Privacy Policy.
Implemented by Spire.Office, this online PDF converter allows you to convert DOC, DOCX, XLS, XLSX, PPT, PPTX, PNG, JPG, TIFF, BMP, RTF, XPS, HTML, TXT to PDF for free. No need to register an account, no need to install any other software.
Developers who’d like to convert PDF to other file formats like DOC, DOCX, XLS, XLSX, PNG, JPG, HTML, or want to set the conversion preferences/options, could try our Spire.Office, which is a document API for processing Word, Excel, PowerPoint, PDF, Barcode, and Email on .NET or Java platform. To learn more about the conversion features, check the following code examples.

Convert Word to PDF
  • C#
  • VB.NET
  • JAVA
using Spire.Doc;

namespace ConvertWordToPdf
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Document object
            Document doc = new Document();

            //Load a .docx (or .doc) file
            doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\source.docx");

            //Create a ToPdfParameterList object to set the conversion options
            ToPdfParameterList parameterList = new ToPdfParameterList();

            //Embed all fonts in PDF
            parameterList.IsEmbeddedAllFonts = true;

            //Encrypt the resulting PDF document with an open password and a permission password
            parameterList.PdfSecurity.Encrypt("open-psd","permission-psd", Spire.Pdf.Security.PdfPermissionsFlags.None,Spire.Pdf.Security.PdfEncryptionKeySize.Key128Bit);

            //Set the conformance level
            parameterList.PdfConformanceLevel = Spire.Pdf.PdfConformanceLevel.Pdf_A1A;

            //Save to PDF
            doc.SaveToFile("result.pdf", parameterList);
        }
    }
}
Imports Spire.Doc

Namespace ConvertWordToPdf
    Class Program
        Shared  Sub Main(ByVal args() As String)
            'Create a Document object
            Document doc  =  New Document()

            'Load a .docx (or .doc) file
            doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\source.docx")

            'Create a ToPdfParameterList object to set the conversion options
            Dim parameterList As ToPdfParameterList =  New ToPdfParameterList()

            'Embed all fonts in PDF
            parameterList.IsEmbeddedAllFonts = True

            'Encrypt the resulting PDF document with an open password and a permission password
            parameterList.PdfSecurity.Encrypt("open-psd","permission-psd", Spire.Pdf.Security.PdfPermissionsFlags.None,Spire.Pdf.Security.PdfEncryptionKeySize.Key128Bit)

            'Set the conformance level
            parameterList.PdfConformanceLevel = Spire.Pdf.PdfConformanceLevel.Pdf_A1A

            'Save to PDF
            doc.SaveToFile("result.pdf", parameterList)
        End Sub
    End Class
End Namespace
import com.spire.doc.Document;
import com.spire.doc.ToPdfParameterList;
import com.spire.pdf.security.PdfEncryptionKeySize;
import com.spire.pdf.security.PdfPermissionsFlags;

public class WordToPdf {
    public static void main(String[] args) {

        //Create Document object
        Document doc = new Document();

        //Load a Word file
        doc.loadFromFile("sample.docx");

        //Create an instance of ToPdfParameterList.
        ToPdfParameterList parameterList =new ToPdfParameterList();

        //Embed all fonts in PDF
        parameterList.isEmbeddedAllFonts(true);

        //Set setDisableLink to true to remove the hyperlink effect for the result PDF page
        parameterList.setDisableLink(true);

        //Encrypt the resulting PDF document with an open password and a permission password
        parameterList.getPdfSecurity().encrypt("open-psd","permission-psd", PdfPermissionsFlags.None, PdfEncryptionKeySize.Key_128_Bit);

        //Save to PDF
        doc.saveToFile("ToPDF.pdf", parameterList);
    }
}
Convert Excel to PDF
  • C#
  • VB.NET
  • JAVA
using Spire.Xls;

namespace ConvertExcelToPDF
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Workbook instance
            Workbook workbook = new Workbook();

            //Load a .xlsx (or .xls) file
            workbook.LoadFromFile("C:\\Users\\Administrator\\Desktop\\source.xlsx");

            //Set worksheets to fit to page when converting
            workbook.ConverterSetting.SheetFitToPage = true;

            //Save to PDF
            workbook.SaveToFile("ExcelToPdf.pdf", FileFormat.PDF);
        }
    }
}
Imports Spire.Xls

Namespace ConvertExcelToPDF
    Class Program
        Shared  Sub Main(ByVal args() As String)
            'Create a Workbook instance
            Dim workbook As Workbook =  New Workbook()

            'Load a .xlsx (or .xls) file
            workbook.LoadFromFile("C:\\Users\\Administrator\\Desktop\\source.xlsx")

            'Set worksheets to fit to page when converting
            workbook.ConverterSetting.SheetFitToPage = True

            'Save to PDF
            workbook.SaveToFile("ExcelToPdf.pdf", FileFormat.PDF)
        End Sub
    End Class
End Namespace
import com.spire.xls.FileFormat;
import com.spire.xls.Workbook;

public class ConvertExcelToPdf {

    public static void main(String[] args) {

        //Create a Workbook instance and load an Excel file
        Workbook workbook = new Workbook();
        workbook.loadFromFile("C:\\Users\\Administrator\\Desktop\\Sample.xlsx");

        //Set worksheets to fit to page when converting
        workbook.getConverterSetting().setSheetFitToPage(true);

        //Save the resulting document to a specified path
        workbook.saveToFile("output/ExcelToPdf.pdf", FileFormat.PDF);
    }
}
Convert PowerPoint to PDF
  • C#
  • VB.NET
  • JAVA
using Spire.Presentation;

namespace ConvertPowerPointToPdf
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation object
            Presentation presentation = new Presentation();

            //Load a .pptx (or .ppt) file
            presentation.LoadFromFile("C:\\Users\\Administrator\\Desktop\\source.pptx");

            //Get the SaveToPdfOption object
            SaveToPdfOption saveToPdfOption = presentation.SaveToPdfOption;

            //Encrypt the resulting PDF document with an open password and a permission password
            saveToPdfOption.PdfSecurity.Encrypt("open-psd", "permission-psd", Spire.Pdf.Security.PdfPermissionsFlags.None, Spire.Pdf.Security.PdfEncryptionKeySize.Key128Bit);

            //Save to PDF
            presentation.SaveToFile("ToPdf.pdf", FileFormat.PDF);
        }
    }
}
Imports Spire.Presentation

Namespace ConvertPowerPointToPdf
    Class Program
        Shared  Sub Main(ByVal args() As String)
            'Create a Presentation object
            Dim presentation As Presentation =  New Presentation()

            'Load a .pptx (or .ppt) file
            presentation.LoadFromFile("C:\\Users\\Administrator\\Desktop\\source.pptx")

            'Get the SaveToPdfOption object
            Dim saveToPdfOption As SaveToPdfOption =  presentation.SaveToPdfOption

            'Encrypt the resulting PDF document with an open password and a permission password
            saveToPdfOption.PdfSecurity.Encrypt("open-psd", "permission-psd", Spire.Pdf.Security.PdfPermissionsFlags.None, Spire.Pdf.Security.PdfEncryptionKeySize.Key128Bit)

            'Save to PDF
            presentation.SaveToFile("ToPdf.pdf", FileFormat.PDF)
        End Sub
    End Class
End Namespace
import com.spire.pdf.security.PdfEncryptionKeySize;
import com.spire.pdf.security.PdfPermissionsFlags;
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;
import com.spire.presentation.SaveToPdfOption;

public class ConvertPptToPdf {

    public static void main(String[] args) throws Exception {

        //Create a Presentation object
        Presentation presentation = new Presentation();

        //Load a .pptx (or .ppt) file
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\example.pptx");

        //Get the SaveToPdfOption object
        SaveToPdfOption saveToPdfOption = presentation.getSaveToPdfOption();

        //Encrypt the resulting PDF document with an open password and a permission password
        saveToPdfOption.getPdfSecurity().encrypt("open-psd", "permission-psd", PdfPermissionsFlags.None, PdfEncryptionKeySize.Key_128_Bit);

        //Save to PDF
        presentation.saveToFile("toPDF.pdf", FileFormat.PDF);
        presentation.dispose();
    }
}
Convert HTML to PDF
  • C#
  • VB.NET
  • JAVA
using System.IO;
using Spire.Pdf.HtmlConverter.Qt;
using System.Drawing;
using Spire.Pdf.Graphics;

namespace ConvertHtmlStringToPdfWithPlugin
{
    class Program
    {
        static void Main(string[] args)
        {
            //Get the HTML string from a .html file
            string htmlString = File.ReadAllText(@"C:\Users\Administrator\Desktop\Document\Html\Sample.html");

            //Specify the output file path
            string fileName = "HtmlStringToPdf.pdf";

            //Specify the plugin path
            string pluginPath = "F:\\Libraries\\Plugin\\plugins-windows-x64\\plugins";

            //Set plugin path
            HtmlConverter.PluginPath = pluginPath;

            //Convert HTML string to PDF
            HtmlConverter.Convert(htmlString, fileName, true, 100000, new Size(1080, 1000), new PdfMargins(0), Spire.Pdf.HtmlConverter.LoadHtmlType.SourceCode);
        }
    }
}
Imports System.IO
Imports Spire.Pdf.HtmlConverter.Qt
Imports System.Drawing
Imports Spire.Pdf.Graphics

Namespace ConvertHtmlStringToPdfWithPlugin
    Class Program
        Shared  Sub Main(ByVal args() As String)
            'Get the HTML string from a .html file
            Dim htmlString As String =  File.ReadAllText("C:\Users\Administrator\Desktop\Document\Html\Sample.html")

            'Specify the output file path
            Dim fileName As String =  "HtmlStringToPdf.pdf"

            'Specify the plugin path
            Dim pluginPath As String =  "F:\\Libraries\\Plugin\\plugins-windows-x64\\plugins"

            'Set plugin path
            HtmlConverter.PluginPath = pluginPath

            'Convert URL to PDF
            HtmlConverter.Convert(htmlString, fileName, True, 100000, New Size(1080, 1000), New PdfMargins(0), Spire.Pdf.HtmlConverter.LoadHtmlType.SourceCode)
        End Sub
    End Class
End Namespace
import com.spire.pdf.graphics.PdfMargins;
import com.spire.pdf.htmlconverter.LoadHtmlType;
import com.spire.pdf.htmlconverter.qt.HtmlConverter;
import com.spire.pdf.htmlconverter.qt.Size;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class ConvertHtmlStringToPdf {

    public static void main(String[] args) throws IOException {

        //Invoke the custom method HtmlToString() to convert HTML file to string
        String htmlString = HtmlToString("C:\\Users\\Administrator\\Desktop\\Sample.html");

        //Specify the output file path
        String outputFile = "output/HtmlToPdf.pdf";

        //Specify the plugin path
        String pluginPath = "F:\\Libraries\\Plugin\\plugins-windows-x64\\plugins";

        //Set the plugin path
        HtmlConverter.setPluginPath(pluginPath);

        //Convert the HTML string to PDF
        HtmlConverter.convert(htmlString, outputFile, true, 100000, new Size(700, 900), new PdfMargins(0), LoadHtmlType.Source_Code);
    }

    //Convert a HTML file to string
    public static String HtmlToString(String filePath) throws IOException {
        String path = filePath;
        File file = new File(path);
        FileReader fileReader = new FileReader(file);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        StringBuilder stringBuilder = new StringBuilder();
        String temp = "";
        while ((temp = bufferedReader.readLine()) != null) {
            stringBuilder.append(temp + "
");
        }
        bufferedReader.close();
        String str = stringBuilder.toString();
        return str;
    }
}
Convert PNG, JPG, BMP to PDF
  • C#
  • VB.NET
  • JAVA
using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.Graphics;

namespace ConvertImageToPdfWithSameSize
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a PdfDocument object
            PdfDocument doc = new PdfDocument();

            //Set the margins to 0
            doc.PageSettings.SetMargins(0);

            //Load an image
            Image image = Image.FromFile(@"C:\Users\Administrator\Desktop\sample.jpg");

            //Get the image width and height
            float width = image.PhysicalDimension.Width;
            float height = image.PhysicalDimension.Height;

            //Add a page of the same size as the image
            PdfPageBase page = doc.Pages.Add(new SizeF(width, height));

            //Create a PdfImage object based on the image
            PdfImage pdfImage = PdfImage.FromImage(image);

            //Draw image at (0, 0) of the page
            page.Canvas.DrawImage(pdfImage, 0, 0, pdfImage.Width, pdfImage.Height);

            //Save to file
            doc.SaveToFile("ConvertToPdfWithSameSize.pdf");
        }
    }
}
Imports System.Drawing
Imports Spire.Pdf
Imports Spire.Pdf.Graphics

Namespace ConvertImageToPdfWithSameSize
    Class Program
        Shared  Sub Main(ByVal args() As String)
            'Create a PdfDocument object
            Dim doc As PdfDocument =  New PdfDocument()

            'Set the margins to 0
            doc.PageSettings.SetMargins(0)

            'Load an image
            Dim image As Image =  Image.FromFile("C:\Users\Administrator\Desktop\sample.jpg")

            'Get the image width and height
            Dim width As single =  image.PhysicalDimension.Width
            Dim height As single =  image.PhysicalDimension.Height

            'Add a page of the same size as the image
            Dim page As PdfPageBase =  doc.Pages.Add(New SizeF(width,height))

            'Create a PdfImage object based on the image
            Dim pdfImage As PdfImage =  PdfImage.FromImage(image)

            'Draw image at (0, 0) of the page
            page.Canvas.DrawImage(pdfImage, 0, 0, pdfImage.Width, pdfImage.Height)

            'Save to file
            doc.SaveToFile("ConvertToPdfWithSameSize.pdf")
        End Sub
    End Class
End Namespace
import com.spire.pdf.PdfDocument;
import com.spire.pdf.PdfPageBase;
import com.spire.pdf.graphics.PdfImage;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class ConvertPngToPdf {

    public static void main(String[] args) throws IOException {

        //Create a PdfDocument object
        PdfDocument doc = new PdfDocument();

        //Set the margins to 0
        doc.getPageSettings().setMargins(0);

        //Creating a File object for directory
        File directoryPath = new File("C:\\Users\\Administrator\\Desktop\\Images");

        //Get the abstract paths of the image files in the folder
        File filesList[] = directoryPath.listFiles();

        //Loop through the images
        for (int i = 0; i < filesList.length; i++) {

            //Read an image to BufferedImage
            BufferedImage bufferedImage = ImageIO.read(new FileInputStream(filesList[i].getAbsolutePath()));

            //Create a PdfImage object
            PdfImage pdfImage = PdfImage.fromImage(bufferedImage);

            //Get the image width and height
            int width = pdfImage.getWidth();
            int height = pdfImage.getHeight();

            //Add a page of the same size as the image
            PdfPageBase page = doc.getPages().add(new Dimension(width, height));

            //Draw image at (0, 0) of the page
            page.getCanvas().drawImage(pdfImage, 0, 0, width, height);
        }

        //Save to file
        doc.saveToFile("PngToPdf.pdf");
    }
}
Convert XPS to PDF
  • C#
  • VB.NET
  • JAVA
using Spire.Pdf;

namespace ConvertXpsToPdf
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a PdfDocument object
            PdfDocument doc = new PdfDocument();

            //Load a .xps file
            doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\source.xps", FileFormat.XPS);

            //Save to PDF
            doc.SaveToFile("toPDF.pdf", FileFormat.PDF);
        }
    }
}
Imports Spire.Pdf

Namespace ConvertXpsToPdf
    Class Program
        Shared  Sub Main(ByVal args() As String)
            'Create a PdfDocument object
            Dim doc As PdfDocument =  New PdfDocument()

            'Load a .xps file
            doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\source.xps", FileFormat.XPS)

            'Save to PDF
            doc.SaveToFile("toPDF.pdf", FileFormat.PDF)
        End Sub
    End Class
End Namespace
import com.spire.pdf.*;

public class PDFtoXPS {

    public static void main(String[] args) {
        //Create a PdfDocument object
        PdfDocument doc = new PdfDocument();

        //Load a .xps file
        doc.loadFromXPS("source.xps");

        //Save to PDF
        doc.saveToFile("toPDF.pdf", FileFormat.PDF);
    }
}