PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 6:40 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: Mon Jul 27, 2009 8:12 pm 
Offline

Joined: Tue Jul 21, 2009 6:37 pm
Posts: 12
I have a table of contents style defined and it appears that the contents is being displayed as JUSTIFIED, there are some extra embeded spaces being added. How do I find what the "Normal" style is and how can I override it to be Left Justifed ?


// Create a new style called TOC2 based on style Normal
style = document.Styles.AddStyle("TOC2", "Normal");
style.Font.Name = "Arial";
style.Font.Size = 7;
style.ParagraphFormat.AddTabStop("2.5cm", TabAlignment.Left);
style.ParagraphFormat.AddTabStop("8.5cm", TabAlignment.Right);
style.ParagraphFormat.Font.Color = Colors.Black;

thanks


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 28, 2009 12:35 pm 
Offline

Joined: Tue Jul 21, 2009 6:37 pm
Posts: 12
in the following code snippet:

thisRowCtr = ctr + 1;
row = table.Rows[thisRowCtr];
cell = row.Cells[0];
paragraph = cell.AddParagraph();
paragraph.Style = "TOC2";
hyperlink = paragraph.AddHyperlink(trucksection.bom + " " + trucksection.description);
hyperlink.AddText(trucksection.bom + "\t" + trucksection.description + "\t");
hyperlink.AddPageRefField(trucksection.bom + " " + trucksection.description);
}

when I break in the code where a table cell is assigned a value I get the following string that has no embedded spaces which is what I expect:

? trucksection.bom
"21800-K01393"

? trucksection.description
"ENGINE SUPPORTS"


However, when the table is displayed in the pdf there is magically a space between the - and the K. This space occurs in every cell that has the same pattern of data ... where there is a series of numeric characters followed by a DASH followed by a series of characters. The pdf table ends up looking like this:

21800- K01393 ENGINE SUPPORTS 9


So I'm thinking that somehow the contents of the cell is being formatted to spread it across the cell (justify?). Where can I see what the justification default is and how can I set it explicitly.

I tried to use without success: paragraph.Format.Alignment = ParagraphAlignment.Left;

The style is defined like this:

// Create a new style called TOC2 based on style Normal
style = document.Styles.AddStyle("TOC2", "Normal");
style.Font.Name = "Arial";
style.Font.Size = 7;
style.ParagraphFormat.AddTabStop("2.5cm", TabAlignment.Left);
style.ParagraphFormat.AddTabStop("8.5cm", TabAlignment.Right);
style.ParagraphFormat.Font.Color = Colors.Black;

thanks for any assistance!


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 28, 2009 12:43 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Left alignment is default.

There should be no blank.
I'll check this ...

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 28, 2009 1:22 pm 
Offline

Joined: Tue Jul 21, 2009 6:37 pm
Posts: 12
thanks, there must be something that happens when a "-" is encountered.

I created a loop to write out a series of image locations and everywhere there is an embeded dash I get an extra space.


W:\Images\21800- 0034.GIF



//lets try a loop
// the pattern is: 21800-0001.gif thru 21800-0058.gif

string apic;
for (int a = 0; a < 59; a++)
{
apic = String.Format("{0:00}", a);

completeFilename = "W:\\Images\\21800-00" + apic + ".GIF";
document.LastSection.AddPageBreak();
document.LastSection.AddParagraph(completeFilename);
document.LastSection.AddImage(completeFilename);

}


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 28, 2009 2:40 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
I tried both GDI+ and WPF builds - and I don't see the extra space.

Maybe a font problem.
This can occur if the font used for measuring is not the font used for display.
There could be typo in the font name or the font is not supported by PDFsharp (e. g. Postscript outlines in OpenType fonts).

Words can be broken at hyphens and both parts are measured separately.
This could also explain your justification problem: words "look" big when measured, but are small when displayed causing large gaps between words and after hyphens.

Try Arial or another TrueType font that comes with Windows for a start.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 28, 2009 3:32 pm 
Offline

Joined: Tue Jul 21, 2009 6:37 pm
Posts: 12
I am using Arial. My VS2008 C# project must be set up wrong?? I have a small project that just tries reading a bunch of images and adds the path + file name and image to each page. Here the filename has the - in it and here some of the images do not dislay. Zip size for the project is 1458 KB with a bunch of images - can I send it somewhere?


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 29, 2009 3:41 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
I tested your code with the current (internal) version of PDFsharp and MigraDoc Foundation and everything works fine.

It seems there was a problem retrieving the font data - the font embedded in PDF was not the font used for measuring (this led to the spaces). This problem is specific to the WPF build!
All images can be read now.


PDF sharp 1.3 will be available next month (maybe even next week).

_________________
Regards
Thomas Hoevel
PDFsharp Team


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 327 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