15,905,148 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by j053pepe (Top 1 by date)
j053pepe
29-Nov-16 12:20pm
View
hi, i have other example, show your pdf in new page or div.
/// Call my html and send Id of document
function AbrirArchivo(DocumentoId) {
var url =
"/../WebServices/WS/Beca.asmx/GenerarPDF2?DocumentoId=" + DocumentoId;
var archiv = window;
archiv.open("../Inscritos/Archivos/Archivo.html", "PDF");
archiv.Ruta = url;
}
/*in my Archivo.html i have this code */
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Documento
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta content="" name="description" />
<meta content="" name="author" />
<meta http-equiv="pragma" content="no-cache" />
html, body {
margin: 0;
padding: 0;
border: 0;
height: 100%;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: 0;
}
$(document).ready(function () {
var Ruta = window.opener.Ruta;
crarPDF();
function crarPDF() {
$('#iframepdf').attr('src', Ruta);
}
});
/* end file */
in my asmx i have function
[WebMethod]
public void GenerarPDF2(string DocumentoId)
{
Stream stream = new MemoryStream(BLLAlumnoInscrito.TraerDocumento(int.Parse(DocumentoId)));
var MemoryStream = new MemoryStream();
stream.CopyTo(MemoryStream);
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" + "Beca" + ".pdf");
HttpContext.Current.Response.BinaryWrite(MemoryStream.ToArray());
HttpContext.Current.Response.Flush();
MemoryStream.Close();
HttpContext.Current.Response.End();
}