Regarding Page Limit setting for PDF conversion[Java]

Hi,
I am using Aspose.total with Developer OEM license.
I am using the latest version of Aspose words [21.12 ]
I have deployed the Java application using Google Cloud Load Balancer - back end

When I try to convert 100 pages of DOCX files or 100 pages of PPTX or 100 pages of XLSX to PDF, there is no issue for the first time.
CPU Utilization of my back end server reaches more than 60% when multiple PDF conversion done

In order to avoid to this high memory utilization, we need to know how to the page limit for Aspose.Slides[PPTX],Aspose.Cells[XLSX],Aspose.Words[Docx] during PDF conversion?

Could you verify it once and update us.

@dev.raz The most memory and CPU consumng operation upon conversion MS Word document to fixed page formats, such as PDF, is page layout. In Aspose.Words you can use IPageLayoutCallback to skip layout of pages after some limit. For example the following code builds layout for the first two pages only:

int pagesToRender = 2;
Document doc = new Document("C:\\Temp\\in.docx");
doc.getLayoutOptions().setCallback(new PageLayoutCallback(pagesToRender));
try
{
    doc.updatePageLayout();
}
catch (PageLimitReachedException ex)
{
    PdfSaveOptions opt = new PdfSaveOptions();
    opt.setPageSet(new PageSet(new PageRange(0, pagesToRender - 1)));
    doc.save("C:\\Temp\\out.pdf", opt);
}
private static class PageLayoutCallback implements IPageLayoutCallback
{
    public PageLayoutCallback(int maxPageCount)
    {
        mMaxPageCount = maxPageCount;
    }

    @Override
    public void notify(PageLayoutCallbackArgs args) throws Exception
    {
        if (args.getEvent() == PageLayoutEvent.PART_REFLOW_STARTED &&
                args.getPageIndex() >= mMaxPageCount)
            throw new PageLimitReachedException();
    }

    private int mMaxPageCount;
}
private static class PageLimitReachedException extends Exception { }

@alexey.noskov
Thank you for the reply
We will check with our implementation and get back to you.

Could you share the same for Slides and cells because we need to implement like this to slides and cells also

@dev.raz,

In Aspose.Cells, we have PdfSaveOptions.setPageCount() attribute to limit the count of pages to output. Moreover, you can use PdfSaveOptions.setPageSavingCallback() attribute to implement the interface IPageSavingCallback for skipping some pages to output file for your needs. See the document on working on the IPageSavingCallback interface for your reference.