PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
Euro sign problem in merged pdf from reporting services https://forum.pdfsharp.net/viewtopic.php?f=2&t=2158 |
Page 1 of 1 |
Author: | elbrod [ Wed Oct 03, 2012 4:40 pm ] |
Post subject: | Euro sign problem in merged pdf from reporting services |
Hello, I want to merge some pdfs generated with reporting services into a only one pdf with PDFsharp. I use the following code to do it (simplified version): Code: PdfDocument pdfDoc = new PdfDocument(); string strDeviceInfo = "<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>"; string strMimeType = ""; string strEncoding = ""; string strFileNameExtension = ""; string[] streams; Warning[] warnings; // First local report generated with MS Reporting LocalReport report1 = new LocalReport(); report1.DataSources.Add(new ReportDataSource("MyDS", myDataSource1)); report1.ReportEmbeddedResource = "myreport.rdlc"; byte[] pdfContent1 = report1.Render("PDF", strDeviceInfo, strMimeType, strEncoding, strFileNameExtension, streams, warnings); MemoryStream ms1 = new MemoryStream(pdfContent1); PdfDocument tmpPdfDoc1 = PdfReader.Open(ms1, PdfDocumentOpenMode.Import); for (int ind = 0; ind < tmpPdfDoc1.PageCount; ind++) { pdfDoc.AddPage(tmpPdfDoc1.Pages(ind)); } // Second local report generated with MS Reporting LocalReport report2 = new LocalReport(); report2.DataSources.Add(new ReportDataSource("MyDS", myDataSource2)); report2.ReportEmbeddedResource = "myreport.rdlc"; byte[] pdfContent2 = report2.Render("PDF", strDeviceInfo, strMimeType, strEncoding, strFileNameExtension, streams, warnings); MemoryStream ms2 = new MemoryStream(pdfContent2); PdfDocument tmpPdfDoc2 = PdfReader.Open(ms2, PdfDocumentOpenMode.Import); for (int ind = 0; ind < tmpPdfDoc2.PageCount; ind++) { pdfDoc.AddPage(tmpPdfDoc2.Pages(ind)); } // Save the merged pdf strFile = System.IO.Path.GetTempFileName.Replace(".tmp", ".pdf"); pdfDoc.Save(strFile); // Open the merged pdf System.Diagnostics.Process proceso = new System.Diagnostics.Process(); proceso.StartInfo.FileName = strFile; proceso.Start(); All process works fine, the problem is that the file myreport.rdlc contains a textbox with a static text with the euro sign and in the merged pdf, that euro sign appears as question mark. The textbox has the Arial font assigned. If I save the pdfContent1 of first pdf directly to disk with a FileStream (without PDFSharp) the euro sign are showed ok. I don't know where is the problem (in my source Reporting report, or in the conversion of PDFSharp). Any help will be appreciated. |
Author: | Thomas Hoevel [ Thu Oct 04, 2012 9:54 am ] |
Post subject: | Re: Euro sign problem in merged pdf from reporting services |
Hi! Maybe an encoding problem. strEncoding appears to remain empty? Please try saving the byte[] to a file and use PDFsharp to read from the file. If the Euro sign is correct when the file is viewed in Adobe Reader but still incorrect when read with PDFsharp, please provide us that file for further investigation. It sounds as if you tried that already (or did you use a different method to save the PDF file?). ISO-8859-1 is a superset of the ANSI codepage (1252 IIRC), but only the former includes the Euro sign and MS conversion routines tend to replace non-existing characters with question marks. So conversion to ISO-8859-1 may work while conversion to ANSI may not work. If you didn't save your PDF file from a byte[] as shown in your sample, then maybe different code (or a different encoding) was used. |
Author: | elbrod [ Fri Oct 05, 2012 8:49 am ] |
Post subject: | Re: Euro sign problem in merged pdf from reporting services |
Hi Thomas. Thanks for your answer. As you told me, I made the following test: 1.- Generate the byte[] array with Reporting LocalReport.Render() method. 2.- Save that byte[] array to a pdf file (named fileA.pdf). 3.- Import the fileA.pdf into a pdfSharp temp document with PdfReader.Open() method. 4.- Add all pages from temp pdfsharp document into a new pdfSharp document. 5.- Save the new pdfSharp document in another file (fileB.pdf). You were right, both file fileA.pdf and fileB.pdf show the question mark instead of the euro symbol. It seem to be an issue with the encoding and invoking the Render method of Reporting's LocalReport with the DeviceInfo "<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>". Although it is clear that the problem is not in pdfSharp, how could fix it? (I have no idea how could fix it) strEncoding is empty (null) after calling the Render method. Perhaps playing with the Reporting source rdlc file encoding ? Thanks again. |
Author: | elbrod [ Fri Oct 05, 2012 9:57 am ] |
Post subject: | Re: Euro sign problem in merged pdf from reporting services |
Googling, it seem a known problem: http://social.msdn.microsoft.com/Forums ... 6c6f711417 Exists a hotfix for Reporting Services, but not for LocalReports. Quote: I think I will move the euro sign as a report parameter. Perhaps it might work. Not work to move euro sign as parameter ![]() ![]() ![]() |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |