Convert HTML to PDF using Aspose.PDF REST API with page margins

I’m using the Aspose Cloud to convert HTML to PDF using the REST API. I’ve got everything working fine except that I cannot figure out how to set the Page Margins on the PDF. The default Page Margins are huge and it ruins my documents - I don’t want any margins on the PDF unless I specify them.


Does anyone know how to set the PDF margins before/during HTML to PDF conversion?

Hi Peter,


Thanks for your inquiry. I’m sorry to share with you that there is no way to set page size or margins. I have logged these feature requests under ticket ids SAASPDF-99 and SAASPDF-100 in our issue tracking system. Your request has also been linked to these issues and you will be notified as soon as it is supported and available for the public use. We’re sorry for your inconvenience.

Hi Imran,


Thanks for the response. I’m disappointed that it isn’t a feature right now, but glad to hear it’s been logged as a request.

I’ve already done an implementation using the .NET library so I can fall back to that, but the pricing for that is too high to use the .NET library in production - hence the interest in Aspose Cloud.

Can I check the status of those 2 tickets on this website somewhere or do I just wait for an email?

Regards,
Peter

Hi Peter,


Thanks for your inquiry. Unfortunately, there is no direct way you can track issues by yourself. But, you are welcome to ask the issue status via forum threads. We will verify the status from our internal issue tracking system and reply you back.

@peter.watts

As an update, please note we have already implemented your requested feature in Aspose.PDF Cloud API. Please check the following API Methods and C# sample code for reference.

​GET /pdf​/create​/html Convert HTML file (located on storage) to PDF format and return resulting file in response

​PUT /pdf​/{name}​/create​/html Convert HTML file (located on storage) to PDF format and upload resulting file to storage

string name = "HtmlWithImage.zip";
string htmlFileName = "HtmlWithImage.html";
string resultName = "fromHtml.pdf";
string TempFolder = "Temp";
int height = 850;
int width = 600;
int top_margin =10;
int bottom_margin = 10;
int right_margin = 10;
int left_margin = 10;

var response = pdfApi.PutHtmlInStorageToPdf(resultName, Path.Combine(TempFolder, name), htmlFileName, height, width,marginLeft: left_margin, marginBottom: bottom_margin,marginRight: right_margin, marginTop: top_margin, dstFolder: TempFolder);