Aspose Facades - Not converting files to grayscale


I have used the below code to save the pdf as grayscale, it is running for correctly for <200 pages. But not >200 files are not getting converted, also not getting any exceptions.

                    PdfViewer viewer = new PdfViewer();
                    string outputFile = "";
                    //outputFile = SourceFilePath + foldername + "\\" + "_Grayscale_" + Filename.Replace(" ", "_");
                    outputFile = item.FullName;

                    if (File.Exists(item.FullName))
                    //    viewer.BindPdf(outputPath + "\\" + pdfFileName);

                    viewer.PrintPageDialog = false;
                    viewer.PrintAsGrayscale = true;

                    PrinterSettings ps = new PrinterSettings();
                    PageSettings pgs = new PageSettings();

                    ps.PrinterName = "Microsoft Print to PDF"; // this is virtual printer
                    ps.PrintFileName = outputFile;
                    ps.PrintToFile = true;
                    pgs.PaperSize = new PaperSize("A4", 827, 1169);
                    ps.DefaultPageSettings.PaperSize = pgs.PaperSize;
                    viewer.PrintDocumentWithSettings(pgs, ps);
                    //viewer.PrintLargePdf(SourceFilePath + foldername + "\\" + Filename, pgs, ps);


Please try using another below approach to convert your PDF files into grayscale colorspace and let us know in case you still notice any issues. Also, please make sure to use the latest version of the API i.e. Aspose.PDF for .NET 22.11:


Attached the URL for the input PDF below. Not getting any desired output PDF, its just creating the instance for the file with 0KB and nothing after. Not getting any exception with the attached source code.


We have tried with the approach, same result. Not getting any exception but creating the instance for the file 0KB and nothing else it is proceeding to next step with throwing any exceptions.


Please check the attached output that was generated in our environment. We did not notice any issue that you mentioned. Can you please confirm that you are using 22.11 version of the API. If issue still persists, please share a sample console application that is able to reproduce the issue so that we can further assist you accordingly.


Attached the sample console application code which we tried from our end. We are suing 22.11 version of Aspose.PDF only. Also, we do have license for Aspose.PDF.Product.Family we tried using that but still not getting appropriate result. Without license we are getting only first 4 pages grayscale converted.


Could you please try to use the below code snippet in your shared console application and let us know in case issue still persists. We tested it and did not notice any issues:

using (Document document = new Document(outputFile))
 Aspose.Pdf.RgbToDeviceGrayConversionStrategy strategy = new Aspose.Pdf.RgbToDeviceGrayConversionStrategy();
 for (int idxPage = 1; idxPage <= document.Pages.Count; idxPage++)
  // Get instance of particular page inside PDF
  Page page = document.Pages[idxPage];
  // Convert the RGB colorspace image to GrayScale colorspace
 // Save resultant file

Hi Asad.ali,

We have tried the mentioned code snippet also, at a certain point of time process is getting skipped without throwing any exceptions if the file is more than 200 pages. Both the code works fine if the file has lesser than 200 pages.

Can you please confirm how long it has taken to convert the file to grayscale from your end. Any timeout needs to be increased, please suggest.

Got this error for a file which has 235 pages and size is around 52.6MB

image.png (44.6 KB)


Please share the sample file having more than 200 pages by uploading it to Google Drive or Dropbox so that we can use it in our environment and try to replicate the same issue that you are facing. We will further proceed to assist you accordingly.


Attached the sample document for your reference.


We are still unable to reproduce the issue using 22.11 version of the API. It looks like the issue can only be reproduced while processing bulk documents. Can you please confirm that? Please try to use only shared document in a sole application and see if error still occurs.