Rotativa 1.6.1 Image “ghosting” but only on QA, not dev or integration server

依然范特西╮ 提交于 2019-12-11 21:21:52

问题


I'm running a c# MVC 4 app , using Rotativa to convert Razor views to Pdfs. Rotativa is basically a wrapper around wkhtmltopdf.

I upgraded to Rotativa 1.6.1, to fix a page break issue in wkhtmltopdf,, and my images are "ghosting". I rolled back to 1.5.0 and the problem went away (but page breaks are broken again).

Looks just like in this wkhtmltopodf bug http://code.google.com/p/wkhtmltopdf/issues/detail?id=788

They claim it's fixed in the tip. (I tried manually updating to the latest stable release and it still occurred)

Oddly the issue only occurs on our QA server, not our DEV server, or our integration server that the IT group claims is "identical" to QA...

Any ideas what might be causing this issue? Anyone else getting it?

This issue: https://github.com/webgio/Rotativa/issues/51 and this one https://github.com/webgio/Rotativa/issues/26

Imply there are some permission issues that can cause Rotativa to have problems. Can anyone point me to more information on what kind of permissions might be at fault, so I can compare then on the 2 boxes?

Thanks,

Eric-


回答1:


OK we figured out a work around for this... It's "ghosting for JPEG Images"...

So I Just converted them from JPEG to PNG (one of 2 known good image formats)...

Since they were already stored in the DB as JPEG, I did the conversion on the fly in the Razor View.

There is some loss of fidelity, but other than that it works great....

try
{
     byte [] byteArrayIn = ( byte[] )@Model.ETA640StudentProfileVM[ currentRecord ].ImageObj;
     byte[] byteArrayOut = null;

     MemoryStream ms = new MemoryStream( byteArrayIn, 0, byteArrayIn.Length );
     ms.Write( byteArrayIn, 0, byteArrayIn.Length );
     Image returnImage = Image.FromStream( ms, true );
     using (var output = new MemoryStream())
     {
         returnImage.Save( output, System.Drawing.Imaging.ImageFormat.Png );
         byteArrayOut = output.ToArray();
     };


     @:<img src="data:image/png;base64,@(Html.Raw( Convert.ToBase64String( byteArrayOut )))" alt="Image Not Available" height="155" />

}
catch
{ 
     @:<img src="" alt="Error Generating Image" height="155" /> 
}


来源:https://stackoverflow.com/questions/23071227/rotativa-1-6-1-image-ghosting-but-only-on-qa-not-dev-or-integration-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!