SSRS 2019报表导出PDF报错求助,Excel导出正常
SSRS报表导出PDF失败(Excel导出正常)
问题描述
将SSRS报表/Test/TestReport导出为PDF时出现报错,Excel导出功能正常。报错堆栈信息如下:
RenderFromSession('/Test/TestReport') reportrendering!ReportServer_0-12 e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.UnhandledReportRenderingException: , Microsoft.ReportingServices.ReportProcessing.UnhandledReportRenderingException: An error occurred during rendering of the report. ---> Microsoft.ReportingServices.OnDemandReportRendering.ReportRenderingException: An error occurred during rendering of the report. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component. at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at Microsoft.ReportingServices.Rendering.RichText.TextRun.ShapeAndPlace(Win32DCSafeHandle hdc, FontCache fontCache) at Microsoft.ReportingServices.Rendering.RichText.LineBreaker.GetLine(Paragraph paragraph, TextLine line, Win32DCSafeHandle hdc, FontCache fontCache, FlowContext flowContext, Single left, Single right, Single height, Stack`1 lineRunsIndex, Stack`1 lineRunsCharIndex, Int32 lineIndents) at Microsoft.ReportingServices.Rendering.RichText.LineBreaker.FlowParagraph(Paragraph paragraph, Directions direction, Win32DCSafeHandle hdc, Single dpiX, FontCache fontCache, FlowContext flowContext, Boolean keepLines, SizeF flowContextSize, Int32& contentOffset) at Microsoft.ReportingServices.Rendering.RichText.LineBreaker.Flow(TextBox textBox, Win32DCSafeHandle hdc, Single dpiX, FontCache fontCache, FlowContext flowContext, Boolean keepLines, Single& height) at Microsoft.ReportingServices.Rendering.RichText.LineBreaker.Flow(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, Boolean keepLines, Single& height) at Microsoft.ReportingServices.Rendering.RichText.TextBox.MeasureFullHeight(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, Single& contentHeight) at Microsoft.ReportingServices.Rendering.HPBProcessing.TextBox.CalculateVerticalSize(PageContext pageContext) at Microsoft.ReportingServices.Rendering.HPBProcessing.TextBox.DetermineVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors) at Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors, Nullable`1 sourceWidth) at Microsoft.ReportingServices.Rendering.HPBProcessing.PageItemContainer.DetermineContentVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors, Boolean resolveState, Boolean resolveItem) at Microsoft.ReportingServices.Rendering.HPBProcessing.PageItemContainer.DetermineVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean& anyAncestorHasKT, B library!ReportServer_0-/11/2024-11:13:44:: e ERROR: Report server dump occured. Exception: Microsoft.ReportingServices.ReportProcessing.UnhandledReportRenderingException: An error occurred during rendering of the report. ---> Microsoft.ReportingServices.OnDemandReportRendering.ReportRenderingException: An error occurred during rendering of the report. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component., Message: , Unhandled Exception: False library!ReportServer_0-/11/2024-11:13:44:: e ERROR: Report server unique dump occured. Exception: Microsoft.ReportingServices.ReportProcessing.UnhandledReportRenderingException: An error occurred during rendering of the report. ---> Microsoft.ReportingServices.OnDemandReportRendering.ReportRenderingException: An error occurred during rendering of the report. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component., Message: , Unhandled Exception: False library!ReportServer_0-/11/2024-11:13:50:: i INFO: Dump result: External dump process return code 0x20000001. External dump process returned no errors.
排查与解决步骤
1. 检查报表字体兼容性
从报错堆栈看,问题出在富文本渲染的字体处理环节:
- 确认报表中使用的所有字体(包括特殊字体、非系统默认字体)已在报表服务器上安装。
- 临时替换报表中的特殊字体为服务器默认字体(如Arial、宋体),测试PDF导出是否恢复正常。
2. 调整文本框布局属性
- 检查报表内所有文本框的
CanGrow、CanShrink属性,尝试设置为False,避免渲染时因文本尺寸计算异常触发COM调用失败。 - 确保文本框宽度足够容纳内容,减少因强制换行导致的布局计算错误。
3. 清理富文本格式
如果报表使用了富文本(RTF)内容:
- 清除文本框中的富文本格式,改为纯文本后测试导出。
- 检查富文本中是否存在无效标记、嵌套样式,手动清理或重新设置格式。
4. 验证服务器资源与权限
- 确认报表服务器有充足的内存、CPU资源,避免PDF渲染时资源不足导致异常。
- 确保报表服务运行账户拥有访问系统字体目录(通常为
C:\Windows\Fonts)的权限。
5. 更新SSRS与.NET环境
- 安装最新的SSRS累积更新(CU),修复官方已知的PDF渲染bug。
- 确保服务器上的.NET框架版本符合对应SSRS版本的要求,必要时更新至指定版本。
6. 定位问题元素
- 创建仅包含基础内容的简化版报表,测试PDF导出是否正常,逐步添加原报表的内容,定位到触发报错的具体元素(如某文本框、某段数据集内容)。
内容的提问来源于stack exchange,提问作者Balamurugan Panneerselvam
相关产品推荐
相关产品推荐

