2015-04-28 51 views
0

美好的一天,Crystal报告徽标图像并未全部显示在报告中

我有一个控制台应用程序,它有一个包含图像的水晶报告。我将使用exporttostream运行报告并将导出的报告存储在sqlserver 2012中的varbinary字段中。然后,我将选择这些报告的批处理,并使用itextsharp将它们连接成1个pdf文件。报告上的徽标显示在一些页面上并非全部。任何想法,为什么这可能会发生。运行此应用程序时,我也使用并行处理(Parallel.For)。 任何想法,为什么这可能会发生?或者在报告中嵌入此图像以便始终显示的最佳方式是什么? 我试着运行相同的代码,但只有1个并行进程(即将按顺序执行),并且所有图像都出现在pdf中。为什么并列处理不能正确渲染图像? 在此先感谢

******编辑****** 代码的PDF文件拼接

Document document = null; 

for (int i=1; i <= numbatches;i++) 
{ 

    String printer_file_prefix = dll.Print.getPrinterFilePrefix(connectionString, bill_type_id.ToString()); 
    batchnumberpadded = i.ToString(); 
    batchnumberpadded = batchnumberpadded.PadLeft(3, '0'); 

    printerfilename = printer_file_prefix + oneup_number + batch_id + batchnumberpadded;//eg D_G123456CUST001 

    BatchPrintFilePath = Globals.printer_filelocation_prefix + printerfilename + ".pdf"; 

    document = new Document(PageSize.A4); 
    PdfCopy copy = new PdfCopy(document, new FileStream(BatchPrintFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)); 
    document.Open(); 

    using (SqlConnection sconn = new SqlConnection(connectionString)) 
    { 

     using (SqlCommand cmd = new SqlCommand("spGetPrinterFiles", sconn)) 
     { 

      cmd.CommandType = CommandType.StoredProcedure; 
      cmd.Parameters.AddWithValue("@batch_num", i); 
      cmd.Parameters.AddWithValue("@maximumRows",Globals.print_batch); 
      cmd.Parameters.AddWithValue("@archive_process_instance_no", archive_process_instance_no); 
      cmd.Parameters.AddWithValue("@batch_id", @batch_id); 

      sconn.Open(); 
      using (SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.Default)) 
      { 

       while (dr.Read()) 
       { 
        copy.AddDocument(new PdfReader((byte[])dr.GetValue(0))); 
       } 

       dr.Close(); 
       sconn.Close(); 
      } 
      sconn.Close(); 
     } 
    } 

    if (copy != null) 
     copy.Close(); 
    if (document.IsOpen()) 
     document.Close(); 


}//end for 
+0

请澄清:你如何连接文件?有很多非常糟糕的例子使用'Document'和'PdfWriter'(这显然是错误的方式),而不是使用'PdfCopy'或'PdfSmartCopy'(这是正确的方式)。如果你不提供更多的数据,这个问题是无法回答的。 –

+0

对不起,我编辑了我的问题。我不知道什么可能导致问题,所以不知道代码的哪些部分将帮助 – CoDeGiRl

+0

从删除'copy.Close()'开始。如果你想保留那条线,在关闭'PdfCopy'实例之前关闭'Document' *。现在我们可以看到你的代码,但我们仍然不知道什么是错的。你在谈论的标志在哪里?由于iText之外的某些原因,它们可能不在任何地方。有没有办法可以提供[SSCCE](http://sscce.org)? –

回答

0

感谢所有的答复。该徽标以某种方式添加为OLE对象。我将该徽标添加为图片,并将jpg徽标文件放置在项目的图像文件夹中,并运行该过程,现在似乎可以工作。感谢您的协助