Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Re: Adding a footer before printing
Started by Michaelo at 05-14-2008 6:35. Topic has 3 replies.

Print Search « Previous Thread Next Thread »
  05-14-2008, 6:35
Michaelo is not online. Last active: 5/14/2008 11:36:30 AM Michaelo

Top 500 Posts
Joined on 05-13-2008
Posts 8
Adding a footer before printing
Reply Quote
I have an jpg image 400 x 400 and printing it on A4 paper i would like to add a footer note at the bottom of the page. But i can only get the text to be in the bounds of the image. I have attached the code.

I'm using version 14.5 of Lead tools for .Net
   Report 
  05-14-2008, 6:37
Michaelo is not online. Last active: 5/14/2008 11:36:30 AM Michaelo

Top 500 Posts
Joined on 05-13-2008
Posts 8
Re: Adding a footer before printing
Reply Quote
private void AddPageFooter(IRasterImage image, AnnContainer container)
{
container.Bounds = new AnnRectangle(0, 0,
printDocument.DefaultPageSettings.PrintableArea.Width,
printDocument.DefaultPageSettings.PrintableArea.Height, AnnUnit.Millimeter);
container.UnitConverter = new AnnUnitConverter(image.ImageWidth, image.ImageHeight);

container.Name = "Container";
container.Visible = true;

AnnTextObject text = new AnnTextObject();

text.Text = string.Format("Document - {0} Revision {1} Date {2}", "TestDoc");
text.Pen = new AnnPen(Color.Red,new AnnLength(4)) ;
text.Brush = null;
text.EdgeMargin = AnnLength.Empty;
text.Alignment = StringAlignment.Center;
text.LineAlignment = StringAlignment.Center;
text.TextColor = Color.Black;
text.Font = new AnnFont(InvuRenderer.Instance.FontName, new AnnLength(12), FontStyle.Bold);
text.Bounds = new AnnRectangle(1, 0, printDocument.DefaultPageSettings.PrintableArea.Width, 5, AnnUnit.Millimeter);

container.Objects.Add(text);
container.Draw(image.CreateGdiPlusGraphics().Graphics);
}

   Report 
  05-14-2008, 15:35
jigar is not online. Last active: 12/12/2008 5:08:42 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 480
Re: Adding a footer before printing
Reply Quote
What you have to do is, create an empty white image that is A4 size with 400dpi, or whatever the image's DPI is.  Then put the original image on top of the white image.  This will give you a new image.  Then you can add the text with your code above.

If all of your images are 400dpi.  You could easily create a white image in Photoshop or GIMP and load that image, instead of creating one programmatically.  Let me know if you are unsure about anything or have questions.

LEADTOOLS Technical Support
   Report 
  08-26-2008, 14:26
JoeBussell is not online. Last active: 12/13/2008 12:04:09 AM JoeBussell

Top 50 Posts
Joined on 06-17-2008
Eugene, OR
Posts 62
Re: Adding a footer before printing
Reply Quote
This solution seems particularly bulky for very large image files.  Specifically, the requirement that I form multiple lead objects with the contents of the large bitmap may result in unnecessary slow down of my printing procedure.  I am working with an alternative plan, though it does have its challenges.  My technique is to write out the header and footer to the printer, and to provide the selected printer hDc to the LEAD.Render call.

' I am using stuff to setup printer and get paper settings, tray settings, etc
' derived from the VB PrinterDlg module (for the lib and a good example search at msdn)

PrinterXYPrint (7.5 - PrinterTextWidth(Title)) / 2, 0#, "My Title"
hDc = Printer.hDc

' removed some stuff that limits the image size to the page size in use...
LEAD1.Render hDc, 1, 1, PrintWidth, PrintHeight

PrinterXYPrint (7.5 - Printer.TextWidth(PageStr)) / 2, ypos, "My Footer String"


Where:
'*** PrinterXYPrint
'***    Draw a string at a specified X,Y location.
Sub PrinterXYPrint(X As Single, Y As Single, S As String)
    On Error Resume Next
    Printer.CurrentX = GConf.PrintLeftMargin + X
    Printer.CurrentY = GConf.PrintTopMargin + Y
    Printer.Print S
End Sub


Now if I could only get the lead image to invariably print out what I see I will be golden.


   Report 
Post
LEAD Support Fo... » Developer » Printing » Re: Adding a footer before printing

Powered by Community Server, by Telligent Systems