Created
November 24, 2015 19:37
-
-
Save srkirkland/971f8255c911c714c251 to your computer and use it in GitHub Desktop.
pdf with floating box and ocr scan line
This file contains 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
// Load HTML file | |
var pdfDocument = new Document(stream, options); | |
//pdfDocument.FitWindow = true; | |
Font myFont = FontRepository.OpenFont(HttpContext.Current.Server.MapPath("~/fonts/ocraextended.ttf")); | |
//Font myFont = FontRepository.OpenFont(".\\fonts\\ocraextended.ttf"); | |
myFont.IsEmbedded = true; | |
//create text stamp | |
TextStamp textStamp = new TextStamp("0123456789000100000123456789"); | |
//set whether stamp is background | |
textStamp.Background = true; | |
textStamp.HorizontalAlignment = HorizontalAlignment.Right; | |
textStamp.VerticalAlignment = VerticalAlignment.Bottom; | |
textStamp.BottomMargin = 27; // 3/8 inch | |
textStamp.RightMargin = 27; | |
//set text properties | |
textStamp.TextState.Font = myFont; | |
textStamp.TextState.FontSize = 12.0F; | |
textStamp.TextState.FontStyle = FontStyles.Regular; | |
//add stamp to particular page | |
pdfDocument.Pages[1].AddStamp(textStamp); | |
var box = new FloatingBox((float)pdfDocument.PageInfo.Width, 100); | |
box.VerticalAlignment = VerticalAlignment.Bottom; | |
box.HorizontalAlignment = HorizontalAlignment.Left; | |
box.Margin = new MarginInfo(0, 0, 0, 0); | |
box.Border = new BorderInfo(BorderSide.Top, 8, Color.Black); | |
var text = new TextFragment("GREAT COUPON"); | |
text.TextState.FontSize = 24F; | |
text.TextState.FontStyle = FontStyles.Bold; | |
text.Margin = new MarginInfo(10, 10, 10, 10); | |
box.Paragraphs.Add(text); | |
box.Left = 0 - pdfDocument.PageInfo.Margin.Left; | |
box.Top = pdfDocument.PageInfo.Height - 216; //3 inches | |
pdfDocument.Pages[1].Paragraphs.Add(box); | |
var output = new MemoryStream(); | |
pdfDocument.Save(output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment