Export single page per VBNet

This Forum is for the use of End Users requiring help and assistance for Tracker Software's PDF-Tools.

Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - Tracker, Stefan - PDF-XChange

Post Reply
Nimrod_189
User
Posts: 49
Joined: Wed Sep 23, 2009 8:39 am

Export single page per VBNet

Post by Nimrod_189 »

Hi guys,

is it possible to use the PDF tools to export one or more pages from a PDF file to a new file via command line?

I need this function for my private VBNet program.

Thank you very much.

Nimrod_189
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10158
Joined: Wed Jan 03, 2018 6:52 pm

Re: Export single page per VBNet

Post by Daniel - PDF-XChange »

Hello, Nimrod_189

While it would be possible to create a custom tool via PDF-Tools and call it, most settings, including the page numbers to be used for Insert/extract pages cannot be modified directly via CMD.

You can find a complete list of available PDF-tools CMD actions here: https://help.pdf-xchange.com/pdfxt10/co ... ons_t.html

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Nimrod_189
User
Posts: 49
Joined: Wed Sep 23, 2009 8:39 am

Re: Export single page per VBNet

Post by Nimrod_189 »

Hello Daniel,

I solved my problem using the commandline tool "pdftk". I've worked with it before and it's still great. :D

Here's my solution for VBNet:

Code: Select all

   Sub ExtractPDFPages(sTargetPath As String, sSourcePDF As String, sDestFileName As String, listPages As List(Of String))
        Dim strParam As String = ""
        Dim PDFtk As String = ""
        Dim tmpFile As String = System.IO.Path.Combine(sTargetPath, "Input.pdf")

        Call CleanPath(sTargetPath)

        PDFtk = My.Settings.PDFtk & " "        '<<===== E:\Programmtools\PDFtk Server\bin\pdftk.exe
        System.IO.File.Copy(sSourcePDF, tmpFile)

        sSourcePDF = tmpFile
        Dim p As New Process

        For i As Integer = 0 To listPages.Count - 1
            strParam += listPages(i) & " "      '<<=== einzelne Seiten einfach mit Leerzeichen trennen
        Next

        strParam = sSourcePDF & " cat " & strParam.Trim & " output " & Path.Combine(sTargetPath, sDestFileName)
        p.StartInfo.FileName = PDFtk
        p.StartInfo.Arguments = strParam
        p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
        p.Start()
        p.WaitForExit()
        p.Close()

    End Sub
Or as Batchfile for example "CatPDF.bat":

Code: Select all

"E:\Programmtools\PDFtk Server\bin\pdftk.exe" "input.pdf" cat 2 3 output "Output.pdf"
Nimrod_189
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10158
Joined: Wed Jan 03, 2018 6:52 pm

Re: Export single page per VBNet

Post by Daniel - PDF-XChange »

Hello, Nimrod_189

Glad to hear you have found a solution. I wish I could say we plan to offer the same, but at this time it does not seem likely.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Nimrod_189
User
Posts: 49
Joined: Wed Sep 23, 2009 8:39 am

Re: Export single page per VBNet

Post by Nimrod_189 »

That's really sad to hear, because I would like to do everything with one tool. I do use the IText framework in VBNet sometimes, but it's very complicated. So sometimes I need the easier way.

But whatever, the goal is the way.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10158
Joined: Wed Jan 03, 2018 6:52 pm

Re: Export single page per VBNet

Post by Daniel - PDF-XChange »

Hello, Nimrod_189

Well, we can keep our fingers crossed at least, who knows what the future may bring. things ive said are unlikely have happened before (And I do hope they keep happening).

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Nimrod_189
User
Posts: 49
Joined: Wed Sep 23, 2009 8:39 am

Re: Export single page per VBNet

Post by Nimrod_189 »

:D
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2147
Joined: Mon Jan 15, 2018 9:01 am

Export single page per VBNet

Post by Dimitar - PDF-XChange »

:)
Post Reply