title: Image to PDF conversion without using third party library in C#
body: <p>I need to convert image files to PDF without using third party libraries in C#. The images can be in any format like (.jpg, .png, .jpeg, .tiff).</p>
  
  <p>I am successfully able to do this with the help of itextsharp; here is the code.</p>
  
  <pre><code>string value = string.Empty;//value contains the data from a json file
      List&lt;string&gt; sampleData;
      public void convertdata()
      {
          //sampleData = Newtonsoft.Json.JsonConvert.DeserializeObject&lt;List&lt;string&gt;&gt;(value);
          var jsonD = System.IO.File.ReadAllLines(@"json.txt");
          sampleData = Newtonsoft.Json.JsonConvert.DeserializeObject&lt;List&lt;string&gt;&gt;(jsonD[0]);
          Document document = new Document();
  
          using (var stream = new FileStream("test111.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
          {
              PdfWriter.GetInstance(document, stream);
              document.Open();
  
              foreach (var item in sampleData)
              {
                  newdata = Convert.FromBase64String(item);
                  var image = iTextSharp.text.Image.GetInstance(newdata);
                  document.Add(image);
                  Console.WriteLine("Conversion done check folder");
  
              }
              document.Close();
          }
  </code></pre>
  
  <p>But now I need to perform the same without using third party library.</p>
  
  <p>I have searched the internet but I am unable to get something that can suggest a proper answer. All I am getting is to use it with either "itextsharp" or "PdfSharp" or with the "GhostScriptApi".</p>
  
  <p>Would someone suggest a possible solution?</p>