PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Jul 19, 2024 1:26 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Jul 18, 2012 1:41 pm 
Offline

Joined: Wed Jul 18, 2012 1:03 pm
Posts: 7
Hi all,

Im using PDFsharp and trying to create some output with some special fonts and somehow I cannot display all of them on a pdf.
If I want to display an other font in my Windows Form Application, I do this:

Code:
        private void Form1_Load(object sender, EventArgs e)
        {
            Label l = new Label();

            l.Text = "ÌtestwÎ";

            this.Font = new Font("Code 128", 80);

            l.Size = new System.Drawing.Size(300, 300);
           
            this.Controls.Add(l);
            this.Size = new Size(300, 300);
        }


As output I get a Window with my font (barcode), everything is fine
Attachment:
File comment: font in windows form
form.jpg
form.jpg [ 12.11 KiB | Viewed 12601 times ]



Now I would like to use the same font and the same string and write it in a pdf. That should work well. I try something like this:
Code:
            PdfDocument doc = new PdfDocument();
            PdfPage page = doc.AddPage();

            XGraphics gfx = XGraphics.FromPdfPage(page);

            gfx.DrawString("ÌtestwÎ", new XFont("Code 128", 80), XBrushes.Black, 50, 100);


If I open my pdf I get this
Attachment:
File comment: same font in pdf
pdf.jpg
pdf.jpg [ 18.4 KiB | Viewed 12601 times ]


I think everything is alright, there is just some trouble with the start and end characters Ì and Î But why?
How to avoid this issue? Any ideas? Thank you

PS: I downloaded the font from http://www.jtbarton.com/Barcodes/Code128.aspx But I think thats not that important.


Last edited by FrageWurm on Sun Jul 22, 2012 10:14 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 19, 2012 9:22 am 
Offline

Joined: Fri Apr 13, 2012 6:33 am
Posts: 10
As a work-around you could draw the barcode on a .Net bitmap or jpeg image and insert the image into the pdf.

Danny


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 22, 2012 9:58 pm 
Offline

Joined: Wed Jul 18, 2012 1:03 pm
Posts: 7
Hi, to create an image and then add this image to the pdf is one solution. But I liked pdfsharp because I could add my fonts "on the fly" without creating an image.

Somebody an idea why there is only a prob with the start and end character?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 30, 2012 9:27 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!
FrageWurm wrote:
Somebody an idea why there is only a prob with the start and end character?
I presume the font uses an unusual encoding. Could be a bug in PDFsharp.
I'll ask my boss when he's back from his holidays (fonts in PDF are not my area of expertise).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 06, 2012 7:39 pm 
Offline

Joined: Wed Jul 18, 2012 1:03 pm
Posts: 7
Thomas Hoevel wrote:
I'll ask my boss when he's back from his holidays (fonts in PDF are not my area of expertise).

Thx that would be nice, Im still interested.

Ì is ASCII Code 204 and Î 206 (could use Convert.ToChar(204) to get the char).
These are some unusual chars, but I have to use them.


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 07, 2012 1:56 pm 
Offline
Supporter

Joined: Fri May 15, 2009 3:28 pm
Posts: 96
could it not be embedding some of the characters in the font within the PDF? i know it only does a subset by default, maybe you can check in the Properties screen of the PDF which characters are part of the embedded subset of that font?


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 08, 2012 9:22 am 
Offline

Joined: Wed Jul 18, 2012 1:03 pm
Posts: 7
Hi. Im not sure what you mean with "Properties screen of the PDF", how/where should I check that?


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 08, 2012 9:45 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
The document properties dialog of Adobe Reader shows which fonts are embedded in the document. But AFAIK you cannot see which characters are included.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 08, 2012 12:27 pm 
Offline

Joined: Wed Jul 18, 2012 1:03 pm
Posts: 7
If I use another font (common font like arial) everything is fine:

Attachment:
File comment: pdf image
pdf.jpg
pdf.jpg [ 16.51 KiB | Viewed 12491 times ]


Thomas Hoevel wrote:
The document properties dialog of Adobe Reader shows which fonts are embedded in the document. But AFAIK you cannot see which characters are included.

I could upload the my pdf. Maybe there is a way to analyse it.
http://www.mediafire.com/?a9fkh70o7tc0ukl

Edit: Forgot to say, but this issue is with a lot unusual characters like Ã, Ä, Å... (Convert.ToChar(195+))


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 08, 2012 1:25 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
FrageWurm wrote:
Edit: Forgot to say, but this issue is with a lot unusual characters like Ã, Ä, Å... (Convert.ToChar(195+))
All these letters work fine if you use a font like Arial.
They don't work with the Code 128 font. So Code 128 is somewhat different. Could be a bug in the font, could be a bug in PDFsharp.

I'm afraid we don't have time to investigate this in the near future. I would try a workaround, drawing the bar code on an image and using that image in the PDF.
This may even result in smaller PDFs as you don't have to include the font in the PDF file.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 21, 2015 6:37 am 
Offline

Joined: Fri Dec 19, 2014 1:46 am
Posts: 8
If you only tested the code 128 font in PDF sharp, it cannot explain there's bug in PDFsharp.
Possible situation is that the code 128 font you downloaded is not compatible with PDFsharp.
Why not change other barcode fonts.


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 31 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group