Friends,
I have a requirement to read a .pdf file and export the content to
a .png image format assuming that the pdf will contain only one page
and that page will contain image. I am using abcpdf 6.0 for the
purpose. The product has a method called GetData() which returns the
byte[].

Doc theDoc = new Doc();
        theDoc.Read(Server.MapPath("./Pdf/test.pdf"));
        byte[] theData = theDoc.GetData();
        System.Drawing.Image newImage;
        using (MemoryStream ms = new MemoryStream(theData, 0,
theData.Length))
        {
            ms.Write(theData, 0, theData.Length);
            //newImage = System.Drawing.Image.FromStream(ms, true);
            newImage = new System.Drawing.Bitmap(ms);
        }

Reading is not a problem but at the time saving the content as .png is
problem as
newImage = new System.Drawing.Bitmap(ms);
This line throws an exception ‘Invalid parameter’. Well I have tried
other methods too one of them is
newImage= System.Drawing.Bitmap.FromStream(stream, true);
           ImageConverter imageConverter = new
System.Drawing.ImageConverter();
But nothing seems working as the format of a .png is not as the same
as it contains in the memory stream. There is a way using
ghostsscript. Hmmm is it possible to save it as image without using
any third party dll?
Thanks in advance for reading this post……………….

Reply via email to