PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jul 15, 2024 4:58 pm

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: Thu Oct 06, 2011 7:04 pm 
Offline

Joined: Thu Oct 06, 2011 6:50 pm
Posts: 6
Hi,

I'm new to Migradoc and PDFSharp and I want to have a header containing multiple lines and styles. I coded this way:

Code:
  Document documento = new Document();
           documento.Info.Title = "Caratula del Contrato";

            Style style = documento.Styles["Normal"];
            style.Font.Name = "Verdana";

            Section section = documento.AddSection();
            section.PageSetup.TopMargin = Unit.FromCentimeter(3);

            //Header
            Paragraph header = section.Headers.Primary.AddParagraph();
            header.AddText(this.recaI);
            header.AddLineBreak();
            header.AddText("CreaBienestar");
            header.AddLineBreak();
            style = documento.Styles.AddStyle("Header1", "Normal");
            style.Font.Name = "Elegance";
            style.Font.Size = 9;
            header.AddFormattedText("CREA BIENESTAR, S.A. de C.V., SOFOM, E.N.R.", "Header1");
            header.AddLineBreak();
            header.AddText("Crédito y Bienestar para tu familia");
            header.Format.Alignment = ParagraphAlignment.Right;


My header must have 4 lines with different style each line, I'm adding linebreaks in my code to make this happen. However my problem is with the styles.
In My code I try to add a style to line 3 but my document is not rendered. If AddText method it is used in line 3 my document is rendered fine, but no styles are added. Do you know what I'm doing wrong?


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 06, 2011 7:09 pm 
Offline

Joined: Thu Oct 06, 2011 6:50 pm
Posts: 6
I think is a problem with supported fonts, so how do I know which fonts are supported?

regards


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 10, 2011 8:20 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!
alimnios72 wrote:
In My code I try to add a style to line 3 but my document is not rendered.
What does that mean? Do you get an error message or an exception? An empty document?

Styles normally are paragraph styles (one style per paragraph). I'd use one paragraph per line, so styles will be no problem. You try to use one paragraph with four lines and try to assign a different style to the third line. I'm not sure which limitations apply to that setup.

The code I'd try would look like this:
Code:
Paragraph header = section.Headers.Primary.AddParagraph("First line");
header = section.Headers.Primary.AddParagraph("Second line");
header = section.Headers.Primary.AddParagraph("Third line");
header.Style = "HeaderSpecialStyle";
header = section.Headers.Primary.AddParagraph("Fourth line");

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 12, 2011 10:33 pm 
Offline

Joined: Thu Oct 06, 2011 6:50 pm
Posts: 6
Thanks Thomas, I tried changing the font family and that worked out. I noticed that the issue here is that the font chosen is not supported. For some reason I wasn't getting any exception, but my document was not rendered. How do I know which fonts are supported?


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 13, 2011 7:19 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Look here (or see FAQ)):
http://www.pdfsharp.net/wiki/PostScript_fonts.ashx

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 17, 2011 10:22 pm 
Offline

Joined: Thu Oct 06, 2011 6:50 pm
Posts: 6
Thanks Thomas


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: No registered users and 46 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