I got an issu with the plugin IronPDF. I'm trying to render HTML and CSS display to a PDF files, it work in our web application, but now I'm trying to do the same stuff with a windows service. I tried to use Bootstrap locally to get CSS, that didn't work so I used CDN link and it worked. But now, I would like to use pictures, so I pasted a folder in the root of the project with pictures in it, I think it's an application root problem (Ibelieved that the application root was the root of the project, but it seems to be wrong)
I would like to have something like this:
https://prnt.sc/gvzvpg
but instead, I have something like that :
http://prntscr.com/gvzw1r
thanks for attention
I used before ItexSharp for generating PDF files with c#. For images, the path must be relative path. try it
Related
I got an ASPX file on my Sharepoint. It's supposed to display some simple tables after clicking on it, but instead of it, it's being downloaded to my PC.
There is another file like that in my other folder and it works perfectly fine.
Could anyone give me some advice, how could I fix this problem, please?
Best regards
If the Aspx file is located in Site Pages or Pages library, it should display data directly rather than download if clicking it.
For this issue I suggest you can create a new site page and insert your custom JavaScript logic into the new created page, it should be able to display directly.
I have 2 projects that are needing to talk to one another. The first is a ASP.NET MVC project, that when in production, has a feature where the user can edit an html template that is stored in the wwwroot folder of the project.
The second project is a C# console app that grabs some user data from a database, and then uses that data to email surveys to users. The html template from the first project is needing to be grabbed by this console app so that it can be used in sending out these emails. I was hoping to use HtmlAgilityPack to grab the html email template from the first project when it is live, something along the lines of this:
var web = new HtmlWeb();
var document = web.Load("www.sitename.com/EmailTemplate");
string text = document.ParsedText;
But I'm open to other ideas that might work in this case. More or less I think I just need to figure out how to access static html files from within the wwwroot folder from a browser path, if that's possible. Oh and these two projects are going to be running on different servers, so local paths won't work. Thank you!
In large part thanks to ADyson's comments, the course of action that makes most sense in this situation is to create a small API within the MVC app, that fetches the html file, and the console app will call this API to retrieve the needed html.
I had a similar problem, and I did it by adding ~/ in the beginning of my static file addresses in my _Layout.cshtml.
My template files and photos were no longer loaded in the project but the layout was loaded. This way the files were also loaded
I need to write the code which will load some HTML (received from external source by other means) into WebView and display images referenced in this HTML. These images will be stored locally somewhere in Windows.Storage.ApplicationData.Current.LocalFolder.
Neither of suggestions at use local image to display in webview for windows phone 8.1 or Use local images in Webbrowser control work for me. If I load such HTML with web.NavigateToString(html):
<html><head></head><body>A <img src="file:///c:/Users/idh/AppData/Local/Packages/d783af9f-88eb-42f5-ab0f-abb025f32baa_5cy2zb9g43kb2/LocalState/folder/image001.jpg"> B</body></html>
I get just A B displayed. I tried slashes and backslashes, double and triple slashes after file:, ms-appx: and relative paths instead of file:, etc. The image never gets displayed. At the same time, if I save this in HTML file and open it outside of my app, it's displayed fine. I also successfully save and read these files (they are actually appeared in that folder because my app created them so unauthorized access is not an issue). package.manifest does include Private networks.
I'd better not use embedding with base64, custom uri resolver and other special techniques because I'm not the actual developer of the application. I make a library which gets HTML and saves images to local storage and now I need to demonstrate an easy to use method to visualize the stored content in WebView like I earlier did for normal .NET framework. I.e. I'm actually writing a sample for developers who are users of my library and these folks will then use my sample to deal with this HTML and images.
As the last resort, I can end up writing base64 or custom resolver for UWP version of my sample (while for other platforms like normal .NET framework the same procedure is much easier). But I want to at least be sure that the direct route of selecting proper URLs for images in the source HTML is not possible and I won't end up with situation where I wrote some quite complicated stuff and then someone experienced in UWP apps reveals that I over-engineered things. I.e. some expert opinion "no, it's not possible in UWP and you MUST use base64 embedding or custom URI resolving" will work for me too.
Although NavigateToString supports content with references to external files such as CSS, scripts, images, and fonts. But it only supports content in the app package using the ms-appx-web scheme, and web content using the http and https URI schemes. It can't work with assets located in the apps local folder. So using file:///, ms-appdata:/// or ms-appx:/// scheme won't work here.
To achieve what you want, you can use Base64 encoded images or custom URI resolver. Also I think you can store the html string to a file under the same subfolder that stores these image assets. In the html, you can use relative URI to reference these assets like what in my previous answer. And then use the Navigate method with a Uri that uses the ms-appdata scheme. For example:
var html = "<html><head></head><body>A <img src=\"image001.jpg\"> B</body></html>";
var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("folder", CreationCollisionOption.OpenIfExists);
var file = await folder.CreateFileAsync("html.html", CreationCollisionOption.OpenIfExists);
await FileIO.WriteTextAsync(file, html);
webView.Navigate(new Uri("ms-appdata:///local/folder/html.html"));
Background: I'm trying to make an extremely light news sort of...thing that relies entirely on hard code ASPX documents (not my decision). What I would like to do is create a bit of dynamic updating by having the main news page pull the latest ASPX file from a folder and get its "TopContent" section on the main page. How would I best be able to do that? I'm stuck with ASP.NET 2.0 on this project as well.
So I didn't quite transclude ASPX documents, but I found a way to get this to work by having XML files with the data pieces I needed and just using that. No problem.
In detailed: An XML file containing the title, the top content and the main content and then using a URL argument to figure out which file to open.
I have an html file (which consists of both text and images) in my Documents library (it need not exactly be over there, what I mean to emphasize is - it's not in the internet and not included within the app package since it's dynamic content and created after the app has been deployed).
I want to display the contents of this page within a WebView. How would I go about doing that ?
You can (and should) copy your HTML Files to the LocalState Directory of your App which sits here: C:\Users\YourUSerName\AppData\Local\Packages\YourApp\LocalState.
You then can Access this with: ms-appdata:///local/
Very Basic example:
string url = "ms-appdata:///local/myWebpage.html";
webView.Navigate(new Uri(url));
You can find a lot of Information and samples in this sample download: https://code.msdn.microsoft.com/windowsapps/XAML-WebView-control-sample-58ad63f7