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!
How to use Quick PDF Library with PowerShell |
Post Reply |
Author | |
Stefan Schnell
Beginner Joined: 18 Jun 15 Location: Germany - Oberi Status: Offline Points: 8 |
Post Options
Thanks(0)
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------------------------------------------------------------------- |
|
mLipok
Senior Member Joined: 23 Apr 14 Location: Poland, Zabrze Status: Offline Points: 453 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store