Wednesday, April 23, 2014

VS2013 - Visual Studio 2013 References, WTF why can't I add references. (solved)



So I'm switching to Vs2013...


and I keep adding references to the project, but they don't' show up in the references list under the project.


all I can say is WTF... but I finally figured it out..


You dont' add references like you did in say... every other visual studio ever...




If you highlight the reference and hit OK... it doesn't add it.


You MUST check the checkboxes for one or more reference to get it to add (see image below)





You have to get the check box next the reference name to appear and get it checked...


the easiest way is to just double click the reference and it'll show up checked... then and only then can you add the reference..




It makes sense, now you can add multiple references in one go, unlike before.. but DAMN was it confusing to a brain that already "knew" how to do it....




Proving once again the Maxim,


It's not what you dont' know that will kill you, it's what you do know, that's not what you think it is.



Wednesday, April 16, 2014

Rotativa corrupting or "ghosting" images when converting a JPEG in HTML to aPDF document

I'm using Rotativa to generate PDFs from Html Razor views.


v1.5.0 display images correctly, but doesn't paginate correctly
v1.6.1 correctly paginates from the html, but "ghosts" the images  Per this bug:


this is because of wkhtmltopdf which has a bug... it's supposed to be fixed in the trunk, but it's not in the versions I downloaded from their page.




The workaround is to convert the JPEG to one of the other "not jacked up" image formats..


In our case we converted to PNG. There is some loss of clarity, but we can live with that.






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" />


}