groege / PdfSharpCore

PdfSharp port NetCore
47 stars 13 forks source link

When a single word doesn't fit in a paragraph there will be no Linebreak #3

Open groege opened 7 years ago

groege commented 7 years ago

Linebreak currently only works on Spaces, Hyphens and Soft-Hyphens. If there aren't any of those characters the word should still be fit into the width.

Wetzel402 commented 7 years ago

I ran into a similar issue with the original PdfSharp. I'm not sure if you are working with the same problem or not but word wrapping does not work with gfx.drawstring. Instead XTextFormatter needs to be used.

//need xtextformatter for word wrapping var tf = new XTextFormatter(gfx); rect = new XRect(25, 150, 570, 50); gfx.DrawRectangle(xpen, rect); format.LineAlignment = XLineAlignment.Near; tf.DrawString("Lengthy text that needs to wrap...", tinos, brush, rect, format);

groege commented 7 years ago

Thank you for the tipp :) I'll have to look into using XTextFormatter in MigraDoc rather than gfx.drawstring

Wetzel402 commented 7 years ago

I created a test project based on my original .Net 4.5 project using your PdfSharp port and have text wrapping working. You can have a look here.

https://github.com/Wetzel402/PdfSharpCore_TestApp