We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF to JPG putting white lines across images

Converting from PDF to JPG puts white lines across images. Using latest Aspose.PDF .NET ver
page1.jpg (111.4 KB)
temppdf.pdf (751.1 KB)


Thanks for contacting support.

We have tested the scenario in our environment with following code snippet and were unable to notice the issue. Please check following code snippet which we have used to convert the document into JPG image.

Document pdfDocument = new Document(dataDir + "temppdf.pdf");
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
                using (FileStream imageStream = new FileStream(dataDir + "image" + pageCount + "_out" + ".jpg", FileMode.Create))
                    // Create JPEG device with specified attributes
                    // Width, Height, Resolution, Quality
                    // Quality [0-100], 100 is Maximum
                    // Create Resolution object
                    Resolution resolution = new Resolution(300);

                    // JpegDevice jpegDevice = new JpegDevice(500, 700, resolution, 100);
                    JpegDevice jpegDevice = new JpegDevice(resolution, 100);

                    // Convert a particular page and save the image to stream
                    jpegDevice.Process(pdfDocument.Pages[pageCount], imageStream);

                    // Close stream

For your reference, generated output is also attached. image1_out.jpg (1.3 MB)

Please try using above code snippet and in case you still face any issue, please share your environment details (i.e OS version, Application Type, Target Framework, etc.), so that we can test the scenario in our environment and address it accordingly.

I will try it with your code. Here is my code snippet. I didn’t know about the JpegDevice.
My environment: Windows 10 or Windows Server 2008, .NET 4.5.
My code uses the Aspose.Pdf.Facades.PdfConverter.

        string pdfpath = "temppdf.pdf";
        Aspose.Pdf.License license = new Aspose.Pdf.License();
        Aspose.Pdf.Facades.PdfConverter converter = new PdfConverter();
        int iCount = 2;
        for (int i = 1; i <= iCount && converter.HasNextImage(); i++)
            string nextimagefilename = string.Format("page{0}.jpg", i);
            if (File.Exists(nextimagefilename)) File.Delete(nextimagefilename);
            converter.GetNextImage(nextimagefilename, System.Drawing.Imaging.ImageFormat.Jpeg, 1000, 1300, 80);


Thanks for sharing sample code snippet.

We have also observed the output image with lines over it, after executing the code snippet, which you have shared.

However please note that it is recommended to use Aspose.Pdf (Document Object Model) approach, in order to generate images from PDF pages (i.e code snippet which we have shared earlier), as Aspose.Pdf.Facades approach will going to be obsoleted sooner or later and fixes against issues in this approach are being provided in Aspose.Pdf (DOM).

In case you face any issue while using DOM model, please feel free to let us know. For more information regarding Aspose.Pdf DOM, please check “Convert PDF Pages” article(s) in our API documentation.

I used your sample code and it works if I use this line:
JpegDevice jpegDevice = new JpegDevice(resolution, 100);

But it still puts the white lines just as before if I specify a smaller page width and height.
Using either the size from the documentation example (500, 700), or this one:
JpegDevice jpegDevice = new JpegDevice(1000, 1300, resolution, 100); // or use quality 80
It outputs white lines over the image.

I would prefer to specify a smaller width and height so my jpeg file size isn’t so large.
I reduced the quality to 80 which helped the image size, but it would still be better if I could specify width and height.
Thank you for your help!


Thanks for adding more details to the scenario.

We have observed that if we lower the quality and height/width of the image, white lines appears over the output image. Hence for the sake of correction, we have logged an issue as PDFNET-43429 in our issue tracking system. We will further investigate the reasons behind this and keep you posted with the status of its rectification. Please be patient and spare us little time.

We are sorry for the inconvenience.