static private void InsertIntoDictionary(PdfDocument doc, PdfPage page, PdfImageObject image)
    {
        //Get page dictionary, list of indirect objects and original page content
        var pageDict = page.Dictionary;
        var list     = PdfIndirectList.FromPdfDocument(doc);
        //Convert contents to array.
        PdfTypeArray array = ConvertContentsToArray(pageDict["Contents"], list, pageDict);
        //Get stream of image.
        IntPtr streamHandle = Pdfium.FPDFImageObj_GenerateStream(image.Handle, page.Handle);
        var    stream       = PdfTypeStream.Create(streamHandle);
        //Add image's stream into list of indirect objects and then add it to array.
        int num = list.Add(stream);

        array.AddIndirect(list, num);
    }