【问题标题】:Crystal report logo image does not show all the time on the report水晶报表徽标图像不会一直显示在报表上
【发布时间】:2015-04-28 14:52:59
【问题描述】:

美好的一天,

我有一个控制台应用程序,它有一个带有图像的水晶报表。我将使用 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

【问题讨论】:

  • 请澄清:你是如何连接文件的?有很多非常糟糕的例子使用Document和PdfWriter(这显然是错误的方式)而不是使用PdfCopy或PdfSmartCopy(这是正确的方式)。如果您不提供更多数据,这个问题将无法回答。
  • 抱歉,我编辑了我的问题。我不知道可能导致问题的原因,所以不知道代码的哪些部分会有所帮助
  • 首先删除copy.Close()。如果要保留该行,请在关闭 PdfCopy 实例之前关闭 Document 。现在我们可以看到您的代码,但我们仍然不知道出了什么问题。你说的标志在哪里?由于 iText 之外的某些原因,它们可能不会出现在任何地方。有没有办法可以提供SSCCE?
  • 徽标在水晶报表中。由于公司政策,我认为我无法提供 SSCEE。对不起
  • 问题是不是一直没有加logo造成的? iText 没有任何理由删除特定内容。我认为徽标从不存在。

标签: .net crystal-reports itextsharp parallel.foreach


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多