PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Jun 04, 2024 5:53 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri May 17, 2013 12:16 pm 
Offline

Joined: Mon May 13, 2013 3:49 pm
Posts: 9
Hello,

I have a MigraDoc.Document with an image an some special characters (accents and copyright character)

If I do this:

Code:
 
Document document = crearPDF.CreateSaldoMovimientosPDF(dsPDF);
MemoryStream stream = new MemoryStream();
PdfDocumentRenderer renderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Default);
renderer.Document = document;

renderer.RenderDocument();
                   
renderer.PdfDocument.Save(stream, false);

string filename = Guid.NewGuid().ToString("N").ToUpper() + ".pdf";

return new FileStreamResult(stream, "application/pdf") { FileDownloadName = filename };


The file is looks like this:

Quote:
Ticket Corporate� (it may be copyright character)
Saldo: 24,91 � (it may be €)


But, if I save the document in a file, the file is correct without errors. Why?

Has anyone can tell me what I'm doing wrong?

Thanks in advance,
Maria


Top
 Profile  
Reply with quote  
PostPosted: Tue May 21, 2013 8:48 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3099
Location: Cologne, Germany
Looks like an encoding problem.
Since the file is correct (as you write), the problem occurs somewhere else.
Did you try several browsers (IE, FF, Chrome, Opera)?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu May 23, 2013 9:45 am 
Offline

Joined: Mon May 13, 2013 3:49 pm
Posts: 9
Thanks for the answer.

we solve doing this:

Code:
Document document = crearPDF.CreateSaldoMovimientosPDF(dsPDF);
MemoryStream stream = new MemoryStream();
PdfDocumentRenderer renderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Default);
renderer.Document = document;

renderer.RenderDocument();
                   
renderer.PdfDocument.Save(stream, false);

string filename = ResHelper.GetString("NWT_File_Name") + ".pdf";

stream.Seek(0, SeekOrigin.Begin);

Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
Response.Buffer = true;
Response.Clear();
Response.OutputStream.Write(stream.GetBuffer(), 0, stream.GetBuffer().Length);
Response.OutputStream.Flush();
Response.End();

return new FileStreamResult(Response.OutputStream, "application/pdf");



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: Google [Bot] and 132 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