Created
September 4, 2015 04:36
-
-
Save KMR-zoar/83bd2946f57cf2c22228 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dllpath = "B:\tmp\itextsharp.dll" | |
$inpdf = "B:\tmp\input.pdf" | |
$outpdf = "B:\tmp\output.pdf" | |
[void][System.Reflection.Assembly]::LoadFrom($dllpath) | |
$iText="iTextSharp.text" | |
$reader = New-Object "$iText.pdf.PdfReader"($inpdf) | |
$B4 = New-Object iTextSharp.text.Rectangle(1031.91, 728.595) | |
$doc = New-Object "$iText.Document"($B4) | |
$BaseFont = [iTextSharp.text.pdf.BaseFont]::CreateFont( | |
"C:\windows\fonts\msmincho.ttc,0", | |
[iTextSharp.text.pdf.BaseFont]::"IDENTITY_H", | |
$True) | |
$stream = New-Object System.IO.FileStream( | |
$outpdf, | |
[System.IO.FileMode]::Create) | |
$writer = [iTextSharp.text.pdf.PdfWriter]::GetInstance($doc, $stream) | |
$doc.Open() | |
$page = $writer.GetImportedPage($reader, 1) | |
$dc = $writer.DirectContent | |
$dc.AddTemplate($page, 0, -1, 1, 0, 0, 728.595) | |
$dc.BeginText() | |
$dc.SetFontAndSize($BaseFont, 20) | |
$dc.ShowTextAligned( | |
[iTextSharp.text.pdf.PdfContentByte]::ALIGN_LEFT, | |
"Hello World!", | |
45, | |
685, | |
0) | |
$dc.EndText() | |
$doc.Close() | |
$stream.Close() | |
$reader.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment