Creare un documento PDF con asp NET senza salvarlo SUL SERVER.. il file PDF viene reso scaricabile (o stampabile, senza che poi risieda su alcuna root del server..): "attachment" - servito come HTTP
l' utilizzo è di assoluta facilità: copia inclolla e salva come *.aspx
CODICE:
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="ASPPDFLib" %>
<%@ Page aspCompat="True" %>
<script runat="server" LANGUAGE="C#">
void Page_Load(Object Source, EventArgs E)
{
IPdfManager objPdf = new PdfManager();
// Create empty document
IPdfDocument objDoc = objPdf.CreateDocument(Missing.Value);
// Set various document properties
objDoc.Title = "TITOLO NUOVO DOCUMENTO PDF ";
objDoc.Creator = "AUTORE";
// Add a new page
IPdfPage objPage = objDoc.Pages.Add(Missing.Value, Missing.Value, Missing.Value);
// Select one of the standard PDF fonts
IPdfFont objFont = objDoc.Fonts["Helvetica", Missing.Value];
// Param string
String strParams = "x=0; y=650; width=612; alignment=center; size=50";
// Draw text on page
objPage.Canvas.DrawText( "CONTENUTO DEL DOCUMENTO ", strParams, objFont );
// Save document to HTTP stream
objDoc.SaveHttp( "attachment;filename=hello_net.pdf", Missing.Value );
}
</script>
|