PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Apr 28, 2024 6:41 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Jan 06, 2016 11:49 am 
Offline

Joined: Wed Jan 06, 2016 11:33 am
Posts: 6
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?


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 06, 2016 3:44 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 340
Hi!

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

viewtopic.php?f=2&t=832

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 07, 2016 3:21 pm 
Offline

Joined: Wed Jan 06, 2016 11:33 am
Posts: 6
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!


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 07, 2016 6:14 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 916
Location: CCAA
I didn't try the Preview, but in PDF it looks as expected:
Attachment:
$$$table.png
$$$table.png [ 2.89 KiB | Viewed 7520 times ]


And the Preview should look like the PDF.

Do you also have this unwanted gap in the PDF?

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 08, 2016 12:04 pm 
Offline

Joined: Wed Jan 06, 2016 11:33 am
Posts: 6
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 7513 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 11, 2016 7:53 am 
Offline

Joined: Wed Jan 06, 2016 11:33 am
Posts: 6
The solution was implicitly to set table left padding to 0.

Thank you all!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 324 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group