is it possible to generate a grayscale pdf from a colour pdf
i have searched the forums and help and i have found a similar issue Gray Pdf's from Color Pdf's but it is 4 years old and i wanted to check whether the answer has changed since then
that thread seems to suggest it migth be possible to convert colout pdf to image and then image to grayscale pdf, that sounds a bit of hack and i wondered if there was a more robust method available
Hi Nick,
Thanks for your interest in our products.
I am afraid currently Aspose.Pdf for .NET does not support the capability to directly convert the colored PDF file into GrayScale PDF. So in order to accomplish your above requirement, you may consider using either approach
- Convert the pages of PDF file into image format, change the color space of individual image into GrayScale and then place these images in a PDF file (Create a new PDF file using GrayScale images).
- Convert the PDF file into TIFF image format and then create a PDF file using this TIFF image.
You may consider visiting the following links for details on
- Convert all PDF pages to JPEG Images
- Convert all PDF pages to single TIFF Image
- How to Convert an Image to PDF
In case of any further query, please free to contact. We are sorry for this inconvenience.
Hello,
Hi Diane,
Hello Nayyer,
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(@“F:… <span style=“background-color: rgb(255, 255, 255);”>Exemple-1_pourAspose.pdf”);Aspose.Pdf.RgbToDeviceGrayConversionStrategy strategy = newAspose.Pdf.RgbToDeviceGrayConversionStrategy();for (int idxPage = 1; idxPage <= pdfDoc.Pages.Count; idxPage++){// Get instance of particular page inside PDFPage page = pdfDoc.Pages[idxPage];// Convert the RGB colorspace image to GrayScale colorspacestrategy.Convert(page);}pdfDoc.Save(@“c:\temp<font color=”#0000ff">Exemple-1-PdfGrayScale.pdf",Aspose.Pdf.SaveFormat.Pdf);MessageBox.Show(“Pdf saved”);
dianerheaume:
Hello Nayyer,Thank's for your answer.But... I have already tried that recipe before writing to you.That does not give the expected results.To make sure that I did all that I was supposed to, I did it another time (this morning) with the code in my program following the example in Aspose documentation:Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(@"F:\........ \Exemple-1_pourAspose.pdf");Aspose.Pdf.RgbToDeviceGrayConversionStrategy strategy = newAspose.Pdf.RgbToDeviceGrayConversionStrategy();for (int idxPage = 1; idxPage <= pdfDoc.Pages.Count; idxPage++){// Get instance of particular page inside PDFPage page = pdfDoc.Pages[idxPage];// Convert the RGB colorspace image to GrayScale colorspacestrategy.Convert(page);}pdfDoc.Save(@"c:\temp\Exemple-1-PdfGrayScale.pdf",Aspose.Pdf.SaveFormat.Pdf);MessageBox.Show("Pdf saved");In attached files, you can see the original PDF file containing the image (with color)and the PDF file converted to gray scale (the image is now black and white).Have a nice day,DianeHi Diane,Thanks for using our API's.I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFNET-42188 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.
The issues you have found earlier (filed as PDFNET-42188) have been fixed in Aspose.PDF for .NET 21.8.