Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MigraDoc: How do I add preceding spaces to a String?

I have a table of text data and I'd like to indent certain pieces of data by a couple spaces, but everything I try seems to result in my string being automatically trimmed, and the preceding spaces are deleted. The PDF as it is right now looks something like this:

http://i.imgur.com/KBK6jWS.png

So for example, I'd like to indent 'LiabilityOne' and 'LiabilityTwo' a bit. I've tried adding spaces in the String as it's rendered. Adding spaces before it's rendered, using '\x020' in hopes that'd stick and using PadLeft(String.Length + 2, ' '), all with no luck.

Certainly there is a way I can just add some preceding spaces to these strings. How can I do it?

Edit:

Context -- This is the method that generates the content for the second half of the table on the right. Everything else is very similar.

private void DrawStaticLiabilities()
{
    _PdfVerticalOffset = 85 + (_PdfRowsFSRight * _PdfRowHeight);

    Document tDoc = new Document();
    MigraDoc.DocumentObjectModel.Style style = tDoc.Styles["Normal"];
    style.Font.Name = tPdfFont;
    style.Font.Size = 10;
    Section tSec = tDoc.AddSection();
    MigraDoc.DocumentObjectModel.Tables.Table table2 = new MigraDoc.DocumentObjectModel.Tables.Table();
    table2 = tSec.AddTable();
    table2.Borders.Width = 0.2;
    table2.Rows.LeftIndent = 0;

    Column columnData2 = table2.AddColumn("295pt");
    Column columnValue2 = table2.AddColumn("70pt");
    columnValue2.Borders.Right.Visible = false;

    Row rowAb = table2.AddRow();
    rowAb.Borders.Top.Visible = true;
    rowAb.Borders.Bottom.Visible = false;
    rowAb.Cells[0].AddParagraph(MP.FormFinancialStatement.StaticLiabilites.TopLine);
    rowAb.Cells[1].AddParagraph("");

    Row row1b = table2.AddRow();
    row1b.Borders.Bottom.Visible = false;
    row1b.Cells[0].AddParagraph("  Intermediate Liabilities  (" + MP.FormFinancialStatement.StaticLiabilites.IntLiabilitiesText + ")");
    row1b.Cells[1].Format.Alignment = ParagraphAlignment.Right;
    row1b.Cells[1].AddParagraph(MP.FormFinancialStatement.StaticLiabilites.IntLiabilitiesValue);

    Row row2b = table2.AddRow();
    row2b.Borders.Bottom.Visible = false;
    row2b.Cells[0].AddParagraph("  Long Term Liabilities (" + MP.FormFinancialStatement.StaticLiabilites.LongLiabilitiesText + ")");
    row2b.Cells[1].Format.Alignment = ParagraphAlignment.Right;
    row2b.Cells[1].AddParagraph(MP.FormFinancialStatement.StaticLiabilites.LongLiabilitiesValue);

    Row row3b = table2.AddRow();
    row3b.Borders.Bottom.Visible = false;
    row3b.Cells[0].AddParagraph("  Accrued Interest On: (" + MP.FormFinancialStatement.StaticLiabilites.AccruedInterestText + ")");
    row3b.Cells[1].AddParagraph("");

    Row row4b = table2.AddRow();
    row4b.Borders.Bottom.Visible = false;
    row4b.Cells[0].AddParagraph("  Accounts and Notes Payable(" + MP.FormFinancialStatement.StaticLiabilites.AccountsPayableText + ")");
    row4b.Cells[1].Format.Alignment = ParagraphAlignment.Right;
    row4b.Cells[1].AddParagraph(MP.FormFinancialStatement.StaticLiabilites.AccountsPayableValue);

    Row row5b = table2.AddRow();
    row5b.Borders.Bottom.Visible = false;
    row5b.Cells[0].AddParagraph("  Intermediate Liabilities (" + MP.FormFinancialStatement.StaticLiabilites.OtherIntLiabilitiesText + ")");
    row5b.Cells[1].Format.Alignment = ParagraphAlignment.Right;
    row5b.Cells[1].AddParagraph(MP.FormFinancialStatement.StaticLiabilites.OtherIntLiabilitiesValue);

    Row row6b = table2.AddRow();
    row6b.Borders.Bottom.Visible = false;
    row6b.Cells[0].AddParagraph("  Long Term Liabilities (" + MP.FormFinancialStatement.StaticLiabilites.OtherLongLiabilitiesText + ")");
    row6b.Cells[1].Format.Alignment = ParagraphAlignment.Right;
         row6b.Cells[1].AddParagraph(MP.FormFinancialStatement.StaticLiabilites.OtherLongLiabilitiesValue);

    MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(tDoc);
    docRenderer.PrepareDocument();
    docRenderer.RenderObject(gfx, 405, _PdfVerticalOffset, "365pt", table2);

    _PdfRowsFSRight += 8;
}
like image 306
mkautzm Avatar asked Feb 15 '23 00:02

mkautzm


1 Answers

To get more than one adjacent spaces with MigraDoc, simply use non-breaking spaces (press Alt+<255>).

See also:
http://forum.pdfsharp.net/viewtopic.php?p=1304#p1304

like image 120
I liked the old Stack Overflow Avatar answered Feb 18 '23 10:02

I liked the old Stack Overflow