PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
New-PDF with Powershell https://forum.pdfsharp.net/viewtopic.php?f=2&t=1816 |
Page 1 of 1 |
Author: | jbruns2011 [ Wed Oct 12, 2011 5:16 pm ] |
Post subject: | New-PDF with Powershell |
Using example New-PDF.ps1 written by your group and was wondering how to tell the code to allow data that has carriage return, line feeds? If I supply a variable to it as is, it renders the PDF unreadable. |
Author: | Thomas Hoevel [ Thu Oct 13, 2011 7:12 am ] |
Post subject: | Re: New-PDF with Powershell |
jbruns2011 wrote: Using example New-PDF.ps1 written by your group [...] Sorry, but AFAIK this example is not from our team.Where did you find it so we can have a look? |
Author: | Thomas Hoevel [ Thu Oct 13, 2011 1:16 pm ] |
Post subject: | Re: New-PDF with Powershell |
I found the sample on the web. It uses DrawString to draw a string. Use XTextFormatter for text that spans several lines. |
Author: | jbruns2011 [ Thu Oct 13, 2011 2:29 pm ] |
Post subject: | Re: New-PDF with Powershell |
Hate to be a prick, got any samples in Powershell? |
Author: | Thomas Hoevel [ Thu Oct 13, 2011 3:25 pm ] |
Post subject: | Re: New-PDF with Powershell |
No, we have C# samples only (and some VB sample code), but no Powershell samples yet. |
Author: | jbruns2011 [ Thu Oct 13, 2011 3:33 pm ] |
Post subject: | Re: New-PDF with Powershell |
Any chance you could take the NEW-PDF.ps1 example and add the XTextFormatter call and publish? Code: param($text="Hello World",$fileName="c:\test.pdf")
[reflection.assembly]::loadfrom("C:\downloads\pdfsharp\PDFsharp\code\PdfSharp\bin\Debug\PdfSharp.dll") | out-null # Create a new PDF document $document = new-object PdfSharp.Pdf.PdfDocument # Create an empty page $page = $document.AddPage() # Get an XGraphics object for drawing $gfx = [PdfSharp.Drawing.XGraphics]::FromPdfPage($page) $options = new-object PdfSharp.Drawing.XPdfFontOptions([PdfSharp.Pdf.PdfFontEncoding]"Unicode", [PdfSharp.Pdf.PdfFontEmbedding]"Always") # Create a font $font = new-object PdfSharp.Drawing.XFont("Arial", 20, [PdfSharp.Drawing.XFontStyle]"Bold", $options) # Draw the text $gfx.DrawString( $text, $font, [PdfSharp.Drawing.XBrushes]::Black, (new-object PdfSharp.Drawing.XRect(0, 0, $page.Width, $page.Height) ), [PdfSharp.Drawing.XStringFormats]::Center) # Save the document... $document.Save( $filename ) |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |