PDF RGB to CMYX cannot find the method pdfDocument.convert(ColorSpaceType.Cmyk);

image.png (1.1 KB)
Aspose pdf for Java latest version 24.1 does not have this method
Is there any other way to convert PDF RBG to CMYK

@rivert015

Can you please share the entire chunk of the code where you were using this method? We will provide you the alternate solution from the perspective of the latest available version of the API.

@asad.ali
Change Color Space of PDF Document using Java | Aspose.PDF Java PDF Processing API

// Change the color space to CMYK
pdfDocument.convert(ColorSpaceType.Cmyk);

this document show this method but now i cant find it

@MrMao

Please try to use below code snippet to convert RGB document into CMYK:

Document document = new Document("RGB.pdf");
// converting text colors to CMYK
PdfFormatConversionOptions options = new PdfFormatConversionOptions("CMYK-logs.log", PdfFormat.PDF_X_1A);
document.convert(options);
document.save("CMYK.pdf");

In the meanwhile, we are checking the older information shared over the link and will update it accordingly.

@asad.ali thanks for you reply
can you tell me param CMYK-logs.log means
can i use other param to change pdf gray or black?

@MrMao

The .log file contains errors information and log that API faces and resolves during the conversion of PDF to PDF/X_1A.

From RGB to Grayscale conversion, you can please use below code sinppet:

using (Document document = new Document(dataDir + "input.pdf"))
{
    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
        strategy.Convert(page);
    }
    // Save resultant file
    document.Save(dataDir + "Test-gray_out.pdf");
}