Header and table (VB)

Hello,

I have some problem with my header. I made an header with a table inside it. And then I try to use a table too in my doc with a Margin.Top at 10. But I certainly made a mistake because my content table begin on the header. Can you help me fix it?
If I use a text instead of a table for the content it works.

Here’s my code and the render is attached.

’ Instantiate an object PDF class
Dim license As License = New License
license.SetLicense(“Aspose.Total.lic”)
Dim Doc = New Pdf

’ add the section to PDF document sections collection
Dim section As Aspose.Pdf.Section = New Section(Doc)
Doc.Sections.Add(section)

Dim header As HeaderFooter = New HeaderFooter(section)
section.OddHeader = header
section.EvenHeader = header

Dim Tableau As Table = New Table()
Tableau.ColumnWidths = “300 150”
Dim Row As Row
Row = Tableau.Rows.Add()
Dim Cellule As Cell = Row.Cells.Add()
Dim Cellule2 As Cell = Row.Cells.Add()

'Add img header
Dim Paragraphe As Aspose.Pdf.Paragraphs = Cellule.Paragraphs
Dim image As Aspose.Pdf.Image = New Aspose.Pdf.Image()

Paragraphe.Add(image)
image.ImageInfo.File = “D:/imgentete.png”
image.ImageInfo.ImageFileType = ImageFileType.Png
image.ImageInfo.Alignment = AlignmentType.Left
image.ImageScale = 0.7
Cellule.VerticalAlignment = VerticalAlignmentType.Center
Cellule.Padding.Top = 10
Cellule.Padding.Bottom = 30
Cellule.Padding.Left = 7
Cellule.Padding.Right = 2

'Add text header
Dim t As Aspose.Pdf.Text = New Aspose.Pdf.Text
t.Segments.Add(“TestEntete”)
Cellule2.Padding.Top = 10
Cellule2.Padding.Bottom = 10
Cellule2.Padding.Left = 0
Cellule2.Padding.Right = 15
Cellule2.VerticalAlignment = VerticalAlignmentType.Center
t.TextInfo.Alignment = AlignmentType.Right
Cellule2.Paragraphs.Add(t)

Tableau.Border = New BorderInfo(BorderSide.All, 0.1F, New Color(102, 102, 102))
header.Paragraphs.Add(Tableau)

'Content
Dim Tableau2 As Table = New Table
Tableau2.Margin = New MarginInfo()
Tableau2.ColumnWidths = “100”
Tableau2.Margin.Left = 20
Tableau2.Margin.Top = 10
Tableau2.DefaultCellTextInfo.LineSpacing = 1
Tableau2.DefaultCellBorder = New BorderInfo(BorderSide.All, 0.1F, New Color(“Red”))
Tableau2.DefaultCellTextInfo.FontSize = 6.5
Tableau2.DefaultCellTextInfo.Alignment = AlignmentType.Left
Tableau2.DefaultCellTextInfo.FontName = “Arial”
Tableau2.IsBroken = False
For i As Integer = 0 To 75
Dim Row2 As Row = Tableau2.Rows.Add()
Dim cell2 As Cell = Row2.Cells.Add()
Dim text2 As Text = New Text()
cell2.Paragraphs.Add(text2)
Dim seg2 As Segment = text2.Segments.Add()
seg2.Content = “Testcontent” & i
Next
section.Paragraphs.Add(Tableau2)

Doc.Save(“D:/Entete.pdf”)

Hello Anouck,

Thanks for using our products.

I have tested the scenario and I am able to notice the problem that Margin.Top information for the table in body section is not properly being honored. For the sake of correction, I have logged this problem as PDFNET-24022. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

As a workaround, please comment out the code line where you are specifying the Margin.Top information for Tableau2. By default the contents in PDF document are displayed in flow layout i.e. 1st Header Section will be displayed, then body Section and after that Footer section. Same is the case with paragraphs in a section. First paragraph is displayed and then the subsequent paragraph and so on.

In your specific case, first the Header section is displayed and then contents of main body section are displayed. Please take a look over the attached PDF document that I have generated while using Aspose.Pdf for .NET 4.9.0 where Tableau2.Margin.Top = 0

I can’t use your workaround. Let me explain my problem.
In fact I made that file just for simplify the way I have done my document. I have a table with several images and nested tables for content in my real code. And I can add a table after that but the number of nested tables and images can change. So in one case I can have all of it in one page and I need a space between all this content and my second table (which contains some comments I can add to my doc) but for another case the images and nested tables will take all the pages so the second table is on the top of my second page and that’s the case I represent here. So I really need my top margin you see… I need another way to go around that issue, please.

I attached some chart so that you can see my two cases more clearly


I really need help on this one, please. Our customer will certainly not appreciate this bug and they could see it after this afternoon because we can’t wait more before changing our Aspose version.

Hi,

Sorry for replying you late.

Our development team is working hard to get PDFNET-24022 resolved. I am afraid I might not be able to share any other workaround to resolve this problem. However, as you explained the scenario in 281604, I am unable to test the scenario. Can you please share some sample code so that we can test the scenario. We are really sorry for this inconvenience.

The issues you have found earlier (filed as 24022) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.