VintaSoft PDF .NET Plug-in Discussions
Questions, comments and suggestions concerning VintaSoft PDF .NET Plug-in.
Board index < VintaSoft Imaging < VintaSoft PDF .NET Plug-in Discussions
Private imageViewer1 As Vintasoft.Imaging.ImageViewer
Private _fileStream As System.IO.Stream = Nothing
Private _document As Vintasoft.Pdf.PdfDocument
Private _useEmbeddedThumbnails As Boolean = True
Private _titlePrefix As String = "VintaSoft PDF Reader Demo v3.1 {0}"
Private _isFirstOpenedPage As Boolean = False
_fileStream = New System.IO.FileStream(strArchivoPDF, System.IO.FileMode.Open, System.IO.FileAccess.Read)
_document = Vintasoft.Pdf.PdfDocumentController.OpenDocument(_fileStream)
_document.RenderingSettings.DrawPdfAnnotations = True
_document.RenderingSettings.DrawVintasoftAnnotations = True
_document.RenderingSettings.UseEmbeddedThumbnails = _useEmbeddedThumbnails
_fileStream.Position = 0
Dim openFileThread As New System.Threading.Thread(AddressOf OpenFileAsynchronously)
openFileThread.Start()
_isFirstOpenedPage = True
Text = String.Format(_titlePrefix, String.Format("- {0}", System.IO.Path.GetFileName(strArchivoPDF)))
If _document.IsEncrypted Then
Text += " (SECURED)"
End If
' #############################
' Let's go to generate JPG's...
' #############################
firstPage = 1
lastPage = _document.Pages.Count
For pageNo = 1 To _document.Pages.Count
strNombreArchivoJPG = "PAG_" & Format(pageNo, "000") & ".jpg"
.../...
Next
We have been reviewing the help, not just find a way to do this easily, without being as complicated as the example.Imports System.IO
Imports Vintasoft.Imaging
Imports Vintasoft.Imaging.Codecs
Module Module1
Sub Main()
SavePdfPagesAsJpeg("d:\PdfTest.pdf", "d:\jpegDir\")
End Sub
Public Sub SavePdfPagesAsJpeg(ByVal pdfFileName As String, ByVal jpegDir As String)
' create image collection
Dim imageCollection As New ImageCollection()
' add PDF document to collection
imageCollection.Add(pdfFileName)
' create JpegEncoder
Dim jpegEncoder1 As New JpegEncoder()
' set quality of output JPEG files
jpegEncoder1.Settings.Quality = 90
' save images of image collection to TIFF file using TiffEncoder
Dim vsImage as VintasoftImage
For i As Integer = 0 To imageCollection.Count - 1
' get image of PDF page as VintasoftImage object
vsImage = imageCollection(i)
' save VintasoftImage object as JPEG file
vsImage.Save(Path.Combine(jpegDir, String.Format("page{0}.jpg", i)), jpegEncoder1)
Next
' free resources
jpegEncoder1.Dispose()
imageCollection.Dispose()
End Sub
End Module
Best regards, Alexander
Imports System.IO
Imports Vintasoft.Imaging
Imports Vintasoft.Pdf
Module Module1
Sub Main()
SavePdfPagesAsJpeg("d:\PdfTest.pdf", "d:\jpegDir\")
End Sub
Public Sub SavePdfPagesAsJpeg(ByVal pdfFileName As String, ByVal jpegDir As String)
' open existing PDF document
Dim pdfDocument As New PdfDocument(pdfFileName)
' for each PDF page
For i As Integer = 0 To pdfDocument.Pages.Count - 1
' get image of PDF page as VintasoftImage object
Using vsImage As VintasoftImage = pdfDocument.Pages(i).Render()
' save VintasoftImage object as JPEG file
vsImage.Save(Path.Combine(jpegDir, String.Format("page{0}.jpg", i)))
End Using
Next
' free resources
pdfDocument.Dispose()
End Sub
End Module
Best regards, Alexander
Imports System.IO
Imports Vintasoft.Imaging
Imports Vintasoft.Pdf
Imports Vintasoft.Imaging.Codecs
Module Module1
Sub Main()
SavePdfPagesAsJpeg("d:\PdfTest.pdf", "d:\jpegDir\")
End Sub
Public Sub SavePdfPagesAsJpeg(ByVal pdfFileName As String, ByVal jpegDir As String)
' open existing PDF document
Dim pdfDocument As New PdfDocument(pdfFileName)
Dim JPEGencoder As New JpegEncoder()
JPEGencoder.Settings.Quality = 90
JPEGencoder.Settings.SaveAsGrayscale = False
' for each PDF page
For i As Integer = 0 To pdfDocument.Pages.Count - 1
' get image of PDF page as VintasoftImage object
Using vsImage As VintasoftImage = pdfDocument.Pages(i).Render()
' save VintasoftImage object as JPEG file
vsImage.Save(Path.Combine(jpegDir, String.Format("page{0}.jpg", i)), JPEGencoder)
End Using
Next
' free resources
pdfDocument.Dispose()
End Sub
End Module
This works fine, but.. How to set DPI to 150, for example ?How to set DPI to 150, for example ?You need change the rendering settings of PDF document if you want to render PDF pages with custom settings.
... Dim pdfDocument As New PdfDocument(pdfFileName) pdfDocument.RenderingSettings.Resolution = New Resolution(150, 150) ...Best regards, Alexander