PDF first page as picture

Posted by: bernd.havla on 5 December 2017, 6:18 am EST

    • Post Options:
    • Link

    Posted 5 December 2017, 6:18 am EST

    Hello,

    Over C1.Win.C1Document.Export.ExportProvider.PngExportProvider.NewExporter i’m

    able to Export each page of the PDF-file as a single Picture (C1.Win.C1Document.C1PdfDocumentSource).

    But if the PDF-file contains n-Count of pages the exporter gererates n-Count of Pictures…

    My question: Is there a way to get a Picture only from the first page of a PDF-file?

    thanks!

    
     Public Sub PDFToPNgConverter_Test()
            Dim inputDirectory As String = "C:\PDF\"
            Dim files As String() = IO.Directory.GetFiles(inputDirectory, "*.pdf")
            For Each filePath As String In files
                Dim startIdx As Integer = filePath.LastIndexOf("\")
                Dim endIdx As Integer = filePath.LastIndexOf(".")
                Dim docName As String = filePath.Substring(startIdx + 1, endIdx - startIdx - 1)
                Dim exporter = C1.Win.C1Document.Export.ExportProvider.PngExportProvider.NewExporter
                exporter.FileName = "C:\PDF\PDFtoPNG" & docName & ".png"
                Dim pdf As C1.Win.C1Document.C1PdfDocumentSource = New C1.Win.C1Document.C1PdfDocumentSource
                pdf.LoadFromFile("C:\PDF\" & docName & ".pdf") '   Dokumentenname & "_page'n'.png" !
                pdf.Export(exporter) 'creates a png for each page, we only need the first page ! How to?
            Next
        End Sub
    
    
  • Posted 5 December 2017, 9:20 am EST

    Hi,

    You can use the exporter.Range property to export only desired pages. Please see the attached sample project explaining the same.

    Thanks,

    +Manindra

    VBExportPdfFirstPage.zip

  • Posted 5 December 2017, 10:24 am EST

    Hi Manindra!

    Thanks a lot! It works fine!

    THX !!!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels