GdPicture.NET.14
GdPicture14 Namespace / GdPictureDocumentConverter Class / ConvertToPDF Method
An input stream object. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.

This stream should be open for reading and should be closed/disposed by the user as well.

A member of the DocumentFormat enumeration. Specifies a file format of the input document. Supported input document formats are listed here.

You can use a value of GdPicture14.DocumentFormat.DocumentFormatUNKNOWN if you are not sure about the document's format.

An output stream object. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.

This stream should be open for writing and should be closed/disposed by the user as well.

A member of the PdfConformance enumeration. Specifies the required PDF version or conformance to the PDF or PDF/A standard of the resuting PDF document.
Example





In This Topic
ConvertToPDF Method (GdPictureDocumentConverter)
In This Topic
This method converts the specified document from an instantiated input stream object to a single PDF document and saves the resulting file into an instantiated output stream object according to what you have specified.

The PDF version or the PDF conformance level of the resulting PDF document is set according to the given Conformance parameter.

Syntax
'Declaration
 
Public Function ConvertToPDF( _
   ByVal InputStream As Stream, _
   ByVal DocumentFormat As DocumentFormat, _
   ByVal OutputStream As Stream, _
   Optional ByVal Conformance As PdfConformance _
) As GdPictureStatus
public function ConvertToPDF( 
    InputStream: Stream;
    DocumentFormat: DocumentFormat;
    OutputStream: Stream;
    Conformance: PdfConformance
): GdPictureStatus; 
public function ConvertToPDF( 
   InputStream : Stream,
   DocumentFormat : DocumentFormat,
   OutputStream : Stream,
   Conformance : PdfConformance
) : GdPictureStatus;

Parameters

InputStream
An input stream object. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.

This stream should be open for reading and should be closed/disposed by the user as well.

DocumentFormat
A member of the DocumentFormat enumeration. Specifies a file format of the input document. Supported input document formats are listed here.

You can use a value of GdPicture14.DocumentFormat.DocumentFormatUNKNOWN if you are not sure about the document's format.

OutputStream
An output stream object. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.

This stream should be open for writing and should be closed/disposed by the user as well.

Conformance
A member of the PdfConformance enumeration. Specifies the required PDF version or conformance to the PDF or PDF/A standard of the resuting PDF document.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Example
Converting an image file to a single PDF document.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
    Using inputStream As Stream = File.Open("image.jpg", System.IO.FileMode.Open)
        Using outputStream As Stream = File.Create("image.pdf")
            gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatUNKNOWN, outputStream, PdfConformance.PDF1_5)
        End Using
    End Using
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
    using (Stream inputStream = File.Open("image.jpg", System.IO.FileMode.Open))
    {
        using (Stream outputStream = File.Create("image.pdf"))
        {
            gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatUNKNOWN, outputStream, PdfConformance.PDF1_5);
        }
    }
}
See Also