Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
In below this coding string contain html code
how to use string value into HtmlTextWriter or StringWriter

string HtmlContent = "";
HtmlContent = "<html><body>RAJKUMAR</body></html>";
where i can include HtmlContent below this code

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);

StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
Posted
Comments
virusstorm 19-May-15 12:08pm    
What library are using to create a PDF document?
Rajkumar RRRS 20-May-15 1:35am    
iTextSharp
Sergey Alexandrovich Kryukov 9-Sep-15 9:35am    
What's the problem?
—SA

1 solution

Sorry for not answering your present question, because I don't understand what's your problem. First of all, you should understand that it cannot be a "conversion" to PDF, but only a "snapshot" of one particular instance of HTML rendering. The concepts of PDF and HTML are very different: HTML is fluid and flexible, responds to user input, and PDF has fixed rendering, is more of a kind of electronic paper.

Now, I answered your last (at the moment of writing question) which has been removed by some abuse reports, with my answer which I happened to post. In fact, your "abuse" was merely the failure to do the Web search and figure out that GSP in not the topic relevant to JavaScript embedded in a general-purpose Web browser. I also reported the question but later realized that it wasn't fair. So, the answer is lost, but I hope it can be helpful for you. So, let me post it here, even though it violates the site's rules.
In the last (auto-removed) question, Rajkumar ilamaraja asked:
Track the latitude and longitude for a vehicle using GPS
See more: ASP.NET jQuery

i want to get latitude and longitude from my trucks based GPS,
In my application i want to show inside the google map to point the truck latitude and longitude
But i don't where to start the application, just i have the user details only. Based on the user, to show user vehicle's where it's moving
First of all, What kind of inputs needed for this task.

This was my answer:
JavaScript embedded in a browser (and, if your "jQuery" tag is relevant, this is what you are working with) in has limited access to local system, which is set for security. You can process input only from standardized input devices, such as keyboard and mouse/touchpad. You cannot use anything which is not standardized by the W3 committee.

However, the set of standard input devices and method tends to quickly grow, driven by the quick expansion of the unit equipped with newer devices, which includes media input (audio and video), the use of biometric devices, accelerometers, gyroscopes, and, of course, GSP. Please see:
http://dev.w3.org/geo/api/spec-source.html[^].

As you can see, this is just the draft for the specification, but many new standards get implemented in some major browsers before the establishment of formal standards.

In other words, you have to for the browsers implementing new input methods. I don't even want to discuss platform-specific approaches such as using ActiveX components in JavaScript, which is also considered to be utterly unsafe, so it may cause security-savvy users deny using your products and site.

Note that you can possibly expect the possibility to use GSP in JavaScript for more specialized software hosting JavaScript engine (example: Chrome OS). But your question suggests that you mean the use of general-purpose Web browsers.
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900