How to set page size of PDF document with Aspose.PDF REST API?

Hello,

We have a problem with converting an image to PDF. It gets stretched to the size of the page and has a broken size in the result.

We saw you have a related ticket PDFCLOUD-33 from this topic Convert JPEG to PDF with image size and orientation using Aspose.PDF REST API. Was it resolved yet?

Is it possible now to set page sizes and margins via cloud API?

Thanks in advance
Ivan

@idorosh

Thank you for contacting Aspose Support.

We have a problem with converting an image to PDF. It gets stretched to the size of the page and has a broken size in the result.

Please use PUT /pdf/{name} API and set fitSize parameter value to true. The cURL example would look as follows:

// cURL example to create PDF from JPG   
curl -v "https://api.aspose.cloud/v1.1/pdf/pdfFromImage.pdf?templateFile=Penguins.jpg&templateType=jpg&fitSize=true" \
-X PUT \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Content-Length: 0" \
-H "Authorization: Bearer cxKb_YpVXmW7RQU2-givh_RKE6WsYC09H0qsocB2R9lYzkiRryRW0mTzG6CHBZ62G3xMmHDGXoFWML-f-1g8BX0TeJHKhQlJScjlngpxsoi6JBvkbCxGurqWrTjCmewlZox01a8pqvtnT6VXv93mmJza08KqwWB5rWn-6rfrlH4OX-SxX4Jwv-5rvBVchRFdtzXzuf8YZlsNYEGWR4Ymqz-2nJyHoSUGGtalrNV4Bpkp0pf8wWN208mGXeNspOCVb-Vi9KQ0ZZptLKo73UE3bzUL9e3QQU00dX_ajxYE_ZZN0MLJ0mriDj8KQ6ofXQQM2FiR9Q9R4JV8vtL3iVtYNme6nOqUhshwRMjGV7eAZ6zlSiUBNX9y5x-I52ECR0jc1gcvzA3QCwh82pKlmeRmOvJRjlx48GvdxDplx-tymypj_r94PP6sldY1-dBOGdGZPX_cR-h2_cxNL-LDsG2jzJ9-k1Y"

Is it possible now to set page sizes and margins via cloud API?

PUT /pdf/{name}/create/images API let you specify page margins and size (width and height).

P.S. Please check our GitHub repository for a complete list of Aspose.PDF SDKs along with working examples.