C# 是什么原因导致 Crystal Reports 中出现“页眉加页脚对于页面来说太大”错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12098164/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 22:03:45  来源:igfitidea点击:

What causes the "Page Header plus Page Footer is too large for the page" error in Crystal Reports?

c#.netwindows

提问by anurag19

I have used the following code for a print button:

我已将以下代码用于打印按钮:

Data.str = null;
//Data.str = textBox24.Text.ToString();
string s = "select * from temp_bond";
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\Real.mdb";
cn.Open();

DataSet ds = new DataSet();

OleDbDataAdapter da = new OleDbDataAdapter(s, cn);
ds.Clear();
da.Fill(ds);
Bond rpt = new Bond();
rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "BOND_" + Data.str + ".pdf");
System.Diagnostics.Process.Start("BOND_" + Data.str + ".pdf");
//r.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "E:\rep.pdf");
//crystalReportViewer1.ReportSource = r;
OleDbCommand cm1 = new OleDbCommand("delete * from temp_bond", cn);
cm1.ExecuteNonQuery();
cn.Close();

and I'm getting an error in this code:

我在此代码中遇到错误:

rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "BOND_" + Data.str + ".pdf");

The error is:

错误是:

Page Header plus Page Footer is too large for the page. Error in File C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\temp_3f674868-8e5d-46ce-80eb-dce78bb2ba89 {17674136-B71E-4C6F-9E36-1CEB514B13BF}.rpt: Page header or footer longer than a page.

页眉加页脚对于页面来说太大了。文件 C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\temp_3f674868-8e5d-46ce-80eb-dce78bb2ba89 中的错误 {17674136-B71E-4C6F-9E36-1CEB514B13 页眉或footerrpt:长于页眉或页脚}。页。

What can cause this and how can I fix it?

什么会导致这种情况,我该如何解决?

回答by RLH

I have an application that has been published for years and uses Crystal Reports as an embedded document generation tool. The report that is included with my application has been working for years, and I was stumped for a while when I received a support call from a user who had received this exact error message.

我有一个已发布多年的应用程序,它使用 Crystal Reports 作为嵌入式文档生成工具。包含在我的应用程序中的报告已经工作多年,当我收到来自收到此确切错误消息的用户的支持电话时,我被难住了一段时间。

After a bit of head-scratching and research, I've found that the primary culprit is the default printer on the end-users computer. If the default printer is currently configured to print on paper of a different size that is smaller than the report you are generating, Crystal Reports will give you this error message.Also, you will receive this message if the printer is set to print in an orientation different than the orientation of your CR report.

经过一番摸索和研究,我发现罪魁祸首是最终用户计算机上的默认打印机。 如果默认打印机当前配置为在小于您生成的报告的不同尺寸的纸张上打印,Crystal Reports 将向您提供此错误消息。此外,如果打印机设置为以与 CR 报告方向不同的方向打印,您将收到此消息。

The really odd/poorly designed issue with this bug is that you will receive it, even if you declare to the runtime to simply create a PDF. I assume CR is using some of the default printer settings to initialize the runtime.

这个错误真正奇怪/设计不佳的问题是你会收到它,即使你向运行时声明只是创建一个 PDF。我假设 CR 正在使用一些默认的打印机设置来初始化运行时。

You have a few options to fix this. First, you can change the default printer to another device. You may have to do this if your default printer is of a different, non-typical form factor (e.g. a label printer.) Crystal Reports will not like the label printer if the labels are smaller than your document.

您有几个选项可以解决此问题。首先,您可以将默认打印机更改为其他设备。如果您的默认打印机具有不同的非典型外形(例如标签打印机),您可能必须这样做。如果标签小于您的文档,Crystal Reports 将不喜欢标签打印机。

Option two is, of course, to reconfigure your printer driver to specify a paper type that is large enough to fit your document. Also, as mentioned, be sure that the paper printing preference is also set to print in the correct orientation (landscape or portrait) as your Crystal Report document expects.

选项二当然是重新配置您的打印机驱动程序以指定一种足够大的纸张类型以适合您的文档。此外,如上所述,请确保纸张打印首选项也设置为按照 Crystal Report 文档预期的正确方向(横向或纵向)打印。

Last, you can change your default printer to another printer or remove the printer from your PC. This isn't the most favorable answer, but it may be a last-case necessary step to get the message to go away.

最后,您可以将默认打印机更改为另一台打印机或从 PC 中删除打印机。这不是最有利的答案,但它可能是让消息消失的最后一个必要步骤。

回答by Efrain Nunez

I had the same problem and I changed the default printer to Microsoft XPS Writer. This corrected my the display of the crystal reports.

我遇到了同样的问题,我将默认打印机更改为 Microsoft XPS Writer。这更正了我的水晶报告显示。

回答by Knave

I recently had a similar problem, but I couldn't resolve it by changing the default printer or by changing the settings of them.

我最近遇到了类似的问题,但我无法通过更改默认打印机或更改它们的设置来解决它。

I managed to solve the problem by setting the parameters of the report by code, manually.

我通过代码手动设置报告的参数设法解决了这个问题。

This is an example to show you.

这是一个向您展示的示例。

dim crep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
crep.PrintOptions.PaperOrientation = PaperOrientation.Portrait
crep.PrintOptions.PaperSize = PaperSize.PaperA4

Saludos a todos! =)

Saludos 一个待办事项!=)

回答by Denn

Try changing page size of crystal report by Right click on report DESIGN--> PAGE SETUP ... Try it with A4, Landscape and others as per need.

尝试通过右键单击报告设计--> 页面设置来更改水晶报告的页面大小...根据需要尝试使用 A4、横向和其他。

回答by Matt Roy

I had this problem too with a Zebra label printer configured by the network on a Windows Server as the print server. I didn't want to try to change settings on the client default printer, because I can't be sure which client will print. Instead, I fixed it in the driver settings (printer defaults) on the print server (Windows Server 2008). So on the print server:

我在 Windows 服务器上通过网络配置作为打印服务器的 Zebra 标签打印机也遇到了这个问题。我不想尝试更改客户端默认打印机的设置,因为我无法确定哪个客户端会打印。相反,我在打印服务器 (Windows Server 2008) 上的驱动程序设置(打印机默认值)中修复了它。所以在打印服务器上:

  1. Go to "Devices and Printers" and choose the affected printer.
  2. Right-click and choose "Printer properties".
  3. Go to the "General" tab and click on the button "Change Properties" at the bottom.
  4. Go to the "Advanced" tab and click on the button "Printing Defaults...".
  5. Go to the "Page Setup" tab and define the settings you want (size, orientation).
  6. Click "OK" as many times as you need to save and exit.
  1. 转到“设备和打印机”并选择受影响的打印机。
  2. 右键单击并选择“打印机属性”。
  3. 转到“常规”选项卡,然后单击底部的“更改属性”按钮。
  4. 转到“高级”选项卡,然后单击“打印默认值...”按钮。
  5. 转到“页面设置”选项卡并定义所需的设置(大小、方向)。
  6. 根据需要多次单击“确定”以保存并退出。

回答by Renditya

Check the header or another object.

检查标题或其他对象。

Set properties:

设置属性:

can grow = False

回答by zankhesh jain

After the long search and try,i found that when crystal viewer load the page setup with four margin (top, bottom,left,right) changed automatic. So always write them in your code. it will solve your problem.

经过长时间的搜索和尝试,我发现当水晶查看器加载页面设置时,四个边距(顶部,底部,左侧,右侧)自动更改。所以总是把它们写在你的代码中。它会解决你的问题。

回答by BrankoH

Turn off "Adjust Automatically" in Design -> Page Setup -> Margins.

在设计 -> 页面设置 -> 边距中关闭“自动调整”。

回答by user11473955

I have just had this error with a Crystal Report that has been running in my MS Dynamics environment for YEARS without problem. After a bit of head scratching and Googling, one of my users said "oh, I guess you want me to delete all the NOTES on the Order".

我刚刚在我的 MS Dynamics 环境中运行了多年没有问题的 Crystal Report 出现了这个错误。经过一番挠头和谷歌搜索后,我的一位用户说“哦,我猜你想让我删除订单上的所有 NOTES”。

My Crystal report template has a "Notes" box in the Header of the report. In the design, it is fitted to have 1 line of notes, and the form fits an A4 page.

我的 Crystal 报表模板在报表标题中有一个“注释”框。在设计中,它适合有 1 行笔记,并且表格适合 A4 页。

[Quote Form]

[报价单]

The user entered over 40 lines of Notes into that box.... hence it pushed it outside the bounds of the page.

用户在该框中输入了 40 多行注释......因此它将它推到了页面的边界之外。