PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

Fonts are not copied to output document
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2722
Page 1 of 1

Author:  miroslavmandl [ Thu Jan 30, 2014 4:36 pm ]
Post subject:  Fonts are not copied to output document

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 562 times
File comment: Input & Output PDFs.
Files.zip [67.46 KiB]
Downloaded 579 times

Author:  Thomas Hoevel [ Tue Feb 04, 2014 1:13 pm ]
Post subject:  Re: Fonts are not copied to output document

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.

Author:  miroslavmandl [ Thu Feb 06, 2014 8:46 am ]
Post subject:  Re: Fonts are not copied to output document

Hi,
Thank you for your explanation and the fix. I've implemented it and it works now,
Mirek

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/