protected void preview_Callback(object sender, CallbackEventArgsBase e)
{
using (var uow = new OriginationUow())
{
var id = new Guid(Convert.ToString(hdf_attchmentid.Get("attachmentid")));
var file = uow.Attachments.GetAll().Where(o => o.InvoiceId == (id));
foreach (var item in file)
{
byte[] fileBytes = item.FileDetails;
var filename = item.DocName;
if (filename.EndsWith(".pdf"))
{
// Assume that 'imageBytes' is your byte array containing the image data
// Convert the byte array to a Base64-encoded string
string base64String = Convert.ToBase64String(fileBytes);
// Generate the data URL with the Base64-encoded image
string imageUrl = $"data:image/png;base64,{base64String}";
// Use window.location to display the image in a new window or tab
ScriptManager.RegisterStartupScript(this, this.GetType(), "openImage", $"window.open('{imageUrl}')", true);
_name = "View/Attachment/PdfFile.aspx";
}
// cppreview.JSProperties["cpResult"] = _name;
}
}
}