Converts image file to PDF file

Namespace:  SautinSoft
Assembly:  SautinSoft.PdfVision (in SautinSoft.PdfVision.dll) Version: 5.1.2.13

Syntax

      
 C#  Visual Basic 
public int ConvertImageFileToPDFFile(
	string inputImageFile,
	string outputPdfFile
)
Public Function ConvertImageFileToPDFFile ( _
	inputImageFile As String, _
	outputPdfFile As String _
) As Integer

Parameters

inputImageFile
String
Local path to any image file
outputPdfFile
String
Local path to output PDF file

Return Value

0 - converting successfully
1 - can't open input file, check the input path
2 - can't create output file, check the output path
3 - converting failed

Remarks

Image file can be in any format: JPG, GIF, PNG, TIF, multi-page TIFF, BMP, WMF, ICO etc.


Examples

CopyHow to convert PNG file to PDF file C#
using System;
using System.IO;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            // Convert PNG file to PDF file
            SautinSoft.PdfVision v = new SautinSoft.PdfVision();
            //v.Serial = "XXXXXXXXXXXXXXX";

            //specify converting options
            v.PageStyle.PageSize.Auto();
            //v.PageStyle.PageMarginLeft.Inch(1);
            //v.ImageStyle.Heightmm(150);
            //v.ImageStyle.WidthInch(10);

            string pngFile = Path.GetFullPath(@"..\..\..\..\..\Testing Files\image2.png");
            string pdfFile = Path.ChangeExtension(pngFile, ".pdf");

            int ret = v.ConvertImageFileToPDFFile(pngFile, pdfFile);

            //0 - converting successfully
            //1 - can't open input file, check the input path
            //2 - can't create output file, check the output path
            //3 - converting failed
            if (ret == 0)
            {
                // Open produced PDF in default PDF Viewer.
                System.Diagnostics.Process.Start(pdfFile);
            }
        }
    }
}
CopyHow to convert PNG file to PDF file in VB.Net
Imports System.IO

Namespace Sample
    Friend Class Test

        Shared Sub Main(ByVal args() As String)
            ' Convert PNG file to PDF file
            Dim v As New SautinSoft.PdfVision()
            'v.Serial = "XXXXXXXXXXXXXXX";


            'specify converting options
            v.PageStyle.PageSize.Auto()
            'v.PageStyle.PageMarginLeft.Inch(1);
            'v.ImageStyle.Heightmm(150);
            'v.ImageStyle.WidthInch(10);


            Dim pngFile As String = Path.GetFullPath("..\..\..\..\..\Testing Files\image2.png")
            Dim pdfFile As String = Path.ChangeExtension(pngFile, ".pdf")

            Dim ret As Integer = v.ConvertImageFileToPDFFile(pngFile, pdfFile)

            '0 - converting successfully
            '1 - can't open input file, check the input path
            '2 - can't create output file, check the output path
            '3 - converting failed
            If ret = 0 Then
                ' Open produced PDF in default PDF Viewer.
                System.Diagnostics.Process.Start(pdfFile)
            End If
        End Sub
    End Class
End Namespace

See Also