Hi Folks,
The following PowerShell code works on converting me a img (jpg,png, etc) to a PDF
Code:
[reflection.assembly]::loadfrom("C:\assemblies\PdfSharp.dll ") | out-null
Function Img2PDF {
Param($img, $pdf)
# Create a new PDF document
$document = new-object PdfSharp.Pdf.PdfDocument
# Create an empty page
$page = $document.AddPage()
$page.Orientation
# Get an XGraphics object for drawing
$gfx = [PdfSharp.Drawing.XGraphics]::FromPdfPage($page)
#$image = New-Object PdfSharp.Drawing.XImage
$image = [PdfSharp.Drawing.XImage]::FromFile($img)
$gfx.DrawImage($image, 0, 0, $page.Width, $page.Height)
# Save the document...
$document.Save($pdf)
}
Img2PDF -img c:\test\123.png -pdf c:\test\test123.pdf
I cant seem to figure out the last part on how to get the page to landscape. I have looked at the PDFSharp Page Sizes example but cant seem to get it to work. In the above "$page.Orientation" will print out "Portrait" (ie its working) but I want to set the page to Landscape.
Thoughts?
~dpc