PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 16, 2024 4:53 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Tue Jan 12, 2010 5:23 pm 
Offline

Joined: Mon Feb 16, 2009 5:33 pm
Posts: 3
Hi,

Is there a way to configure paragraph alignment justification in 'MigraDoc'? Current when I set a paragraph to justification, it'll justify even 3-4 words across the full span which leaves quite a huge whitespace. My paragraph contents are dynamically changing, and it's not possible for me to use justification as is. For ex: In word justification will not span full length if there is only a few words and the span is too long. How can I mimic this in Migradoc?

Thanks for the help and great product!


Attachments:
migradoc_justify.png
migradoc_justify.png [ 6.35 KiB | Viewed 9021 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 13, 2010 10:04 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
yigosan wrote:
For ex: In word justification will not span full length if there is only a few words and the span is too long. How can I mimic this in Migradoc?

AFAIK word does exactly the same, when linebreaks are used inside a paragraph.
Word doesn't justify the last line of a paragraph - neither does MigraDoc.

Edit: tested it with Word 2003 - and that's what I got:


Attachments:
File comment: Screen shot from Word 2003
word2003.PNG
word2003.PNG [ 3.04 KiB | Viewed 9013 times ]

_________________
Regards
Thomas Hoevel
PDFsharp Team
Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 02, 2014 10:53 am 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
I have found a similar problem.

Code:
         p3hdr.AddFormattedText("You may be able to take advantage of one or more of the following", _greenHeading14)
 p3hdr.AddLineBreak()
 p3hdr.AddLineBreak()
 Dim rhiImg = p3hdr.AddImage(_path & "Images/OA/Rhi.png")
   rhiImg.ScaleHeight = 0.5 p3hdr.AddFormattedText("Domestic Renewable Heat Incentive (RHI)", _greyFont14)
 p3hdr.AddLineBreak()
 p3hdr.Format.Alignment = ParagraphAlignment.Justify
 p3hdr.AddText("Your assessor has recommended improvement measure(s) which could be eligible for financial support under " & _
            "the domestic RHI scheme. The support is paid at set rates per unit of eligible heat produced (in kilowatt hours) for seven years, " & _
            "to the owner of the equipment. Based on the type of system(s) that has been recommended, we estimate that you could receive around " & _
            "£00,000 per year in RHI revenues, totalling £00,000 over seven years. In some cases, metering of the eligible heat produced " & _
            "will be required. Where this applies, RHI revenues will be based on meter readings up to a capped amount.")


I would prefer that the top 2 lines do not span the whole column width.
Also, it ignores space after text.


Attachments:
File comment: Justified text.
Justify.png
Justify.png [ 13.84 KiB | Viewed 8572 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 02, 2014 11:17 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
bizzel74 wrote:
I would prefer that the top 2 lines do not span the whole column width.
If you'd use MigraDoc as intended, you would have three different paragraphs (not a single paragraph that looks like three paragraphs by means of AddFormattedText and AddLineBreak).
You can create styles for the headings and set SpaceBefore and SpaceAfter for the headings.

Word does the same when you put all the text into a single paragraph.

bizzel74 wrote:
Also, it ignores space after text.
I'm afraid I don't understand this.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 03, 2014 9:50 am 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
I agree that would be the best way to handle titles but my screenshot was not clear enough. It happens with large blocks of text too. I will do as you suggest and break each section into separate paragraphs without line breaks.

Attachment:
Justify2.png
Justify2.png [ 24.76 KiB | Viewed 8568 times ]


Here is also an example of spaces being ignored after '2kW':
Code:
    p4hdr.Format.Alignment = ParagraphAlignment.Justify
        p4hdr.AddLineBreak()

        p4hdr.AddFormattedText("You may be able to take advantage of one or more of the following", _greenHeading14)
        p4hdr.AddLineBreak()
        p4hdr.AddLineBreak()


        Dim fitImg = p4hdr.AddImage(_path & "Images/OA/Fit.png")
        fitImg.ScaleHeight = 0.5

        p4hdr.AddFormattedText(" Feed-in Tariff (FIT)", _greyFont14)
        p4hdr.AddLineBreak()
        p4hdr.AddText("FITs are available for the following renewable micro-generation (up to 50kW) technologies " & _
            "solar photovoltaics (PV), wind, hydro and anaerobic digestion (AD); " & _
            "and micro combined heat and power (micro-CHP) up to 2kW.                                    ") ' <- Space ignored
        p4hdr.AddLineBreak()
        p4hdr.AddLineBreak()


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 03, 2014 9:57 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
bizzel74 wrote:
I agree that would be the best way to handle titles but my screenshot was not clear enough. It happens with large blocks of text too.
The last line of a paragraph will not be justified. The problem is that you use a single paragraph (with empty lines) to make it look like several paragraphs.
Simply take several paragraphs (and use them as intended) and the last line of each paragraph will not be justified.

MigraDoc treats multiple blanks like a single blank. This is a feature, not a bug. You can use non-breaking spaces to get larger spaces (but you're trying multiple blanks as a workaround that won't be needed when you get rid of those AddLineBreak() calls and use several AddParagraph() calls instead).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 03, 2014 1:08 pm 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
Adding paragraphs each time is working thanks :D
For example:
Code:
  Dim pg3HeadingRow = p3Text.AddRow
        pg3HeadingRow.Cells(0).AddParagraph()
        Dim p3hdr = pg3HeadingRow.Cells(0).AddParagraph()
        p3hdr.AddFormattedText("You may be able to take advantage of one or more of the following", _greenHeading14)

        pg3HeadingRow.Cells(0).AddParagraph()

        Dim domRenewableHdr = pg3HeadingRow.Cells(0).AddParagraph()
        Dim rhiImg = domRenewableHdr.AddImage(_path & "Images/OA/Rhi.png")
        rhiImg.ScaleHeight = 0.5
        domRenewableHdr.AddFormattedText(" Domestic Renewable Heat Incentive (RHI)", _greyFont14)
        pg3HeadingRow.Cells(0).AddParagraph()
        Dim domRenewText = pg3HeadingRow.Cells(0).AddParagraph()
        domRenewText.AddText("Your assessor has recommended improvement measure(s) ...
...
  domRenewText.Format.Alignment = ParagraphAlignment.Justify
        pg3HeadingRow.Cells(0).AddParagraph()


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 164 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:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group