PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Nov 22, 2017 7:17 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Apr 12, 2017 10:10 am 
Offline

Joined: Mon Sep 05, 2016 7:54 am
Posts: 22
Hi there,

In my project using PDFSharp 1.50 Beta 3 I am using the
Code:
XGraphics DrawString()
method to draw strings onto the PDFs that I am creating, however I noticed that this method does not play nicely with new lines (\n). After some googling I found out that using the XTextFormatter DrawString() method would correctly parse the newline characters, which is great.

I did notice that the
Quote:
XTextFormatter DrawString()
method only supports TopLeft Formatting at this moment in time, is there any workaround for getting Right or Center alignment with newlines?

Thanks, RBrNx


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 12, 2017 7:28 pm 
Offline
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 305
Location: CCAA
Hi!

Did you try the Alignment property of XtextFormatter?
See also:
http://pdfsharp.net/wiki/TextLayout-sample.ashx

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 13, 2017 8:25 am 
Offline

Joined: Mon Sep 05, 2016 7:54 am
Posts: 22
TH-Soft wrote:
Hi!

Did you try the Alignment property of XtextFormatter?
See also:
http://pdfsharp.net/wiki/TextLayout-sample.ashx


Hi there, yes that was the first thing I tried, unfortunately when you use anything other than

Code:
XStringFormats.TopLeft


It throws the exception
Code:
Only TopLeft alignment is currently implemented.


I was wondering if anyone had implemented the other alignments or knew of an easy way to do it?


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 13, 2017 9:43 am 
Offline

Joined: Mon Sep 05, 2016 7:54 am
Posts: 22
TH-Soft wrote:
Hi!

Did you try the Alignment property of XtextFormatter?
See also:
http://pdfsharp.net/wiki/TextLayout-sample.ashx


Apologies I misread your post! Keeping the XStringFormats value as TopLeft, I was also able to set the XTextFormatter.Alignment to Left/Right/Center and this worked fantastic!

Thanks for your help

RBrNx


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

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 13 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:  
Powered by phpBB® Forum Software © phpBB Group