A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hello @Sreenivasan, Sreejith ,
Thanks for your question.
This behavior is often related to how iOS WKWebView renders a standalone image. When an image URL is loaded directly, iOS treats it as a raw image document without a real <body> element, so alignment changes applied through the handler or injected CSS may have no effect. This could be the reason your handler updates are not producing the expected result.
I recommend loading the image through a small HTML wrapper on iOS, rather than loading the image URL directly. The HTML provides a container that can be centered with CSS:
string imageHtml = $@"
<html>
<head>
<style>
html, body {{ margin:0; padding:0; height:100%; }}
body {{ display:flex; justify-content:center; align-items:center; }}
img {{ max-width:100%; max-height:100%; object-fit:contain; }}
</style>
</head>
<body><img src='{imageUrl}' /></body>
</html>";
wkWebView.LoadHtmlString(new NSString(imageHtml), baseUrl: null);
The PDF loading path can be left unchanged, and this branch would only run when the URL points to an image.
I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback. Thank you.