Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Dec 17, 2024 11:06 am

Hello,
I have this table, whose length in some cases exceedes the page length (the format is portrait), for example when the table vertcal position is = 364:
Dim tblAgentiDiSost As Table = SezExtra.Body.AddTable(True)
tblAgentiDiSost.TableFormat.Positioning.VertRelationTo = VerticalRelation.Margin
tblAgentiDiSost.TableFormat.Positioning.VertPosition = _
70 + IIf(drwas(d) >= drwri(d), drwas(d) * 17, drwri(d) * 17) _
+ IIf(drwas(d) >= drwri(d) And drwas(d) > 0, 35, 0) _
+ IIf(drwri(d) > drwas(d) And drwri(d) > 0, 35, 0) + 4

tblAgentiDiSost.TableFormat.Positioning.HorizRelationTo = HorizontalRelation.Margin
tblAgentiDiSost.TableFormat.Positioning.HorizPosition = 5

tblAgentiDiSost.TableFormat.Paddings.All = 2
It happens that the table is positioned higher than the calculated vertical position and the table is also truncated.
How can I avoid this behaviour? I would see the table positioned correctly and with page break, finishing in the following page.
Thanks you in advance,
Paola

paolagumi
 
Posts: 85
Joined: Tue Apr 21, 2015 11:32 am

Wed Dec 18, 2024 2:56 am

Hello Paola,

Thank you for your inquiry.

Are you experiencing the issue of the table being truncated when saving the document in PDF format, or does this also happen when saving the document in Docx format?

Please try the following settings:
Code: Select all
'Loop through the table rows
For Each row As TableRow In table.Rows
'Allow break across pages
row.RowFormat.IsBreakAcrossPages = True
Next row


If the above method does not resolve the issue, please provide the resulting document along with the version number of the spire.doc.dll you are currently using. I will investigate further to provide you with an effective solution. Thank you for your assistance.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Wed Dec 18, 2024 7:29 am

Hello Amy,
thank you for your answer to my inquiry,

I've saved my document also in docx format, but I've obtained a strange behaviour: breaks page after every tablerow!
I'm attaching the result in pdf and in docx format (ServizioExtra IM.pdf and ServizioExtra IM.docx)

with your setting:
For Each row As TableRow In table.Rows
row.RowFormat.IsBreakAcrossPages = True
Next row


If the above method does not resolve the issue, please provide the resulting document along with the version number of the spire.doc.dll you are currently using. I will investigate further to provide you with an effective solution. Thank you for your assistance.
, so you can see the difference.
The table which overlaps the second one instead of being divided whìith a page break is the one whose header contains the string "AGENTE DI SOSTITUZIONE/CORSE SOPPRESSE".

I tried your setting:
For Each row As TableRow In table.Rows
row.RowFormat.IsBreakAcrossPages = True
Next row

but the result is the same.

I'm attaching also another pdf (ServizioExtra CAL.pdf) , with different datas but correct beaviour: the difference is in the two tables rows number.

My version is Spire.office spire 9.6.0

Thank you in advance for you precious help,
Paola

paolagumi
 
Posts: 85
Joined: Tue Apr 21, 2015 11:32 am

Wed Dec 18, 2024 9:19 am

Hi Paola,

Thank you for your assistance.

Upon investigation, the issue you're encountering is due to the paragraph before spacing in the footer of your template Word document being set to an unusually high value of 3256.8 points. You can observe this by opening your Word document using MS Word tool, where you will notice that the footer is positioned before the header as a result.

Please refer to the code below to correct the paragraph before spacing in the footer. There's no need to modify the initial table settings.
Code: Select all
 
Dim SezExtra As Spire.Doc.Section = document.Sections(0)
 Dim footer1 As HeaderFooter = SezExtra.HeadersFooters.Footer

 For i As Integer = 0 To footer1.Paragraphs.Count - 1
     Dim beforeSpacing As Single = footer1.Paragraphs(i).Format.BeforeSpacing ' 3256.8
     If beforeSpacing > 1000 Then
         footer1.Paragraphs(i).Format.BeforeSpacing = 0
     End If
 Next


I am looking forward to your further feedback.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Mon Dec 23, 2024 7:08 am

Hi Paola,

Hope you are doing well.

Has your issue been solved?

I look forward to receiving your feedback.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF