1 messaggio dal 30 giugno 2005
salve, premetto che da anni ormai non programmo più quindi visual studio mi risulta molto ostico anche se ha delle potenzialità enormi.
con questo codice riempio i due campi sul mio pdf. fin qui tutto è funzionante! Ora nel mio documento ho anche un campo immagine che vorrei riempire ma proprio non riesco a capire dove iniziare.

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports iTextSharp
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports iTextSharp.text.xml
Imports System.IO
Public Class WebForm1
    Inherits System.Web.UI.Page

    Private Sub ListFieldNames()

        Dim pdfTemplate As String = "C:\origine.pdf"

        ' create a new PDF reader based on the PDF template document
        Dim pdfReader As PdfReader = New PdfReader(pdfTemplate)

        ' create and populate a string builder with each of the 
        ' field names available in the subject PDF
        Dim sb As New StringBuilder()

        Dim de As New DictionaryEntry
        For Each de In pdfReader.AcroFields.Fields
            sb.Append(de.Key.ToString() + Environment.NewLine)
        Next

    End Sub




    Private Sub FillForm()

        Dim pdfTemplate As String = "C:\origine.pdf"
        Dim newFile As String = "C:\Finale.pdf"

        Dim pdfReader As New PdfReader(pdfTemplate)
        Dim pdfStamper As New PdfStamper(pdfReader, New FileStream(
                    newFile, FileMode.Create))

        Dim pdfFormFields As AcroFields = pdfStamper.AcroFields

        ' set form pdfFormFields

        ' The first worksheet and W-4 form
        pdfFormFields.SetField("nome", "Marco")
        pdfFormFields.SetField("numero", "12456")
        
        '*******************************************************************  
        'QUESTA RIGA PROPRIO NON VA
        'pdfFormFields.SetField("firma", "C:\firma.png")
        '********************************************************************
        pdfStamper.FormFlattening = True

        ' close the pdf
        pdfStamper.Close()

    End Sub

    Private Sub WebForm1_LoadComplete(sender As Object, e As EventArgs) Handles Me.LoadComplete
        ' Load all field names from template PDF
        ListFieldNames()

        ' Fill the target PDF form with canned values
        FillForm()

    End Sub
End Class

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.