Oppure

Loading
07/06/10 14:30
Ciao a tutti!

Alla fine del post trovate il codice che utilizzo per stampare
tramite la stampante virtuale di PDF Creator, un file jpg
(utilizzo questo metodo perchè per il momento è l'unico che conosco
per poter convertire una pagina pdf in jpg).

Il problema di questo codice è il seguente :

PDF Creator stampa in jpg 1 pagina alla volta, quindi
se stampo un pdf da 10 pagine lui stamperà sempre e solo la prima
pagina....

Come potrei dare in pasto a pdf una determinata pagina del pdf?

Grazie

Private Sub PrintIt(ByVal Filetyp As Long)
        Dim fname As String, fi As FileInfo, DefaultPrinter As String
        Dim opt As PDFCreator.clsPDFCreatorOptions
        Dim test As PDFCreator.clsUpdate
        fi = New FileInfo(OpenFileDialog1.FileName)
        If fi.Name.Length > 0 Then
            If InStr(fi.Name, ".", CompareMethod.Text) > 1 Then
                fname = Mid(fi.Name, 1, InStr(fi.Name, ".", CompareMethod.Text) - 1)
            Else
                fname = fi.Name
            End If
        End If

        If Not _PDFCreator.cIsPrintable(fi.FullName) Then
            MsgBox("File '" & fi.FullName & "' is not printable!", MsgBoxStyle.Exclamation, Me.Text)
            Exit Sub
        End If
        opt = _PDFCreator.cOptions
        With opt
            .UseAutosave = 1
            .UseAutosaveDirectory = 1
            .AutosaveDirectory = fi.DirectoryName
            .AutosaveFormat = 2
            .JPEGQuality = 100
            .JPEGResolution = 150
            opt.AutosaveFilename = fname
        End With
        With _PDFCreator
            .cOptions = opt
            .cClearCache()
            DefaultPrinter = .cDefaultPrinter
            .cDefaultPrinter = "PDFCreator"
            .cPrintFile(fi.FullName)
            ReadyState = False
            .cPrinterStop = False
        End With

        With Timer1
            .Interval = maxTime * 1000
            .Enabled = True
            Do While Not ReadyState And .Enabled
                Application.DoEvents()
            Loop
            .Enabled = False
        End With
        If Not ReadyState Then
            MsgBox("Creating printer test page as pdf." & vbCrLf & vbCrLf & _
             "An error is occured: Time is up!", MsgBoxStyle.Exclamation, Me.Text)
        End If
        _PDFCreator.cPrinterStop = True
        _PDFCreator.cDefaultPrinter = DefaultPrinter
        opt = Nothing
    End Sub