Pagina 1 di 4 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 32

Discussione: PDF da pagina ASP

  1. #1

    PDF da pagina ASP

    Buongiorno,
    avrei questa necessità:

    ho una pagina asp in cui posso effettuare ricerche ne mio db in base ad un intervallo di date.

    Vorrei aggiungere un pulsante che permetta all'utente di avere i risultati ottenuti dalla ricerca in PDF.

    Mi potete aiutare?

    Grazie

    Roberto

  2. #2

  3. #3
    Hosting Windows su Aruba

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,563
    Puoi usare il componente Persits ASPPDF, leggi la documentazione.

    Roby

  5. #5
    mi puio idicare qualche documento?

  6. #6

  7. #7
    Scusa ma avevo cercato su questo sito.

    Grazie mille.

    Come sempre bravissimi!!!!!

  8. #8
    Ciao,
    solo oggi riprendo in mano il lavoro.

    Ho visto quanto suggerito da Roby_72.


    http://vademecum.aruba.it/start/Persits/index.asp

    a me interessa creare pdf da url e nei vari esempi c'è questo:

    <%

    Set Pdf = Server.CreateObject("Persits.Pdf")

    ' Create empty document
    Set Doc = Pdf.CreateDocument


    ' Set various document properties
    Doc.Title = "AspPDF creato al volo e servito con attachment"
    Doc.Creator = "John Smith"

    ' Add a new page
    Set Page = Doc.Pages.Add

    ' Select one of the standard PDF fonts
    Set Font = Doc.Fonts("Helvetica")

    ' Param string
    Params = "x=0; y=650; width=612; alignment=center; size=50"

    ' Draw text on page
    Page.Canvas.DrawText "AspPDF creato al volo e servito con attachment!", Params, Font

    ' Save to HTTP stream
    Doc.SaveHttp "attachment;filename=hello.pdf"
    %>

    ora passo alle domande:
    1- dove inserisco l'url della mia pagina da stampare in pdf?
    2- dalla mia pagina creo un link a questa o inserisco il codice nella mia?

    Grazie in anticipo!!
    Roberto

  9. #9
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,563
    Con questo script crei un PDF al volo e ci scrivi tu dentro...
    Quello che invece vuoi fare tu è un'altra cosa, trovalo nella documentazione.

    Roby

  10. #10
    Si scusa ho fatto un pò di confusione!

    comunque la soluzione migliore potrebbe essere quella di leggere i dati direttamente da DB, poichè la pagina che dovrei trasfomare in PDF è il risultato di una ricerca per intervallo di date da una tabella.

    Quello che persits propone è:

    <HTML>
    <HEAD>
    <TITLE>AspPDF - legge contenuto da database, in asp</TITLE>
    </HEAD>
    <BODY>

    <h3>leggo contenuto da database, in asp</h3>
    <%
    Set PDF = Server.CreateObject("Persits.Pdf")

    ' Create empty param objects to be used across the app
    Set Param = PDF.CreateParam
    Set TextParam = PDF.CreateParam

    ' Create document
    Set Doc = PDF.CreateDocument

    ' Create table with one row (header), and 5 columns
    Set Table = Doc.CreateTable("width=500; height=20; Rows=1; Cols=5; Border=1; CellSpacing=-1; cellpadding=2 ")

    ' Set default table font
    Table.Font = Doc.Fonts("Helvetica")

    Set HeaderRow = Table.Rows(1)
    Param.Set("alignment=center")
    With HeaderRow
    .BGColor = &H90F0FE
    .Cells(1).AddText "Category", Param
    .Cells(2).AddText "Description", Param
    .Cells(3).AddText "Billable", Param
    .Cells(4).AddText "Date", Param
    .Cells(5).AddText "Amount", Param
    End With

    ' Set column widths
    With Table.Rows(1)
    .Cells(1).Width = 80
    .Cells(2).Width = 160
    .Cells(3).Width = 50
    .Cells(4).Width = 70
    .Cells(5).Width = 60
    End With


    ' Populate table with data
    Set Conn = Server.CreateObject("ADODB.Connection")
    Connect = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/mdb-database/asppdf.mdb")
    Conn.Open Connect

    Set rs = Server.CreateObject("adodb.recordset")
    rs.Open "select * from report order by expensedate", Conn

    param.Set "expand=true" ' expand cell vertically to accomodate text

    Do While Not rs.EOF
    Set Row = Table.Rows.Add(20) ' row height

    param.Add "alignment=left"
    Row.Cells(1).AddText rs("Category"), param
    Row.Cells(2).AddText rs("Description"), param

    param.Add "alignment=center"
    If rs("Billable") Then Billable = "Yes" Else Billable = "No"
    Row.Cells(3).AddText Billable, param
    Row.Cells(4).AddText pdf.FormatDate( rs("ExpenseDate"), "%d %b %Y" ), param

    param.Add "alignment=right"
    Row.Cells(5).AddText pdf.FormatNumber(rs("Amount"), "precision=2, delimiter=true"), param

    rs.MoveNext
    Loop

    ' Render table on document
    Set Page = Doc.Pages.Add(612, 150) ' small pages to demonstrate paging functionality

    Param.Clear
    Param("x") = (Page.Width - Table.Width) / 2 ' center table on page
    Param("y") = Page.Height - 20
    Param("MaxHeight") = 100

    FirstRow = 2 ' use this to print record count on page
    Do While True
    ' Draw table. This method returns last visible row index
    LastRow = Page.Canvas.DrawTable( Table, Param )

    ' Print record numbers
    TextParam("x") = (Page.Width - Table.Width) / 2
    TextParam("y") = Page.Height - 5
    TextParam.Add("color=darkgreen")
    TextStr = "Records " & FirstRow - 1 & " to " & LastRow - 1 & " of " & Table.Rows.Count - 1
    Page.Canvas.DrawText TextStr, TextParam, doc.fonts("Courier-Bold")

    if LastRow >= Table.Rows.Count Then Exit Do ' entire table displayed

    ' Display remaining part of table on the next page
    Set Page = Page.NextPage
    Param.Add( "RowTo=1; RowFrom=1" ) ' Row 1 is header - must always be present.
    Param("RowFrom1") = LastRow + 1 ' RowTo1 is omitted and presumed infinite

    FirstRow = LastRow + 1
    Loop

    ' Save document, the Save method returns generated file name
    Filename = Doc.Save( Server.MapPath("/public/report-db_Asp.pdf"), False )

    Response.Write "Fatto, scarica il file <A HREF=/public/" & Filename & ">qui</A>"

    %>

    </BODY>
    </HTML>

    Secondo te è personalizzabile? cioè, è fattibile fargli leggere i dati dalla mia tabella?

    Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.