Margins on new page

I am creating a table of contents, the background color of the page is purple. I draw the rectangle to create the background color, then add the table of contents. When the table of contents goes to a second page I listen for the handler page added, I first remove the margins so that the background color goes to the edge, but then when I reset the margins the table of content does not adhere to the margins and starts at the very top of the new page. 

Is there a way you can set the background color irrelevant of margins so it fills the entire page but the text adheres to the margins?

6 Replies 1 reply marked as answer

GK Gowthamraj Kumar Syncfusion Team November 18, 2020 02:18 PM UTC

Hi Martin, 

Thank you for using Syncfusion products. 

Currently, we are analyzing your requirement in our end and we will update you the further details on November 20th 2020. 

Kindly please provide more details about your requirement, so that it will be helpful for us to analyze and assist you further on this. 

Regards, 
Gowthamraj K 



MA Martin replied to Gowthamraj Kumar November 18, 2020 02:30 PM UTC

Hi Martin, 

Thank you for using Syncfusion products. 

Currently, we are analyzing your requirement in our end and we will update you the further details on November 20th 2020. 

Kindly please provide more details about your requirement, so that it will be helpful for us to analyze and assist you further on this. 

Regards, 
Gowthamraj K 


Thnaks Gowthamraj.

To simplify the requirement it is as follows:

Using to add text to a new page

Dim element As PdfTextElement = New PdfTextElement(content, fFont, PdfBrushes.Black)
        Dim format As PdfLayoutFormat = New PdfLayoutFormat()
        format.Break = PdfLayoutBreakType.FitPage
        format.Layout = PdfLayoutType.Paginate
        'Dim result As PdfLayoutResult = element.Draw(tocPage, points)
        Dim result As PdfTextLayoutResult
        result = element.Draw(tocPage, New RectangleF(points, New SizeF(tocPage.Graphics.ClientSize.Width - 165, 40)))

This allows the text to move on to the next page, but the next page needs ot have a solid purple back color to all the edges, but the  text needs to have a margin of 30 all the way around. The first page i can create fine, the sceond page i remove all margins, make back purple, re-add margins to 30 but the text does not stay within the margins. However, i save the co-ordinates of the text so i can add PdfDocumentLinkAnnotation, this when applied adheres to the margins so is 30 points out from the actual text.





GK Gowthamraj Kumar Syncfusion Team November 19, 2020 01:33 PM UTC

Hi Martin, 

Thank you for sharing the details. 

As we said earlier, we are analyzing your requirement with provided details in our end and we will update you the further details on November 20th 2020. 

Regards, 
Gowthamraj K 



MK Moorthy Karunanithi Syncfusion Team November 20, 2020 04:04 PM UTC

Hi Martin, 
 
Sorry for the inconvenient caused,  
 
Still, we are analyzing to achieve your requirement with provided details on our end and we will update you the further details on November 24th, 2020 without any further delay.  
 
Regards, 
Moorthy K 



MA Martin replied to Moorthy Karunanithi November 20, 2020 04:44 PM UTC

Hi Martin, 
 
Sorry for the inconvenient caused,  
 
Still, we are analyzing to achieve your requirement with provided details on our end and we will update you the further details on November 24th, 2020 without any further delay.  
 
Regards, 
Moorthy K 


Thanks for the update Moorthy


GK Gowthamraj Kumar Syncfusion Team November 24, 2020 06:54 PM UTC

Hi Martin, 

Thank you for your patience. 
 
We have created the sample to add margin on next page of the PDF document using PdfTextElement class in our Syncfusion PDF library. We have get the current page from PdfLayoutResult instance and compare the current pages and draw the back color to that page. We have attached the sample for your reference. Please try the below sample in your end and let us know the result.       
  
 
If still you are facing an issue, kindly please share the complete code snippet, output document to check the scenario in our end. So, that it will be helpful for us to analyze and assist you further on this. 

Regards, 
Gowthamraj K 


Marked as answer
Loader.
Up arrow icon