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.