Home   
   Domini   
   Siti   
   Indicizzazione   
   Contatto   
   Specials   
   Games   

 


 
Grafica 3D in PDF con ASP Grafica 3D in PDF con ASP NET Convertire JPEG in PDF con ASP Convertire JPEG in PDF con ASP NET Creare PDF con ASP Proprietà PDF a nuovo PDF Creare PDF con ASP via HTTP Aggiungere commento a PDF con ASP
Creare PDF con Form via ASP Gestire PDF via ASP Aggiungere grafica a PDF con ASP HTML da file TXT via ASP Importare da URL in PDF con ASP PDF Bookmark con ASP Da PDF in JPEG via ASP Lettura MDB con PDF via ASP
Moduli PDF via ASP Creare PDF con ASP NET Creare PDF con ASP NET via HTTP Aggiungere commento a PDF con ASP NET Creare PDF con Form via ASP NET Gestire PDF via ASP NET HTML da file TXT via ASP NET Importare da URL in PDF con ASP NET
Maschera PDF con ASP NET Creare PDF con ASP NET e MDB Da PDF a PNG via ASP NET Estrarre testo da PDF via ASP NET Unire documenti PDF via ASP NET Da PDF a PNG via ASP Estrarre testo da PDF via ASP Unire documenti PDF via ASP
Inserire commento in PDF Maschera PDF con ASP PDF Bookmark con ASP NET Convertire TIFF in PDF con ASP Compilare PDF con Form via ASP Creare PDF con ASP e MDB Lettura MDB con PDF via ASP NET Convertire TIFF in PDF con ASP NET

Generare PDF da codice HTML contenuto in file di testo [*.TXT] attraverso asp NET

nota bene: lo script nella versione "copia e incolla" che segue, presuppone permessi di scrittura lato server .. in paritcolare, è la root o cartella di destinazione del nuovo documento PDF che deve possedere i permessi di scrittura [chmod "666" - "777"] ..e l' utilizzo è di assoluta facilità: copia inclolla e salva come *.aspx
RICHIEDE FILE TXT

CODICE:

<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="ASPPDFLib" %>

<script runat="server" LANGUAGE="C#">

void Page_Load(Object Source, EventArgs E)
{
// create instance of the PDF manager
IPdfManager objPDF = new PdfManager();

// Create new document
IPdfDocument objDoc = objPDF.CreateDocument(Missing.Value);

// Add a page to document. Pages are intentionally small to demonstrate text spanning
IPdfPage objPage = objDoc.Pages.Add(300, 300, Missing.Value);

// use Arial font
IPdfFont objFont = objDoc.Fonts["Arial", Missing.Value];

String strText = objPDF.LoadTextFromFile( Server.MapPath("html.txt") );

// Parameters: X, Y of upper-left corner of text box, Height, Width
IPdfParam objParam = objPDF.CreateParam("x=10; y=290; width=280; height=280; html=true");

while( strText.Length > 0 )
{
// DrawText returns the number of characters that fit in the box allocated.
int nCharsPrinted = objPage.Canvas.DrawText( strText, objParam, objFont );

// HTML tag generated by DrawText to reflect current font state
String strHtmlTag = objPage.Canvas.HtmlTag;

// The entire string printed? Exit loop.
if( nCharsPrinted == strText.Length )
break;

// Otherwise print remaining text on next page
objPage = objPage.NextPage;

strText = strHtmlTag + strText.Substring( nCharsPrinted );
}

// Save document, the Save method returns generated file name
String strFilename = objDoc.Save( Server.MapPath("/public/html-from-net.pdf"), false );

lblResult.Text = "fatto, con NET. Vai <A HREF=/public/" + strFilename + ">qui</A>";
}

</script>

<HTML>
<HEAD>
<TITLE>TITOLO DOCUMENTO</TITLE>
</HEAD>
<BODY>

<form runat="server">
<ASP:Label ID="lblResult" runat="server"/>
</form>

</BODY>
</HTML>

 





fonte accreditata aruba.it