Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > Sample Code
  New Posts New Posts RSS Feed - How to use Quick PDF Library with PowerShell
  FAQ FAQ  Forum Search   Register Register  Login Login

How to use Quick PDF Library with PowerShell

 Post Reply Post Reply
Author
Message
Stefan Schnell View Drop Down
Beginner
Beginner
Avatar

Joined: 18 Jun 15
Location: Germany - Oberi
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Stefan Schnell Quote  Post ReplyReply Direct Link To This Post Topic: How to use Quick PDF Library with PowerShell
    Posted: 29 Sep 15 at 5:36AM
Hello community,

here a sample code how to use Quick PDF ActiveX Library Lite inside PowerShell. It is only necessary to build an interoperability library via type library importer of the .NET SDK.

Enjoy it.

Cheers
Stefan

#-Begin-----------------------------------------------------------------
#-
#- PDF document creator
#-
#- Important hint: To use the ActiveX library it is necessary to build
#- an interoperability library via type library importer TlbImp.exe.
#-
#- Author: Stefan Schnell
#-
#-----------------------------------------------------------------------

  #-Constants-----------------------------------------------------------
    $PDFMillimetres = 1
    $PDFInches = 2

    $PDFAlignmentCenter = 0
    $PDFAlignmentTop = 1
    $PDFAlignmentBottom = 2

  #-Variables-----------------------------------------------------------
    $Text  = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
    $Text += "sed diam nonumy eirmod tempor invidunt ut labore et dolor"
    $Text += "e magna aliquyam erat, sed diam voluptua. At vero eos et "
    $Text += "accusam et justo duo dolores et ea rebum. Stet clita kasd"
    $Text += " gubergren, no sea takimata sanctus est Lorem ipsum dolor"
    $Text += " sit amet. Lorem ipsum dolor sit amet, consetetur sadipsc"
    $Text += "ing elitr, sed diam nonumy eirmod tempor invidunt ut labo"
    $Text += "re et dolore magna aliquyam erat, sed diam voluptua. At v"
    $Text += "ero eos et accusam et justo duo dolores et ea rebum. Stet"
    $Text += " clita kasd gubergren, no sea takimata sanctus est Lorem "
    $Text += "ipsum dolor sit amet."

  #-Sub CreatePDFDoc----------------------------------------------------
  #-
  #- Creates PDF documents automatically, with different count of
  #- pages and optional with a picture
  #-
  #---------------------------------------------------------------------
    Function Create-PDFDoc($cntPages, $PictureName) {

      If ($PictureName -eq $Null) {
        $WithPicture = $False
      }
      Else {
        $WithPicture = $True
        $PicName = $PSScriptRoot + "\" + $PictureName
      }

      $Path = $PSScriptRoot
      [Reflection.Assembly]::LoadFile($Path + 
        "\DebenuPDFLibraryLite1114.Interop.dll") > $Null

      $PDF = New-Object DebenuPDFLibraryLite1114.Interop.PDFLibraryClass
      $PDF.SetPageSize("A4") > $Null
      $PDF.SetMeasurementUnits($PDFMillimetres) > $Null

      For ($i = 1; $i -le $cntPages; $i++) {

        $PDF.DrawTextBox(10, 287, 190, 100, $Text, $PDFAlignmentTop) > $Null

        If ($WithPicture -eq $True) {
          $PDF.AddImageFromFile($PicName, 0) > $Null
          $ImgWidth = $PDF.ImageWidth() / 2
          $ImgHeight = $PDF.ImageHeight() / 2
          $PDF.DrawImage(10, 187, $ImgWidth, $ImgHeight) > $Null
        }

        If ($i -lt $cntPages) {
          $PDF.NewPage() > $Null
        }

      }

      $GUID = [GUID]::NewGuid()
      $FileName = $env:USERPROFILE + "\Documents\" + $GUID + ".pdf"
      $PDF.SaveToFile($FileName) > $Null

    }

  #-Sub Main------------------------------------------------------------
    Function Main() {

      Create-PDFDoc 10 "Gonzo.jpg"

    }

  #-Main----------------------------------------------------------------
    Main

#-End-------------------------------------------------------------------
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 29 Sep 15 at 7:56PM
Hello Stefan
Look at my AutoIt UDF for Debenu QuickPDF
https://www.autoitscript.com/forum/files/file/342-debenu-quick-pdf-library-udf/

I think it will be usefull for Powershell users.
As it is very easy to convert functions.

Best regards,
mLipok
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store