PDA

View Full Version : Print - almost no output


Ebh_Finans
December 13, 2006, 10:07:57
I try to print a RTF document loaded into a ServerTextControl. It is two pages containing images and text. The only output on the paper is one image, not positioned properly. The rest is blank.

I'm using a trial version of TxTextControl version 13.0

Am I missing some initialization?

Here is the print code:


private static ServerTextControl serverText = new ServerTextControl();

static void Main(string[] args)
{
string printerName = @"..";
string fileName = @"..";

serverText.Create();
serverText.Load(fileName, StreamType.RichTextFormat);

PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.PrinterName = printerName;
printDocument.PrinterSettings = printerSettings;
PageSettings pageSettings = new PageSettings(printerSettings);
printDocument.DefaultPageSettings = pageSettings;
printDocument.Print();
}

private static int currentPage = 1;

static void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
serverText.Print(currentPage, e);
currentPage++;

e.HasMorePages = currentPage <= serverText.Pages;
}

Ebh_Finans
December 15, 2006, 13:23:32
Thanks to Björn, we are now able to print!

One issue remains though:

We need to insert images at a specific position.
We insert images by adding them to the Images collection of the control. If we save to PDF, the document looks fine, but when we print, the images are positioned too far to the right.

We create images like this:

TXTextControl.Image image = new TXTextControl.Image();
image.FileName = ...;
image.ExportFilterIndex = 4;
image.ExportCompressionQuality = 100;

and add them like this:

textControl.Images.Add(image, page, new Point(11500, 13970), ImageInsertionMode.DisplaceText);

Are we missing something? I tried searching the forum..

/Martin M.

Ebh_Finans
December 15, 2006, 13:58:11
It seems the whole document is scaled too large.
I've tried changing the PageScale property of the Graphics of the PrintPageEventArgs, but it doesn't seem to make a difference.

So it might be an issue regarding the PrintDocument..

/Martin M.

Björn Meyer
December 15, 2006, 14:13:43
Did you adjust the page size of the PrintDocument? This is described in this article:

http://www.textcontrolblog.com/archive/2006/06/12/printing-into-a-printdocument.htm

Ebh_Finans
December 18, 2006, 10:13:18
Setting the page size helped. Thanks.