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.

Wed Sep 19, 2012 6:38 am

Hello, i have a problem trying to create a Spire.Doc document, and saving it as PDF. The problem consist in an incorrect display of a table:

Code: Select all
If document.Sections.Count = 0 Then document.AddSection()
            Dim table As Table = document.Sections(0).AddTable(False)
            table.ResetCells(1, 2)
            Dim p As Paragraph = table.Rows(0).Cells(0).AddParagraph()
            p.AppendBookmarkStart("EmpfängerAdresse")
            Dim txtRange As TextRange = p.AppendText("EmpfängerAdresse")
            p.AppendBookmarkEnd("EmpfängerAdresse")
            txtRange.CharacterFormat.FontName = FontName.Arial.ToString
            txtRange.CharacterFormat.FontSize = 12
            p.Format.HorizontalAlignment = TextAlignmentToHorizAlignment(TextAlignment.Left)

            Dim secTable As Table = table.Rows(0).Cells(1).AddTable(False)
            secTable.ResetCells(3, 2)
            'secTable.Rows(0).IsHeader = True
            secTable.Rows(0).RowFormat.BackColor = Color.FromArgb(112, 112, 112)
            Dim p1 As Paragraph = secTable.Rows(0).Cells(0).AddParagraph
            p1.AppendBookmarkStart("Dokumentart")
            Dim txtRange1 As TextRange = p1.AppendText("Dokumentart")
            txtRange1.CharacterFormat.TextColor = Color.White
            p1.AppendBookmarkEnd("Dokumentart")
            Dim p2 As Paragraph = secTable.Rows(0).Cells(1).AddParagraph
            p2.AppendBookmarkStart("Dokumentnummer")
            Dim txtRange2 As TextRange = p2.AppendText("Dokumentnummer")
            txtRange2.CharacterFormat.TextColor = Color.White
            p2.AppendBookmarkEnd("Dokumentnummer")

            Dim p3 As Paragraph = secTable.Rows(1).Cells(0).AddParagraph
            Dim txtRange3 As TextRange = p3.AppendText("Datum")

            Dim p4 As Paragraph = secTable.Rows(1).Cells(1).AddParagraph
            p4.AppendBookmarkStart("DokumentDatum")
            Dim txtRange4 As TextRange = p4.AppendText("DokumentDatum")
            p4.AppendBookmarkEnd("DokumentDatum")

            Dim p5 As Paragraph = secTable.Rows(2).Cells(0).AddParagraph
            Dim txtRange5 As TextRange = p5.AppendText("Kundennummer")

            Dim p6 As Paragraph = secTable.Rows(2).Cells(1).AddParagraph
            p6.AppendBookmarkStart("Kundennummer")
            Dim txtRange6 As TextRange = p6.AppendText("Kundennummer")
            p6.AppendBookmarkEnd("Kundennummer")


If i save it as Word, it's fine, and converting it to PDF with other tool, it's also fine, but i want to do that with Spire.Doc.
Can you check if you meet the same error, and tell if there is any solution for this?
thank you.

catalin
 
Posts: 48
Joined: Wed Mar 14, 2012 12:56 pm

Wed Sep 19, 2012 9:19 am

Dear catalin,

Thanks for your inquiry.
We have reproduced your problem, and we have defined it as a bug. We are struggling to fix the bug, once it has been fixed, we will inform you immediately.

Best regards,
Amy
e-iceblue support
User avatar

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

Wed Sep 19, 2012 9:39 am

Hello.

I found that if you specify or set the table's cells width, this error doesn't occur. But i expected auto width to be considered.

One more question,

If i want a table, inside of another table cell, to be right aligned, inner that cell, i use
Code: Select all
table.TableFormat.HorizontalAlignment = RowAlignment.Right

But it seems it's working only if i export it as PDF, if i save the document as Word, the table will remain left aligned.
Could you check this also, please?

Thank you :)

catalin
 
Posts: 48
Joined: Wed Mar 14, 2012 12:56 pm

Thu Sep 20, 2012 5:32 am

Dear catalin,

Thanks for your inquiry.
About the problem saving the document as Word, and the table remains left aligned, we have done a test, but we don't reproduce your problem, we provide you the test demo, please check it. If you still have the problem or another problem, please feel free to contact us.

Best regards,
Amy
e-iceblue support
User avatar

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

Thu Sep 20, 2012 7:17 am

Hello,
Thank you very much for your demo.

It seems that the table must be aligned after the ResetCells function call. Otherwise (logically) there is nothing to be aligned :).

So instead of
Code: Select all
t.TableFormat.HorizontalAlignment = RowAlignment.Right
t.ResetCells(3, 2)

simply reverse:
Code: Select all
t.ResetCells(3, 2)
t.TableFormat.HorizontalAlignment = RowAlignment.Right

and worked. Problem solved! :D

catalin
 
Posts: 48
Joined: Wed Mar 14, 2012 12:56 pm

Mon Oct 01, 2012 3:20 am

Dear catalin,

We have released a hotfix to fix your problem, please download it from http://www.e-iceblue.com/downloads/hot_fix/spire.doc_hotfix_4.4.33.zip. With this hotfix, you could save your table of word document to PDF document.
Harry
Technical Support / Developer,
e-iceblue Support Team
User avatar

harry.support
 
Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm

Return to Spire.PDF

cron