Question

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-

Was it helpful?

Solution

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" /> 
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top