PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Missing font styles.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
JM



Joined: 12 Dec 2007
Posts: 3
Location: London, UK

PostPosted: Wed Dec 12, 2007 10:13 am    Post subject: Missing font styles. Reply with quote

Hi,
I am looking to use PDFSharp to produce PDF's from XPS documents, I can extract the text, fonts and font styles from an XPS document but when I try and write that information to the PDF I find that the styles are not being applied in some cases, in particular bold and italic. I notice in part of the PDFSharp code that there are some TODO's to implement bold and italic.
The general form of my code is :-
If lFontFamily.IsStyleAvailable(FontStyle.Italic) Then
pdffont = New Font(lFontFamily, dblFontSizeTemp, FontStyle.Italic, GraphicsUnit.World)
End if
Dim XPdfFont As XFont
XPdfFont = CType(pdffont, XFont)
gfx.DrawString(strCapturedString, XPdfFont, PDFBrush, obj.OriginX / (96.0 / 72.0), obj.OriginY / (96.0 / 72.0))

Am I missing something here in terms of applying styles and if not are there plans to implement the other font styles in the future.

Many thanks
JM.
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Wed Dec 12, 2007 2:44 pm    Post subject: Reply with quote

Most fonts include 4 files: Regular, Bold, Italic, BoldItalic.
With these fonts you can use all styles.

Some fonts only have 1 through 3 files - with these fonts you cannot use all styles with PDFsharp - at least not with version 1.00 and probably not with version 1.10 (currently under construction).
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
JM



Joined: 12 Dec 2007
Posts: 3
Location: London, UK

PostPosted: Wed Dec 12, 2007 4:01 pm    Post subject: Reply with quote

I am testing using the following code :-

Code:
lFont = New System.Drawing.Font("Verdana", 20, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.World)
Font = CType(lFont, XFont)
gfx.DrawString("Hello World", Font, XBrushes.Black, X, Y)


Although I have 4 seperate Verdana fonts for each style on my pc this piece of code does not work, i.e it does not draw in italics.
I also have 4 seperate fonts for Times New Roman on my PC and the code works in that case.
I have looped through all of the fonts installed on my PC and sent the ouput to a PDF via PDFSharp and only Arial, Courier New and Times New Roman produce all four styles despite many of the others have all four styles.
Am I doing something wrong here?

confused
JM
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Wed Dec 12, 2007 4:50 pm    Post subject: Reply with quote

Without lFont and CType it'll work.
Please try:
Code:
font = new XFont(...
instead.

At first glance I'd say this is a bug in PDFsharp ...
... but one with a simple work-around (or rather work-straight).
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
JM



Joined: 12 Dec 2007
Posts: 3
Location: London, UK

PostPosted: Thu Dec 13, 2007 10:21 am    Post subject: Reply with quote

Thanks for your response.

I've tried what you suggested as follows:-

Code:
If font_family.IsStyleAvailable(System.Drawing.FontStyle.Italic) Then
Font = New XFont(font_family.Name, 20, System.Drawing.FontStyle.Italic)
gfx.DrawString("Hello, World!", Font, XBrushes.Black, X, Y)
End If


This still does not work for me the output is produced but not in italics, it still only works for three fonts on my PC. In fact I've tried all available overloads to create the XFont and get the same result each time.
Any suggestions?

JM
Back to top
View user's profile Send private message
Vyacheslav Popov



Joined: 23 Nov 2007
Posts: 18

PostPosted: Mon Dec 17, 2007 12:10 pm    Post subject: Reply with quote

This is pending work. See:

PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer in line 520 and 525

Code:
      if (bold && !descriptor.IsBoldFace)
      {
        // TODO: emulate bold by thicker outline
      }

      if (italic && !descriptor.IsBoldFace)
      {
        // TODO: emulate italic by shearing transformation
      }
Back to top
View user's profile Send private message Visit poster's website
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Mon Dec 17, 2007 12:21 pm    Post subject: Reply with quote

Vyacheslav Popov wrote:
This is pending work.

This does not apply to the majority of fonts like Arial, Verdana, Tahoma, Segoe UI, ...
... because these fonts include files for regular, bold, italic, and bolditalic styles that can be used by PDFsharp.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
Vyacheslav Popov



Joined: 23 Nov 2007
Posts: 18

PostPosted: Mon Dec 17, 2007 12:44 pm    Post subject: Reply with quote

Yes, but you see my solution:
http://pdfsharp.s3.bizhat.com/viewtopic.php?p=597#597
and microsoft example
http://pdfsharp.s3.bizhat.com/viewtopic.php?p=597#597
Back to top
View user's profile Send private message Visit poster's website
Vyacheslav Popov



Joined: 23 Nov 2007
Posts: 18

PostPosted: Mon Dec 17, 2007 12:45 pm    Post subject: Reply with quote

Back to top
View user's profile Send private message Visit poster's website
Vyacheslav Popov



Joined: 23 Nov 2007
Posts: 18

PostPosted: Mon Dec 17, 2007 6:07 pm    Post subject: Reply with quote

Bug solved!!!

http://pdfsharp.s3.bizhat.com/viewtopic.php?p=602#602
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com