Add page breaks in HTML to PDF export

3 posts, 1 answers
  1. Bailey
    Bailey avatar
    3 posts
    Member since:
    Nov 2012

    Posted 19 Mar 2013 Link to this post

    I am using the RichTexBox to read HTML and export it as a PDF. However, I have multiple sources of HTML that each need to have their own page within the PDF file. I got the exporting to work but I can't get a page break to be inserted between each body of HTML.
    What would be the best way to go about this?

    Thanks!
  2. Answer
    Svett
    Admin
    Svett avatar
    728 posts

    Posted 22 Mar 2013 Link to this post

    Hi Bailey,

    You should use the following code snippet to merge multiple documents and inserting page breaks among them:
    private RadDocument MergeDocuments(RadDocument[] documents)
    {
        RadDocument mergedDocument = new RadDocument();
     
        foreach (RadDocument document in documents)
        {
            foreach (Section section in document.Sections)
            {
                Section copySection = section.CreateDeepCopy() as Section;
                document.Sections.Remove(section);
                mergedDocument.Sections.Add(copySection);
            }
     
            mergedDocument.CaretPosition.MoveToLastPositionInDocument();
            mergedDocument.InsertPageBreak();
        }
     
        return mergedDocument;
    }
    Kind regards,
    Svett
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Bailey
    Bailey avatar
    3 posts
    Member since:
    Nov 2012

    Posted 29 Mar 2013 Link to this post

    Worked great, thanks Svett!
Back to Top