Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Pdf to Image Conversion-generating black images

$
0
0
Hi,

when i try to convert a pdf doc page (specification-1.3) to image.The resulting images are black.

we are using Aspose.Pdf version 7.0.does it support versions below 1.4?

I'm using the below code.

private static void GenerateImageFromPDF(Int32 pageNumber, string inputFilePath, string outputFilepath)
        {
            System.Drawing.Size resize = new System.Drawing.Size(200, 300);
            Aspose.Pdf.License _licensePdf = new Aspose.Pdf.License();
            _licensePdf.SetLicense("Aspose.Total.lic");

            using (Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputFilePath))
            {
                
                pdfDocument.Validate("test.txt", Aspose.Pdf.PdfFormat.);
                Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(80);
                Aspose.Pdf.Devices.PngDevice pngDevice;
                pngDevice = new Aspose.Pdf.Devices.PngDevice(resize.Width, resize.Height);
                if (resize.Height == 0 || resize.Width == 0)
                {
                    pngDevice = new Aspose.Pdf.Devices.PngDevice(resolution);
                }
                else
                {
                    pngDevice = new Aspose.Pdf.Devices.PngDevice(resize.Width, resize.Height);
                }
                var directory = Path.GetDirectoryName(outputFilepath);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                // Convert a particular page and save the image to stream
                pngDevice.Process(pdfDocument.Pages[pageNumber], outputFilepath);

            }
        }

--
Thanks,
Lalitya

Viewing all articles
Browse latest Browse all 3131

Trending Articles