facebooktwittermenuarrow-up

GemBox Support Forum

Convert Word document to PDF problem

I am using GemBox.Document to convert a Word document into a PDF. The Word document is two pages long. The problem is that in the PDF the second page is blank. I am on version 27.3.30.1261.

What is the problem here?

Hi,

I’m afraid we’ll need to investigate your document in order to find out why this problem occurs.
Can you please send it to us?

If not, please try using the current latest bugfix version (33.0.35.1290): BugFixes

You can use its Trial mode for evaluation, see: Free / Trial / Professional | GemBox.Document Example

Regards,
Mario

Hi Mario,

I am not able to send you the Word document, for privacy concerns. I did find something interesting though. The document in question is contained in a table, in other words the entire content of the document is in a table. There are two columns in the table and in the top row the two cells are merged into one. There are also places where two columns are merged into one. I experimented with another Word document without tables and it converted to a PDF without problems.

I did try with version 33.0.1290 (33.0.35.1290 is not available in Nuget) and the same problem occurred again.

Hi,

The only thing that currently comes to my mind is that perhaps you’re experiencing an issue with floating tables that span multiple pages. Unfortunately, GemBox.Document currently doesn’t support them.

In other words, can you check the “Text wrapping” option on your Table element:

floating-table

If it’s set to “Around”, try changing it to “None”.
Does this solve your issue?

Regards,
Mario

Hi Mario,

That was it! That solved the problem. Thank you!

Is there way to change the “Text wrapping” to “None” in code with GemBox?

Hi,

Yes, try this:

foreach (Table table in document.GetChildElements(true, ElementType.Table))
    table.TableFormat.Positioning.ClearPositioning();

Regards,
Mario

1 Like

That seems to work. Interestingly enough however, when I open the temporary Word document modified by the code above, its Text Wrapping is still set to “Around”, even though the resulting PDF is not missing any pages.

Without investigating your input file I’m afraid it’s not possible for me to say what you’re observing and why.