# How to use GdPicture in your code?

To make calls to the web service from a client application that utilizes the GdPicture converter, the web service must first be properly configured.

Begin by duplicating the existing GdPicture converter node and renaming the copy to **GdPicture High Fidelity**. Set the `fidelity` value to **High**:

```csharp

<add key="GdPicture High Fidelity"
     description="GdPicture Converter"
     fidelity="High"
     maxInstances="2"
     supportedExtensions="docx,docm,dotx,doc,dot,rtf,htm,html,mht,mhtml,xml,tif,xls,
                          xlsx,xlsm,csv,ppt,pptx,pptm,ps,msg,eml,dxf,cur,wsq,gif,bmp,
                          cut,dds,dib,dicom,exif,exr,fax,g3,hdr,heif,heic,iff,ico,j2k,
                          j2c,webp, jb2,jbig2,jif,jfif,jng,jp2,jpeg,jpg,jpe,koa,lbm,
                          mng,pbm,pcd,pct,pict,pic,pcx,pdf,pfm,pgm,psd,png,pnm,ppm,ras,raw,
                          rle,sgi,svg,tga,targa,tiff,tif,wbmp,wap,wbm,xbm,xpm"
     supportedOutputFormats="pdf"
     type="Muhimbi.DocumentConverter.WebService.GdPictureConverter,
           Muhimbi.DocumentConverter.WebService, Version=1.0.1.1, Culture=neutral, PublicKeyToken=c9db4759c9eaad12" />

```

With the above configuration in place, any web service calls requesting **High** fidelity conversion will automatically use the GdPicture converter, as defined by the second configuration element:

```csharp

static void Main(string[] args)
{
DocumentConverterServiceClient client = null;

    try
    {
        // ** Delete any processed files from a previous run.
        foreach (FileInfo f in new DirectoryInfo(".").GetFiles("*.pdf"))
            f.Delete();

        // ** Determine the source file and read it into a byte array.
        string sourceFileName = null;
        if (args.Length == 0)
        {
            // ** If nothing is specified, then read the first PDF file from the current folder.
            string[] sourceFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.docx");
            if (sourceFiles.Length > 0)
                sourceFileName = sourceFiles[0];
            else
            {
                Console.WriteLine("Please specify a document to convert.");
                Console.ReadKey();
                return;
            }
        }
        else
            sourceFileName = args[0];

        byte[] sourceFile = File.ReadAllBytes(sourceFileName);

        // ** Open the service and configure the bindings.
        client = OpenService(SERVICE_URL);

        //** Set the absolute minimum open options.
        OpenOptions openOptions = new OpenOptions();
        openOptions.OriginalFileName = Path.GetFileName(sourceFileName);
        openOptions.FileExtension = Path.GetExtension(sourceFileName);

        // ** Set the absolute minimum conversion settings.
        ConversionSettings conversionSettings = new ConversionSettings();
        conversionSettings.Format = OutputFormat.PDF;
        conversionSettings.Fidelity = ConversionFidelities.High;

        // ** Carry out the conversion.
        Console.WriteLine("Converting file " + sourceFileName + ".");
        byte[] convFile = client.Convert(sourceFile, openOptions, conversionSettings);

        // ** Write the processed file back to the file system with a PDF extension.
        string destinationFileName = Path.GetFileNameWithoutExtension(sourceFileName) + ".pdf";
        using (FileStream fs = File.Create(destinationFileName))
        {
            fs.Write(convFile, 0, convFile.Length);
            fs.Close();
        }

        Console.WriteLine("File written to " + destinationFileName);

        // ** Open the generated PDF file in a PDF reader.
        Console.WriteLine("Launching file in PDF Reader");
        Process.Start(destinationFileName);
    }
    catch (FaultException<WebServiceFaultException> ex)
    {
        Console.WriteLine("FaultException occurred: ExceptionType: " +
                         ex.Detail.ExceptionType.ToString());
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());
    }
    finally
    {
        CloseService(client);
    }
    Console.ReadKey();

}

/// <summary>
/// Configure the bindings and endpoints and open the service using the specified address.
/// </summary>
/// <returns>An instance of the web service.</returns>
public static DocumentConverterServiceClient OpenService(string address)
{
DocumentConverterServiceClient client = null;

    try
    {
        BasicHttpBinding binding = new BasicHttpBinding();
        // ** Use standard Windows Security.
        binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
        binding.Security.Transport.ClientCredentialType =
                                                        HttpClientCredentialType.Windows;
        // ** Increase the client timeout to deal with (very) long running requests.
        binding.SendTimeout = TimeSpan.FromMinutes(120);
        binding.ReceiveTimeout = TimeSpan.FromMinutes(120);
        // ** Set the maximum document size to 50MB.
        binding.MaxReceivedMessageSize = 50 * 1024 * 1024;
        binding.ReaderQuotas.MaxArrayLength = 50 * 1024 * 1024;
        binding.ReaderQuotas.MaxStringContentLength = 50 * 1024 * 1024;

        // ** Specify an identity (or any identity) to get past.net3.5 sp1.
        EndpointIdentity epi = EndpointIdentity.CreateUpnIdentity("unknown");
        EndpointAddress epa = new EndpointAddress(new Uri(address), epi);

        client = new DocumentConverterServiceClient(binding, epa);

        client.Open();

        return client;
    }
    catch (Exception)
    {
        CloseService(client);
        throw;
    }

}

/// <summary>
/// Check if the client is open and then close it.
/// </summary>
/// <param name="client">The client to close</param>
public static void CloseService(DocumentConverterServiceClient client)
{
if (client!= null && client.State == CommunicationState.Opened)
client.Close();
}

```

---

## Related pages

- [How does the Conversion Service handle concurrency and how can it be adjusted?](/guides/document-converter/document-converter-services/knowledge-base/how-does-the-conversion-service-deal-with-concurrency-and-how-to-tweak-it.md)
- [How does Document Converter handle InfoPath attachments?](/guides/document-converter/document-converter-services/knowledge-base/how-does-the-pdf-converter-deal-with-infopath-attachments.md)
- [How to specify which InfoPath view to convert from your code?](/guides/document-converter/document-converter-services/knowledge-base/how-can-i-specify-which-infopath-view-to-convert-from-my-own-code.md)
- [Do you have sample code for Text Extraction functionality?](/guides/document-converter/document-converter-services/knowledge-base/sample-code-for-text-extraction.md)
- [How to make HTML-to-PDF conversion more secure?](/guides/document-converter/document-converter-services/knowledge-base/make-html-to-pdf-conversion-more-secure.md)
- [Knowledge base: SharePoint Document Converter](/guides/document-converter/document-converter-services/knowledge-base.md)
- [Common code to open and close DocumentConverterServiceClient](/guides/document-converter/document-converter-services/knowledge-base/open-and-close-documentconverterserviceclient.md)
- [Do you have sample code for KVP Extraction functionality?](/guides/document-converter/document-converter-services/knowledge-base/sample-code-for-kvp-extraction.md)
- [Using Document Converter from PowerShell](/guides/document-converter/document-converter-services/knowledge-base/using-the-pdf-converter-from-powershell.md)

