将PDF添加到图像ReportViewer

时间:2017-02-06 14:46:52

标签: c# pdf reportviewer

我正在尝试使用条款和条件PDF打印RDL报告。问题在于报告本身是图像队列,而T& C是PDF格式。因此,每当我执行“入队”时,添加到流中,它就会像一个大图像一样查看PDF,而不是两个页面。这会导致GDI +泛型错误。反正我是否将PDF转换为正确的图像格式,以便我可以合并这些文件?这是我到目前为止的代码:

internal static void DoPrintInvoice(int orderID, SalesOrderBLL.DocumentType doctype, string printer, int copies, List<string> lines)
    {
        using (var context = rempscoDataContext.CreateReadOnlyContext())
        using (MiniProfiler.Current.Step("DoPrintInvoice()"))
        {
            //Customer Opt-Out

            // Generate Report
            using (var report = GetSalesOrderReport(orderID, _DocumentTypeDescriptions[doctype], doctype != DocumentType.InvoiceLetterhead, lines))
            {

                // returns queue of streams.
                var streams = PrintingBLL.RenderStreams(report, landscape: false);
                // returns byte array
                var TermsAndConditions = GetTermsAndConditions();

                //convert byte array to memory stream.
                var TCStream = new MemoryStream(TermsAndConditions);

                //conditional to add T&C's to stream.
                if (doctype == DocumentType.OrderAcknowledgement)
                {
                    streams.Enqueue(TCStream);   
                }

                ParallelInvoke(
                        () => SaveSalesOrderPDF(orderID, doctype, report),
                        () => PrintingBLL.PrintStreams(streams,  string.Format("Sales Order ({0})", report.DisplayName), printer, copies, false)
                        );
            }
        }
    }

我试图将条款和条件转换为图像,然后回到字节数组,但它给了我相同的GDI泛型问题。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

你看过PDFSharp了吗?我过去曾经很幸运地使用它来渲染PDF。

www.pdfsharp.com