PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Apr 24, 2024 11:28 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Apr 14, 2014 6:32 pm 
Offline

Joined: Tue Apr 01, 2014 7:33 pm
Posts: 19
i have this line of code in my mvc 4 pdfsharp project and i cant seem to figure out how to get the decsription field to display plain text when the pdf is generated. all my other lines display fine it is just this one I cant figure out:

graphics.DrawString("" + report.Description, font, XBrushes.Black, new XRect(margin, page.Height - (lineHeight * 35), page.Width, page.Height), XStringFormats.TopCenter);
currentTop += lineHeight;


this is what the pdf displays: Normal;font-weight: bold;font-size: 16px;color: #000000;">Incident API</span><span style="font-family: 'Verdana';font-style: Normal

this is what it should display: Incident API

does anyone know what I can add to this line of code to make it display properly. any advice or support would be greatly appeciated.

thank you so much


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 17, 2014 12:14 am 
Offline

Joined: Tue Apr 01, 2014 7:33 pm
Posts: 19
I really need help on this issue and cant seem to find anything online that works....please can someone offer me some advice and support????? i had the exact same issue in an application using razorpdf and @html.raw that worked fine but doesnt fit into the pdfsharp aplication....any help at all would be really appreciated.

thank you in advance


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 17, 2014 8:09 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
adandrea wrote:
does anyone know what I can add to this line of code to make it display properly.
You have to pass plain text to the PDF functions, neither HTML nor HTML snippets.

Remove the HTML tags before you pass the string to the DrawString method.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 17, 2014 9:19 pm 
Offline

Joined: Tue Apr 01, 2014 7:33 pm
Posts: 19
will this work if i still want to keep all the formatting for that string? for example, bold, italics and so on.....is this possible and do you have an example i could look at to point me in the right direction?

thanks so much


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 19, 2014 6:55 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 340
adandrea wrote:
will this work if i still want to keep all the formatting for that string? for example, bold, italics and so on.....
The parameters passed to DrawString specify how the output looks - font name, font size, bold and/or italics are passed in the font parameter.

See also:
http://pdfsharp.net/wiki/Graphics-sampl ... t_class_34

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 21, 2014 5:22 pm 
Offline

Joined: Tue Apr 01, 2014 7:33 pm
Posts: 19
does anyone have an example to help me get started on this. i have tried so many things but nothing seems to give me the result i need. please any advice or support would be greatly appreciated.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 22, 2014 7:49 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
adandrea wrote:
does anyone have an example to help me get started on this.
Look at this sample code:
http://pdfsharp.net/wiki/Graphics-sampl ... t_class_34

It's up to you to separate HTML tags from text, PDFsharp was not designed to deal with HTML.

Set a counter to 0. Increment the counter for every "<" char, decrement for every ">" char. When the counter is 0, copy characters to the output string. If counter > 0 then character is part of an HTML tag.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 24, 2014 10:14 pm 
Offline

Joined: Tue Apr 01, 2014 7:33 pm
Posts: 19
is there any other solution for this? i cant seem to figure it out. if there is a better example someone can provide or a little more detail that would really help alot, thank you.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 261 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