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

Free Support Forum - aspose.com

Add paragraphs to document (auto-create next page)

Hi,
I want to add paragraphs to a new page of PDF. I followed this thread: Left/Top aligning of text - Aspose.PDF Product Family - Free Support Forum - aspose.com to make content start at the top-left of the page. However, when paragraphs are too long, the result is only added to one page and some content is lost. How can I add paragraphs if the content is too long and it auto-creates the next page?
Thanks,
Hung

@hung1028

Could you please attach the following resources here for testing:

  • Your input PDF document.
  • Please attach the output file that shows the undesired behavior.
  • Please attach the expected output file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

@tahir.manzoor
Here is my example. Please take a look
Thanks,
Hung
Aspose.7z (568.3 KB)

@hung1028

Please use following code example to achieve your requirement. We suggest you please read the following article. Hope this helps you.
Convert Text to PDF

TextReader tr = new StreamReader(@"content.txt");

// Instantiate a Document object by calling its empty constructor
Document pdfDocument = new Document();

// Add a new page in Pages collection of Document
Page page = pdfDocument.Pages.Add();
page.PageInfo = new PageInfo
{
    Margin = new MarginInfo
    {
        Left = 50,
        Top = 50,
        Right = 50,
        Bottom = 50,
    },
};
var text = new TextFragment(tr.ReadToEnd())
{
    TextState =
    {
        FontSize = 14,
        HorizontalAlignment = HorizontalAlignment.Justify,
        Font = FontRepository.FindFont("Arial"),
        BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.White),
        ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black)
    }
};

// Add a new text paragraph in paragraphs collection and pass the TextFragment object
page.Paragraphs.Add(text);

pdfDocument.Save(MyDir + "21.12.pdf");