Nreco PdfGenrator force new page - c#

How to force new page with HTML in NReco PdfGenerator with C#?
Maybe specific class or id, like this works for pagination:
<div style='height: 60px;'>Seite <span class='page'></span> von <span class='topage'></span></div>
Thanks.

Page break may be forced with the following css:
<div style="page-break-after:always"></div>

Related

Is it possible to give name to Quasar Uploader in <form>

I have a <form> where I am using Vue.js and Quasar, and submits in as a HTML form in asp .net core 3.1
The problem is when I am using Quasar Uploader (https://quasar.dev/vue-components/uploader).
The functionality works fine, but when I submit the form (post i C# and .net core).
I cant get the the file in the controller.
As you can see from this example: https://codepen.io/cbrown___/pen/GRZwpxw
When the Uploader is rendered it does not have the attribute name. From the example above you have this input:
<input tabindex="-1" type="file" title="" class="q-uploader__input overflow-hidden absolute-full">.
I guess that is why I cant get it from my Controller. How can I solve this when I am using .net Core 3.1 to submit this form?
And I see no good solutinos in letting people upload files through my API before the record is created.
Is it a option here I do not see?
EDIT:
The <input> is on the plus-icon. So by using inspect elements you should be able to see that no name occurs.
EXAMPLE CODE:
HTML
<div id="q-app">
<div class="q-pa-md">
<div class="q-gutter-sm row items-start">
<q-uploader
url="http://localhost:4444/upload"
style="max-width: 300px"
></q-uploader>
<q-uploader
url="http://localhost:4444/upload"
color="teal"
flat
bordered
style="max-width: 300px"
></q-uploader>
<q-uploader
url="http://localhost:4444/upload"
label="Upload files"
color="purple"
square
flat
bordered
style="max-width: 300px"
></q-uploader>
<q-uploader
url="http://localhost:4444/upload"
label="No thumbnails"
color="amber"
text-color="black"
no-thumbnails
style="max-width: 300px"
></q-uploader>
</div>
</div>
</div>
JS:
new Vue({
el: '#q-app'
})
If any body else need this I ended up with using this:
:name="'file_description[' + index + ']'"
That way each one got one name...and from another array I knew how many file_description it would be.

How do I download the HTML code of the url with the images NOT being hidden

I am trying to do some webscraping but when I download the html of the url the images are hidden but in my browser they are not "user-ad-row__image image image--is-hidden" instead of "user-ad-row__image image image--is-visible". Was seeing if webclient changed anything. Using the HtmlAgilityPack.
var url = "https://www.gumtree.com.au/s-motorcycles-scooters/wa/drz+400/k0c18322l3008845";
var httpClient = new HttpClient();
var html = await httpClient.GetStringAsync(url);
var htmlDocument = new HtmlAgilityPack.HtmlDocument();
WebClient client = new WebClient();
htmlDocument.LoadHtml(client.DownloadString(url));
<div class="user-ad-row__main-image-wrapper user-ad-row__main-image-wrapper--has-image"><img class="user-ad-row__image image image--is-hidden" src="" alt="Suzuki Drz-400E"></div>
</div>
<div class="user-ad-row__details">
<div class="user-ad-row__info">
<p class="user-ad-row__title">Suzuki Drz-400E</p>
<div class="user-ad-price user-ad-price--row"><span class="user-ad-price__price">$4,250</span>
<!-- -->
<!-- --><span class="user-ad-price__price-negotiable user-ad-price__price-negotiable--with-price">Negotiable</span>
<!-- -->
<!-- -->
<!-- -->
</div>
<ul class="user-ad-attributes">
<li class="user-ad-attributes__attribute">Learner Approved</li>
<li class="user-ad-attributes__attribute">6000 km</li>
</ul>
<p id="user-ad-desc-MAIN-1228533281" class="user-ad-row__description user-ad-row__description--regular">For sale 2008 Drz-400E excellent condition, well looked after starts first time evertime serviced about a month ago. Just paid 3 months rego. Call or text </p>
</div>
<div class="user-ad-row__extra-info">
<div class="user-ad-row__location"><span class="user-ad-row__location-area">Perth City Area</span>Perth<span class="user-ad-row__distance"> </span></div>
<p class="user-ad-row__age">15/09/2019</p>
</div>
</div>
<button id="" type="button" class="user-ad-row__watchlist-heart-wrapper watchlist-heart Button__buttonBase--3YR6h Button__button--2NsdC Button__buttonBasic--3CSBx" role=""><span class="" aria-hidden="true"><span class="icon-heart heart"></span></span>
</button>```
The website that you provided loads images using Javascript and according to an internet search it appears that HtmlAgilityPack only renders the HTML but is unable to run Javascript.
Some solutions would be:
WebBrowser Class
It's kind of tricky if you want to mix it with the HtmlAgilityPack but provides decent performance.
Selenium
You can use Selenium+a webdriver for your prefered browser (Chrome, Firefox, PhantomJS). It is somewhat slow but is very flexible.
Javascript.Net
It allows you to run scripts using Chrome's V8 JavaScript engine. Near the bottom of the page there will be something like <script src="/latest/resources/react/app.full.something.js"></script>
If you are able to figure out how that loads then you should be able to get all of the images.

ASP.NET MVC C# show image from text url in database

I have been searching for an answer for this but can't seam to find one.
<div class="text-center">
<img src="#Html.DisplayFor(model => model.Image)" class="img-thumbnail">
</div>
This is the section I'm using. Basically I'm inputting the url as text into the database and when I use the above code (in the details page) it shows the image in Internet Explorer, but not in Chrome.
I'm VERY new to this so I'm unsure how to do this.
Thanks
Use Url.Content as shown below since Model.Image has the URL:
<div class="text-center">
<img src="#Url.Content(Model.Image)" class="img-thumbnail">
</div>

Displaying an image in a foreach

So I have login with LinkedIn and I'm trying to add a Facebook one.
I already have the "Signin with LinkedIn" button working, and am trying to add the Facebook one:
<div id="socialLoginList">
<p>
#foreach (AuthenticationDescription p in loginProviders)
{
var source = "~/Img/" + p.AuthenticationType + ".png";
<input type="image" src="#source" border="0" id="#p.AuthenticationType" name="provider" value="#p.AuthenticationType" style="max-height: 100%; max-width: 100%">
}
</p>
</div>
If I don't build the path like this, and give it src="~/Img/Facebook.png" or src="~/Img/LinkedIn.png" they work. How can I write the path so the pictures don't appear as broken elements on the page?
src="#Url.Content(String.Format("~/Img/{0}", source))"
If you are using c# 6.0 than you can use Interpolated Strings it'll give you same thing but in much cleaner way
src="#Url.Content($"~/Img/{#source}")"

how to apply action link to html block

<div class="thumbnail" style="height: 70px; background-color: #EEEDED">
<div style="font-weight: bold;font-size: 20px;text-align: center">
#Html.Label(exam.ExamName,new{#style="cursor: pointer;color: #FF8627 "})
</div>
<div style="font-size: 15px;text-align: center;color: #505050">
#Html.Label("Total Tests: " + exam.TestInfoes.Count(), new{#style="cursor: pointer"})
</div>
</div>
I have above HTML block, I want to put this whole block in tagin my mvc4 application.
We can do it using maually writing whole block in between tag but I also want to pass some value in the link which will be created for tag
<a href="~/Exam/SingleExam/" + some value from my model>
how do we do it ?
Also How can we achieve this using ActionLink ?
You can do this by using Partials or Editor/Display Templates
To render the partial you can use:
#Html.RenderPartial("partialname", model);
An article can be found here:
http://www.codeproject.com/Tips/617361/Partial-View-in-ASP-NET-MVC
To use templates you can use a custom defined Html.DisplayFor template.
There is an article about the subject here:
http://www.hanselman.com/blog/ASPNETMVCDisplayTemplateAndEditorTemplatesForEntityFrameworkDbGeographySpatialTypes.aspx
The main thing about the templates is that the template must mach the name of the class of the object.
With both methods you can pass your model.
I hope this helps.
well I created link like this
<a href="~/Exam/SingleExam/#exam.Id">
<div class="thumbnail" style="height: 70px; background-color: #EEEDED">
<div style="font-weight: bold;font-size: 20px;text-align: center">
#Html.Label(exam.ExamName,new{#style="cursor: pointer;color: #FF8627 "})
</div>
<div style="font-size: 15px;text-align: center;color: #505050">
#Html.Label("Total Tests: " + exam.TestInfoes.Count(), new{#style="cursor: pointer"})
</div>
</div>
</a>
Instead of using action link I just used html tag & passed id using #exam.id which created proper url for me.

Categories

Resources