I am trying to set margin to my html to pdf document. but its not adding right margin. content also not showing fully.
async Task<byte[]> ITransformHelper.ConvertHtmlToPdf(string htmlDocument, Manifest manifest, string header, string footer, string requestId)
<a class="attachment" href="/uploads/default/86449">image.png</a> (65.0 KB)
{
string htmlFilePath = "";
htmlFilePath = manifest.Output.OutputFileName?.Replace(".pdf", ".html");
string modifiedHtml = htmlDocument.Replace("<body>", $"<body style='margin: 10px 20px 10px 30px;'>");
File.WriteAllText(htmlFilePath, modifiedHtml);
var api = new HtmlApi("8bb39521-349d-415a-8712-8c6c8adb0b16", "31dab4a55d3ab3e2e1b89bdd8fd2d4f0").ConvertApi;
var result = await api.ConvertAsync(htmlFilePath, manifest.Output.OutputFileName);
// Load existing PDF document
var pdfDocument = new Aspose.Pdf.Document(manifest.Output.OutputFileName);
// Initialize HTMLLoadSave Options
HtmlLoadOptions options = new HtmlLoadOptions();
// Load HTML document using Aspose.Pdf.Document
var doc = new Aspose.Pdf.Document(htmlFilePath, options);
// Save the Aspose.Pdf.Document to PDF
doc.Save(pdfDocument + "RenderContentToSamePage.pdf");
pdfDocument.Save(manifest.Output.OutputFileName);
byte[] fileBytes = File.ReadAllBytes(manifest.Output.OutputFileName);
return fileBytes;
}
0000000000.png (73.8 KB)