PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Paragraph indent in Table (document preview)
http://forum.pdfsharp.de/viewtopic.php?f=2&t=3263
Page 1 of 1

Author:  Coach [ Wed Jan 06, 2016 11:49 am ]
Post subject:  Paragraph indent in Table (document preview)

Hi,

I am using MigraDoc version 1.32, and when I put my document in DocumentViewer, to get a print preview, all paragraphs in table cells are auto indented for some value. I just want it to be close to left border of the cell, I don't want that "gap". Any help?

Author:  () => true [ Wed Jan 06, 2016 3:44 pm ]
Post subject:  Re: Paragraph indent in Table (document preview)

Hi!

Please show what you want, what you get, and your code.

viewtopic.php?f=2&t=832

Author:  Coach [ Thu Jan 07, 2016 3:21 pm ]
Post subject:  Re: Paragraph indent in Table (document preview)

Thanks for replay!

I am using DocumentViewer project form solution MigraDoc Samples-WPF-VS2010.

I created my sample (SampleDocuments.CreateMySample()) and put it instead of default sample (SampleDocuments.CreateSample1()).

MainWindow.xaml.cs
Code:
public MainWindow()
    {
      InitializeComponent();

      // Create a new MigraDoc document
      //Document document = SampleDocuments.CreateSample1();

      //my document sample
      Document document = SampleDocuments.CreateMySample();

      // HACK
      string ddl = DdlWriter.WriteToString(document);
      preview.Ddl = ddl;
    }


SampleDocuments.cs
Code:
internal static Document CreateMySample()
    {
        // Create a new MigraDoc document
        Document document = new Document();

        // Add a section to the document
        Section section = document.AddSection();

        // Add a paragraph to the section
        Paragraph paragraph = section.AddParagraph();

        // Add some text to the paragraph
        paragraph.AddFormattedText("Hi!");

        Table table = section.AddTable();
        table.Borders.Width = 0.5;
        table.Rows.LeftIndent = 0;

        table.AddColumn(70);
        table.AddColumn(70);

        Row row = table.AddRow();

        Cell cellLeft = row[0];
        cellLeft.AddParagraph("Left cell.");

        Cell cellRight = row[1];
        cellRight.AddParagraph("Right cell.");

        return document;
    }


The output for this code is:
http://img4.imagetitan.com/img.php?imag ... gradoc.png

And what I want is:
http://img4.imagetitan.com/img.php?imag ... radoc2.png

Thanks!

Author:  TH-Soft [ Thu Jan 07, 2016 6:14 pm ]
Post subject:  Re: Paragraph indent in Table (document preview)

I didn't try the Preview, but in PDF it looks as expected:
Attachment:
$$$table.png
$$$table.png [ 2.89 KiB | Viewed 7590 times ]


And the Preview should look like the PDF.

Do you also have this unwanted gap in the PDF?

Author:  Coach [ Fri Jan 08, 2016 12:04 pm ]
Post subject:  Re: Paragraph indent in Table (document preview)

Yes, I put my table in HelloWorld project in solution MigraDoc Samples-WPF-VS2010 and result is same.

Program.cs - [HelloWorld]
Code:
static Document CreateDocument()
    {
      // Create a new MigraDoc document
      Document document = new Document();

      // Add a section to the document
      Section section = document.AddSection();

      // Add a paragraph to the section
      Paragraph paragraph = section.AddParagraph();

      paragraph.Format.Font.Color = Color.FromCmyk(100, 30, 20, 50);

      // Add some text to the paragraph
      //paragraph.AddFormattedText("Hello, World!  öäüÖÄÜß~§≤≥≈≠", TextFormat.Italic);
      paragraph.AddFormattedText("Hello, World!", TextFormat.Bold);


      Table table = section.AddTable();
      table.Borders.Width = 0.5;
      table.Rows.LeftIndent = 0;

      table.AddColumn(70);
      table.AddColumn(70);

      Row row = table.AddRow();

      Cell cellLeft = row[0];
      cellLeft.AddParagraph("Left cell.");

      Cell cellRight = row[1];
      cellRight.AddParagraph("Right cell.");

      return document;
    }


Attachments:
helloWorld.png
helloWorld.png [ 4.43 KiB | Viewed 7583 times ]

Author:  Coach [ Mon Jan 11, 2016 7:53 am ]
Post subject:  Re: Paragraph indent in Table (document preview)

The solution was implicitly to set table left padding to 0.

Thank you all!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/