SSRS PDF Export. There was an error opening this document. This file is damaged and could not be repaired

Hello,

I just experienced this problem, and was able to successfully mitigate.  I wanted to share my experience and Solution. 

The problem started with the following error after succesfully exporting a PDF Document.  "There was an error opening this document. This file is damaged and could not be repaired."

This is only applicable if you can still export and open SSRS Reports to other formats. Go to the Log files of the SQL Instance. In my particular case I used the Default MSSQL instance:   C:\ Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\LogFiles  

The Folder will begin with MSRS (SRS is for SQL Reporting Services)

Sort the files by date modified and check for the most recent log file: ex.  SQLDmpr0000.log  The 0000 will be the incremental amount of errors you have experienced in SRS. Check for the following error: "System.DllNotFoundException: Unable to load DLL 'T2Embed': Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"


Below is a sample from the log. 

reportrendering!ReportServer_0-1!1b78!02/07/2012-11:56:03:: 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.DllNotFoundException: Unable to load DLL 'T2Embed': Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

   at Microsoft.ReportingServices.Rendering.ImageRenderer.FontPackage.TTGetEmbeddingType(Win32DCSafeHandle hdc, UInt32& status)

   at Microsoft.ReportingServices.Rendering.ImageRenderer.FontPackage.CheckEmbeddingRights(Win32DCSafeHandle hdc)

   at Microsoft.ReportingServices.Rendering.ImageRenderer.PDFWriter.ProcessFontForFontEmbedding(PDFFont pdfFont, Dictionary`2 embeddedFonts)

   at Microsoft.ReportingServices.Rendering.ImageRenderer.PDFWriter.EndReport()

   at Microsoft.ReportingServices.Rendering.ImageRenderer.PDFRenderer.Render(Report report, NameValueCollection deviceInfo, Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream)

   at Microsoft.ReportingServices.Rendering.ImageRenderer.RendererBase.Render(Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, Hashtable& renderProperties, CreateAndRegisterStream createAndRegisterStream)

   --- End of inner exception stack trace ---

   at Microsoft.ReportingServices.Rendering.ImageRenderer.RendererBase.Render(Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, Hashtable& renderProperties, CreateAndRegisterStream createAndRegisterStream)

   at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderFromOdpSnapshot(IRenderingExtension newRenderer, String streamName, ProcessingContext pc, RenderingContext rc)

   --- End of inner exception stack trace ---;

If you notice the error states that T2Embed.dll access is denied. In my case this due to a hotfix installed by Microsoft: 

 MS11-087: Vulnerability in Windows kernel-mode drivers could allow remote code execution: December 13, 2011

Be advised, in order to fix your problem and render pdf's, a vulnerability shall be created.

 To fix this issue and allow the export to PDF work correctly, you must give the system Read/Execute Permissions, and Built-in\Administrators Full Control. 

Go to Windows\System32 and find the T2Embed.dll Go to Security and modify the permissions as listed above. Do the same to the T2Embed.dll in the SysWow64 folder.

Restart Reporting Services and you will be able to export to PDF. 

Best Wishes! 

Mariano

www.lucontech.com 

  • Edited by LuconTech Tuesday, February 07, 2012 10:19 PM Added Log / Modified Fonts
February 7th, 2012 10:10pm

I had similar problem although I'm not sure about the damaged file part of it you got.  I pulled out half of my hair trying to get ReportViewer to work over the web.  It works and it exports to Excel.  PDF and Word export fail.  I'd like to export to PDF as it is more universal.  You have to hate hotfixes that screw up your code.

So after reading your post my question is if Full Control is required then can this be specified in a web.config that is lower from the root to help isolate the extra permissions to just report viewer!?!

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2012 7:32am

I'm not convinced this is the exact cause of the issue.  I will check my log files to see if I find anything like what you described.  However, I get this error when a particular user tries to do a "print preview" from a custom button.  The code builds a ReportViewer object, sets the ReportPath, etc.

The reason I'm not convinced is because we have a separate reports page that has the report viewer embedded into it.  If the user generates the report that way and exports to PDF, Word, etc...the user can generate the file and be on their way.  As soon as the user clicks our "Print" button on the page without the ReportViewer embedded, the above mentioned error occurs.  

UPDATE: Perhaps we have a different problem since my issue is from a custom button.  I found the solution here and confirmed the solution with the customer.  It had to do with the code using Response.Flush() instead of Response.End().

One thing I noticed before I implemented the change: When you would close the PDF, it would ask you to save changes to the PDF.  After implementing Response.End() instead, that prompt went away.  No doubt it has to do with the differences between how Response.Flush() and Response.End() handle the stream returned.

Anyway, posting in case someone has the same issue.

  • Edited by souptoy Thursday, September 13, 2012 3:38 PM
September 12th, 2012 9:59pm

I need to access T2Embed.dll from application bin folder. I have used all other required dll for ReportViewer from bin folder which is working absolutely fine. But this dll is not work. Can anyone help me out !!!



  • Edited by Dulal Baidya Thursday, February 20, 2014 12:54 PM
Free Windows Admin Tool Kit Click here and download it now
February 20th, 2014 12:52pm


Hi Mariano,

I am facing exactly the same problem when the report is running in remote web host. It is working fine in my local system. I had copied the dll in the bin folder also. But it is not working. Can you please help me out...



  • Edited by Dulal Baidya Thursday, February 20, 2014 1:01 PM
February 20th, 2014 1:00pm

I just wasted so much time on trying different ways to get the t2embed.dll working on my godaddy hosted site with my .rdlc reports.  Again, everything worked fine locally.  Different combinations of 32bit\64bit debug and release mode builds, 32bit\64bit copies of the dll, etc.

I finally decided to just try not deploying the t2 dll at all and and i changed all my font's to arial and i removed a dynamic image that i had in there as well.  

That worked!  Hope this helps someone.

FYI, I still did publish the Microsoft.ReportViewer.Common & Microsoft.ReportViewer.ProcessingObjectModel that are needed with a hosted site.

Free Windows Admin Tool Kit Click here and download it now
April 8th, 2014 10:54pm

@jasonhoelz  Thank You - this was a great pragmatic solution!
June 20th, 2014 4:33pm

Thanks Jason, changing all fonts to Arial fixed this error for me.
Free Windows Admin Tool Kit Click here and download it now
March 7th, 2015 2:49pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics