PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
MigraDoc and spaces http://forum.pdfsharp.com/viewtopic.php?f=2&t=561 |
Page 1 of 1 |
Author: | muntablues [ Wed Dec 03, 2008 4:24 pm ] |
Post subject: | MigraDoc and spaces |
Hi I add my text using paragraph.AddFormattedText(_text, "Normal"); My problem is that my input rtf is formated with spaces, but this spaces are deleted by MigraDoc. Is there a flag which I can set to "switch off" this behavior. I could convert my input text to a chararray and look for spaces inside but I think that would be a overkill. Thanks MB |
Author: | Thomas Hoevel [ Thu Dec 04, 2008 8:41 am ] |
Post subject: | |
Hi! MigraDoc treats spaces much like HTML - and therefore you can use the same trick: if spaces must be kept use non-breakable spaces (NBSP, keyboard: Alt+<255>). Replace ordinary spaces (Alt+<32>) with NBSP before adding text. |
Author: | muntablues [ Thu Dec 04, 2008 9:17 am ] |
Post subject: | |
Hi Thomas Thank you very much, its works great! I love PDFSharp! MB |
Author: | mikesowerbutts [ Thu Mar 18, 2010 2:16 pm ] |
Post subject: | Re: MigraDoc and spaces |
Hi i am trying to replace "1 2" with "1 1" but the text is showing as "1 1" in the PDF and not using the non breakable spaces? Mike |
Author: | Thomas Hoevel [ Thu Mar 18, 2010 2:33 pm ] |
Post subject: | Re: MigraDoc and spaces |
mikesowerbutts wrote: i am trying to replace "1 2" with "1 1" but the text is showing as "1 1" in the PDF and not using the non breakable spaces? MigraDoc is not HTML, try the character: Thomas Hoevel wrote: NBSP, keyboard: Alt+<255>
|
Author: | mikesowerbutts [ Thu Mar 18, 2010 3:07 pm ] |
Post subject: | Re: MigraDoc and spaces |
sorry i feel really stupid, but i am literally typing "NBSP" and i get this: "Yes < X >NBSP NBSP NBSP No <NBSP NBSP NBSP>in the pdf ? |
Author: | Thomas Hoevel [ Thu Mar 18, 2010 4:59 pm ] |
Post subject: | Re: MigraDoc and spaces |
Alt+<255> means: hold down Alt while you type 255 on the numeric keypad and you'll get the blank you need. |
Author: | PhilipMWare [ Fri Jun 04, 2010 10:13 pm ] |
Post subject: | Re: MigraDoc and spaces |
Howdy, I hate to resurrect and old thread, but I'd rather do that than start a new that's really an extension of this one. The advice about Alt-255 has gotten me further along -- thank you! -- but I am still losing white space in lines that, normally, are created as such: Code: longInfo = string.Format("{0,-25}{1,-15}{2,-8}{3,-8}{4,-7}{5,-5}{6,-5}{7,-10}{8,-5}{9,-7}{10,-7}{11,-20}{12,-25}{13,-8}{14,-100}{15}", sInfo[0],sInfo[1],sInfo[2],sInfo[3],sInfo[4],sInfo[5],sInfo[6],sInfo[7], sInfo[8],sInfo[9],sInfo[10],sInfo[11],sInfo[12],sInfo[13],sInfo[14],"\r\n"); Now, this is fine for the RTF documents that are produced, but the MigraDoc PDF output, of course, strips out the trailing spaces. I have tried: Code: longPDFInfo = sInfo[0].PadRight(25,' ') + sInfo[1].PadRight(15,' ') + sInfo[2].PadRight(8,' ') + sInfo[3].PadRight(8,' ') + sInfo[4].PadRight(7,' ') + sInfo[5].PadRight(5,' ') + sInfo[6].PadRight(5,' ') + sInfo[7].PadRight(10,' ') + sInfo[8].PadRight(5,' ') + sInfo[9].PadRight(7,' ') + sInfo[10].PadRight(7,' ') + sInfo[11].PadRight(20,' ') + sInfo[12].PadRight(25,' ') + sInfo[13].PadRight(8,' ') + sInfo[14].PadRight(100,' ') + "\r\n"; Now this, to me, seems a touch cumbersome and there is probably a better way, however, for now, the issue is that the space that is in the .PadRight(xx,' ') is indeed an Alt-255 and I'm still getting text in the produced PDF with no trailing white spaces. My question revolves around whether I need to make a specific call to the PdfDocumentRenderer. I have tried both Code: PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always); and with unicode set to false, and neither has output what I need. So, with my logic, it's either how I'm feeding it or what I'm telling it when it saves it out to the PDF. I am using monospaced fonts (either Quick Mono or Raavi) and both seem to support the Alt-255 spacing when I tested. So, I'm kind of at a loss. Any help would be greatly appreciated. Phil |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |