PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Mon Nov 03, 2025 8:59 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Jan 30, 2014 4:36 pm 
Offline

Joined: Wed Jan 29, 2014 3:50 pm
Posts: 6
Hi,

It seems that I'm having the opposite problem to the one mentioned at viewtopic.php?uid=6957&f=2&t=584.
I'm trying to create a PDF where there is a raster image underneath the vector graphics, but the fonts from the original PDF are not copied to the output document. I've tried both approaches - see the simplified snippets:
Code:
XPdfForm form = XPdfForm.FromFile(filename);
PdfDocument outputDocument = new PdfDocument();

PdfPage page = outputDocument.AddPage();

XGraphics gfx = XGraphics.FromPdfPage(page);
XImage image = XImage.FromFile(gifSamplePath);

gfx.DrawImage(image, x, y);
gfx.DrawImage(form, box);

outputDocument.Save(filename);

as well as
Code:
PdfDocument inputDocument = PdfReader.Open(filename, PdfDocumentOpenMode.Import);
PdfDocument outputDocument = new PdfDocument();

PdfPage page = inputDocument.Pages[0];

outputDocument.AddPage(page);

outputDocument.Save(filename);


How can I make sure the fonts are copied to the output document?

Thanks in advance,
Mirek


Attachments:
File comment: Example source .cs.
Program.zip [1.13 KiB]
Downloaded 560 times
File comment: Input & Output PDFs.
Files.zip [67.46 KiB]
Downloaded 578 times
Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 04, 2014 1:13 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3136
Location: Cologne, Germany
Hi!

The fonts are copied, but they do not work.

In class PdfWriter I changed method Write for PdfReal like this:
Code:
public void Write(PdfReal value)
{
  WriteSeparator(CharCat.Character);
  WriteRaw(value.Value.ToString("0.#######", CultureInfo.InvariantCulture));
  this.lastCat = CharCat.Character;
}


With this little change, the fonts worked.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 06, 2014 8:46 am 
Offline

Joined: Wed Jan 29, 2014 3:50 pm
Posts: 6
Hi,
Thank you for your explanation and the fix. I've implemented it and it works now,
Mirek


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

All times are UTC


Who is online

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