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

Free Support Forum - aspose.com

Scale contents of PDF while setting the page size (AsposePDF Java)

I want to scale contents of my pdf page when i resize the page.

double height = doc.getPages().get_Item(1).getPageRect(true).getHeight();
double width = doc.getPages().get_Item(1).getPageRect(true).getWidth();
sampleDoc.getPages().get_Item(1).setPageSize(width, height);

I want to set size of one pdf file according the size of another pdf and this code does help me crop the page to the size i require. However, i want the contents to resize according to the size as well. Kindly guide me how i can achieve that

@ahmedtariq

Pleas refer to the following article about setting and getting the page size of PDF.
Change PDF Page Size Programmatically

If you still face problem, please share the input PDF, problematic and expected output PDF along with code example that you are using to reproduce the same issue at our end. We will then provide you more information it.

Hi, thanks for your response. I am aware of the resizing property in Aspose PDF but i want my PDF page to scale (fit to page) when it resizes. I don’t want to crop it but to scale it. Can you guide me how can i achieve that?

@ahmedtariq

Please share the requested resources. It will help us to understand your requirement. We will then provide you code example according to your requirement.