C# - Pass Html As A String Using Wkhtmltopdf?

Jan 10, 2011

how to pass html as a string instead of url in wkhtmltopdf using asp.net, c#?

View 1 Replies


Similar Messages:

Login - Wkhtmltopdf Log In To Web App?

Jan 10, 2011

Having a problem with wkhtmltopdf. I'm using it to take pdf snapshots of pages on a website that has a username/password page. When the .exe runs, I end up with a snapshot of the login page (running the exe from my own ASP.NET app).

Does anybody know how I would get wkhtmltopdf to log into the site so that it can access the page it needs to take a snapshot of?

wkhtmltopdf is installed in the program files directory on the server and is being called via:

public void HtmlToPdf(string website, string destinationFile)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "wkhtmltopdf.exe";
startInfo.Arguments = website + " " + destinationFile;
Process.Start(startInfo);
}

EDIT -------------

I couldn't get the --cookie-jar method to work (see comments), but I did find another way to programmatically log in with the username/password in the querystring.

I pass the username/pw as params in my querystring and try to access the page I want with wkhtml. When the membership provider kicks me out to the login page, I access the params (which are stored in the url as the returnUrl param) via code-behind and authenticate myself. A simple response.redirect, and bingo -- I've got my PDF snapshot.

// Check to see if an outside program is trying
// to log in by passing creds in the querystring.
if (Request.QueryString["username"] != null) &&
Request.QueryString["password"] != null))
{
string user = Request.QueryString["username"];
string pw = Request.QueryString["password"];
if (System.Web.Security.Membership.ValidateUser(user, pw))
{
// Create an authentication ticket for wkhtml session
System.Web.Security.FormsAuthentication.SetAuthCookie(user, false);
if (Request.QueryString["ReturnUrl"] != null)
{
Response.Redirect(Request.QueryString["ReturnUrl"]);
}
}
else
{
throw new Exception("You failed to log in.");
}
}

View 1 Replies

C# - How To Use Wkhtmltopdf In Page That Requires Users To Be Logged In

Mar 2, 2011

I have created a simple ASP.Net page to create self printable tickets so non-technical people can change the text and layout of a ticket. Obviously the user has to be logged in to be able to print their tickets.

When providing the URL for wkhtmltopdf to convert, the tickets are not created because wkhtmltopdf does not have a session to prove the user is logged in.

Is it possible to pass the session to wkhtmltopdf in the URL, or is their a better solution?

View 1 Replies

State Management :: How To Pass Dynamic String Through Query String With Java Script

Dec 24, 2010

I m facing some problem. i m not passing Dynamic string through query string..

I m using this code

string abc = "CPCB_" + TextBox1.Text + "_" + TextBox2.Text;

Response.Write("<script>window.open('xml.aspx?Flag=3&date='+abc,target='new');</script>");

View 2 Replies

MVC :: How To Pass A Value Form ActionResult To Html.textbox Or Html.TextBoxFor In View

Mar 18, 2010

how can i passing a value form ActionResult to html.textbox or Html.TextBoxFor in View

View 2 Replies

C# - Pass Model Values As Javascript Function Parameters From Inside Mvc Html Helper Such A Html.Radio?

Jul 20, 2010

I think I need to drop in some escape characters, but I'm not quite sure where. Here is the javascript function I'm attempting to call:

function setData(associateValue, reviewDateValue) {
var associate = document.getElementById("Associate");
var reviewDate = document.getElementById("ReviewDate");
associate.value = associateValue;
reviewDate.value = reviewDateValue;
}

Here is the asp .net mvc line where I'm attempting to create a Radio button with a click event that calls the above function and passes data from the model as javascript parameter values.

<%= Html.RadioButton("Selected", item.Selected, new { onClick="setData('<%=item.Associate%>','<%=item.ReviewDate%>' )" } )%>

The above throws a bunch of compile issues and doesn't work. A call such as the following does call the javascript, but doesn't get the data from the model.

<%= Html.RadioButton("Selected", item.Selected, new { onClick="setData('item.Associate','item.ReviewDate' )" } )%>
<%= Html.RadioButton("Selected", item.Selected, new { onClick="setData('item.Associate','item.ReviewDate' )" } )%>
<% String functionCall = String.Format("setData('{0}','{1}')", Html.Encode(item.Associate), Html.Encode(item.ReviewDate )) ; %>
<%= Html.RadioButton("Selected", item.Selected, new { onClick=functionCall } )%>

View 2 Replies

C# - Cannot Pass A Input From Text Box To A Query String And Then Keep The String In This Box?

May 28, 2010

I have a simple ASP.net page:

<form id="form1" runat="server">
<p><asp:TextBox id="input_box" runat="server"></asp:TextBox>
<asp:Button Text="OK" runat="server" OnClick="run" /></p>
</form>

I want to send input from input_box to a query string, and then keep this input in the input_box when the page reloads.

That's the code behind page:

protected void Page_Load(object sender, EventArgs e)
{
input_box.Text = Request.QueryString["input"];
}
protected void run(object sender, EventArgs e)
{
string url = string.Format("?input={0}", input_box.Text);
Response.Redirect(Request.Url.AbsolutePath + url);
}

Problem is that when query string is not empty, string from input_box cannot be passed to query string. How to correct it?

View 1 Replies

Web Forms :: Error Input String Was Not In Correct Exporting HTML String To PDF Using ITextSharp

Jul 20, 2012

 //Read string contents using stream reader and convert html to parsed conent var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(contents), null);   
//Get each array values from parsed elements and add to the PDF document foreach (var htmlElement in parsedHtmlElements) pdfDoc.Add(htmlElement as IElement);   
//Close your PDF pdfDoc.Close();   Response.ContentType = "application/pdf";   
//Set default file Name as current datetime Response.AddHeader("content-disposition",

[Code] ....

Error: Input string was not in a correct format. Contents in html file giving error ...

View 1 Replies

C# - Cutting HTML String Into Separate Lines Without Breaking HTML Tags

Oct 24, 2010

I have to break a HTML content string in to multiple lines. And each line should have some fixed characters, 50 or 60 Also I don't want to break the word..or html tags...

ex : <p>Email: <a href="mailto:someone@gmail.com">someone@gmail.com</a></p>
<p><em>"Text goes <font color=red>Hello world</font> Text goes here and Text goes here Text goes here 1976."</em> </p>

How can I acheive this in C#?

View 1 Replies

Sending An HTML Encoded String In The Query String?

Jan 5, 2011

We are sending an HTML encoded string in the Query string. It was working fine on IIS 6 (windows 2003). We have recently moved the website to Windows 2008 (IIS 7.x). Since the move any Query String that contains "+" sign i.e., "%2b" gives error on the server "404 -File or directory not found."

View 2 Replies

How To Replace Html Tag In Html Editor With Specific String

Feb 9, 2010

anyone knows how to replace a html tag in a string with specific characters:

e.g.

string s1 = "<span style="italic">inluding <span style="bold">other</span> tags </span>";
string s2 = "<span style="italic">inluding </span><span style="bold">other tags </span>";

i want to replace "span" with "bold" to "bOpen" and "bClose" and to replace "span" with "italic" to "iOpen" and "iClose" in both c# and javascript.

i did use regular expression to do that: res = Regex.Replace(res, ".*?", replaceHtmlBold); but it cant match the nested tag and none-nested tag at the same time.

View 2 Replies

Pass String Contains '+' Via The Querystring?

Apr 22, 2010

I need to pass '+' via the QueryString.

some special character can be passed by using 'Encode' .. but '+'

I know the one solution, If I replace '+' with other character.

But it's not the perfect solution.

[edited]

well I used escape() javascript function to encode.

escape function can't encode + . is the another function to encode on javascript?

View 4 Replies

Pass Value In String S Onto A New Webpage In C#

Nov 8, 2010

i want to pass a string value from one page to another.Also i have some text boxes and the values entered in it needs to be passed to a new page.How do i do it?

I have a string S

String S = Editor1.Content.ToString();

i want to pass value in string S onto a new page i.e Default2.aspx how can i do this in ASP.net C#

View 3 Replies

MVC :: Pass A String Value To A Controller Action?

Feb 16, 2011

I am trying to get this functionality on my jokes website:

www.mysite.com/category/bar

To get all the bar jokes ..etc

The way I have my route right now is:

{controller}/{action}/{id}

which means I have to type:

www.mysite.com/category/index/bar

the problem is that even with that, the string parameter "bar" isn't being acknowledged ! ( I know from debugging). Here is my Index action in the Category controller:

[Code]....

View 8 Replies

How To Pass Date In Query String

Mar 4, 2010

I have a textbox with a date field in dd/MM/yyyy format.

I am passing it to popup page via query string. Problem being is that it is translated there as MM/dd/yyyy

How do I fetch the date correctly guys ? My code on parent page gridview

[Code]....

View 8 Replies

C# - Pass String Parameter To SqlDataSource?

Sep 16, 2010

i have placed a SqlDataSource component on my aspx page but while configuring the SqlDataSource in the "Test Query" Step I am passing the following parameters :But when i click ok it returns following error:This error occurs when i pass the string :

INFO, WARN, ERROR,

I have tried a lot of combinations but nothing works. It works only if i pass one of the three words in single quotes like this :'ERROR'Infact the INFO WARN and ERROR are the various levels available in the table. Each record can have only one level and in the sql query i am using IN("-----") to match the criteria, hope you understand.

View 2 Replies

Web Forms :: Can't Pass String From Database

Apr 23, 2010

I'm creating a dynamic menu, from the reading of a table in a database, everything is going well so far I need to read the url field that has the address of the pages, to appear in the masterpage, the problem can not I pass the string from the database for the navigateUrl.

<DataBindings>
<asp:MenuItemBinding DataMember="MenuItem"
TextField="Text" ToolTipField="ToolTip" NavigateUrl="pathurl"/>
</DataBindings>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<!-- Find the root node called Menus
and call MenuListing for its children -->
<xsl:template match="/Menus">
<MenuItems>
<xsl:call-template name="MenuListing" />
</MenuItems>
</xsl:template>
<!-- Allow for recusive child node processing -->
<xsl:template name="MenuListing">
<xsl:apply-templates select="Menu" />
</xsl:template>
<xsl:template match="Menu">
<MenuItem>
<!-- Convert Menu child elements to MenuItem attributes -->
<xsl:attribute name="Text">
<xsl:value-of select="Description"/>
</xsl:attribute>
<xsl:attribute name="ToolTip">
<xsl:value-of select="Text"/>
</xsl:attribute>
<xsl:attribute name="pathurl">
<xsl:value-of select="url"/>
</xsl:attribute>
<!-- Call MenuListing if there are child Menu nodes -->
<xsl:if test="count(Menu) > 0">
<xsl:call-template name="MenuListing" />
</xsl:if>
</MenuItem>
</xsl:template>
</xsl:stylesheet>

View 2 Replies

How To Pass A String From .aspx To A Class

Feb 24, 2010

I need to pass a string from my .aspx page to my .VB class.

i need to capture (device_category; accept_headers : user_agent) and pass the values to my class, i tryed to captur the values on the clas itself but i got an error(valuse are not member of this class..)

How can i have a string accessable to my class?

View 10 Replies

How To Pass A Value To A String From A Local Resource

Feb 11, 2010

I have created a webpage called server.aspx and the related local resource file called server.aspx.resx. In the resourcefile I defined the message "{0} is required." with the key Error.

In my .aspx page I access the string:

<asp:RequiredFieldValidator ControlToValidate="textboxName" runat="server" ErrorMessage="<%$ Resources:Error %> ID="validatorName">

Now I want to pass a value, for example the name of the textbox 'Name' to the resource string, so that the errormessage is "Name is required."

Is there any possibility to pass a value to the string?

View 2 Replies

C# - Pass A String Value Into A Gridview In C Sharp?

Oct 6, 2010

i have extracted data from database..currently that information is in a string variable...my point is to pass that string value into a gridview in the application..i have already created the gridview with checkbox list fitted into it...on inserting the values will the gridview will expand dynamically ??..if no then what to do ? how to push the data into gridview so that it expands dynamically?

View 1 Replies

Web Forms :: Pass A String Value From JavaScript To VB.Net?

Nov 21, 2010

I'm new to ASP.Net and need to pass a string value being recorded in a JavaScript function to a temporary string declared in VB.Net.

View 2 Replies

C# - Pass An Id Number String To Class?

Apr 14, 2010

I'm very much a vb person, but have had to use this id number class in c#. I got it from [URL]

using System;
using System.Text.RegularExpressions;
namespace Utilities.SouthAfrica
{
/// <summary>
/// Represents a South African Identity Number.
/// valid number = 7707215230080

[code].....

View 3 Replies

Using JQuery $.ajax To Pass String Value?

Mar 12, 2010

I'm using ASP.NET and attempting to call a method with a signature of

[WebMethod]
public static string GetInfo(string id){...}


using the following javascript:

var elementValue = $("#element").attr('id');

[code]...

And this is not working.If instead I set elementValue = 2; it works fine. If I try to hardcode in a string value for testing purposes e.g. elementValue = "nameToLookUp"; It fails.Why is this happening, and how do I resolve it?On a side not, why is type: required to be POST instead of a GET? In the end I just want to pass a string value I want to look up in a DB and retrieving some json data.

View 2 Replies

Pass A Variable To HTML Via Iframe?

Aug 23, 2010

I don't know if this is even possible, but here goes: I have an ASP.NET page that contains an IFrame that calls an HTML page. Is it possible to pass a variable from the ASP.NET page to the HTML within the IFrame? More specifically, I'd like for the ASP.NET page to fill in one of the fields on the form within the HTML page.

View 2 Replies

MVC :: How To Pass Html.TextBox To Controller

Jan 14, 2010

I've a controller with different actions that calls the DB code and return result. I want to pass the value of text box to different actions in controller.

How to do it? I know that, I can pass values by using form. But, I don't to know how to call different actions in controller from single view.

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved