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

Free Support Forum - aspose.com

Page break and Margin

Hi,

I am creating PDF using aspose.words latest dll.
Eventually PDF is being created from html string.
How do I setup specific tag or something else in html so that it creates new page when converting to pdf when ever aspose dll reads that tag in html.

Also, I wanna know how can I set margin of page in PDF being created,

Below is my code snippet I am using

byte[] byteArray = Encoding.UTF8.GetBytes("" + [HTML Content] + “”);

using (MemoryStream stream = new MemoryStream(byteArray))
{
Aspose.Words.Document wordDoc = new Aspose.Words.Document(stream);
wordDoc.Save(pathToSaveServer + “\” + filenameToBeDeleted);


Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(pathToSaveServer + “\” + filenameToBeDeleted);
pdfDoc.Encrypt(password, password, 0, Aspose.Pdf.CryptoAlgorithm.AESx128);
pdfDoc.Save(pathToSaveServer + “\” + filename);

}

Please guide me here

Thanks
Rohit

Hi Rohit,


Thanks for your inquiry. Please see the following HTML and code to meet these requirements.

<html>

<head><o:p></o:p>

<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” /><o:p></o:p>

<meta http-equiv=“Content-Style-Type” content=“text/css” /> <o:p></o:p>

<title><o:p></o:p>

</title><o:p></o:p>

</head><o:p></o:p>

<body><o:p></o:p>

<div><o:p></o:p>

<p style=“margin-top:0pt; margin-bottom:8pt; line-height:108%; font-size:11pt”><o:p></o:p>

<span style=“font-family:Calibri”>This should be on page 1</span><o:p></o:p>

</p><o:p></o:p>

<p style=“margin-top:0pt; margin-bottom:8pt; line-height:108%; font-size:11pt”><o:p></o:p>

<br style=“page-break-before:always; clear:both” /><o:p></o:p>

</p><o:p></o:p>

<p style=“margin-top:0pt; margin-bottom:8pt; line-height:108%; font-size:11pt”><o:p></o:p>

<span style=“font-family:Calibri”>This should be on page 2</span><o:p></o:p>

</p><o:p></o:p>

</div><o:p></o:p>

</body><o:p></o:p>

</html>


Document doc = new Document(MyDir + @“in.html”);<o:p></o:p>

PageSetup ps = doc.FirstSection.PageSetup;

ps.LeftMargin = 2 * 72;

ps.RightMargin = 2 * 72;

ps.TopMargin = 2 * 72;

ps.BottomMargin = 2 * 72;

doc.Save(MyDir + @"17.6.pdf");


Hope, this helps.

Best regards,