jsonal
asked on
Watermark text in vb.net
I am adding a watermark text in a document in VB.net application.
But it is causing the text in the page to be printed on the next page and the watermark prints on the first page. In preview it is all fine.
Why is it causing the text to jump to the next page?
But it is causing the text in the page to be printed on the next page and the watermark prints on the first page. In preview it is all fine.
Why is it causing the text to jump to the next page?
Dim objSelection As Word.Selection
Dim waterText As Word.Shape
Dim oMissing As Object
oMissing = System.Reflection.Missing.Value
objSelection = Doc.ActiveWindow.Selection
Dim wordText As String = AppConstants.WATERMARK_TEXT
Doc.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader
waterText = objSelection.HeaderFooter.Shapes.AddTextEffect(Microsoft.Office.Core.MsoPresetTextEffect.msoTextEffect1, _
wordText, "Times New Roman", 1, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, 0, 0, oMissing)
'waterText = objSelection.Document.Shapes.AddTextEffect(Microsoft.Office.Core.MsoPresetTextEffect.msoTextEffect1, _
' "DRAFT", "Times New Roman", 1, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, 0, 0, oMissing)
waterText.Select(oMissing)
'waterText.Select(objSelection)
objSelection.ShapeRange.Name = "PowerPlusWaterMarkObject1"
'objSelection.ShapeRange.TextEffect.NormalizedHeight = False
objSelection.ShapeRange.Fill.Transparency = 0.5
objSelection.ShapeRange.Line.Weight = 0.75
objSelection.ShapeRange.Rotation = 315
waterText.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoTrue
waterText.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
waterText.Fill.Solid()
waterText.Fill.ForeColor.RGB = Convert.ToInt32(Word.WdColor.wdColorGray30)
' objSelection.ShapeRange.WrapFormat.AllowOverlap = True
objSelection.ShapeRange.WrapFormat.Side = Word.WdWrapType.wdWrapNone ' wdWrapNone
objSelection.ShapeRange.WrapFormat.Type = 3
objSelection.ShapeRange.LockAspectRatio = True
waterText.RelativeHorizontalPosition = Word.WdRelativeVerticalPosition.wdRelativeVerticalPositionMargin
waterText.RelativeVerticalPosition = Word.WdRelativeVerticalPosition.wdRelativeVerticalPositionMargin
waterText.Left = Convert.ToDouble(Word.WdShapePosition.wdShapeCenter)
waterText.Top = Convert.ToDouble(Word.WdShapePosition.wdShapeCenter)
waterText.Height = WordApp.InchesToPoints(1.42F)
waterText.Width = WordApp.InchesToPoints(4.0F)
Doc.ActiveWindow.ActivePane.VerticalPercentScrolled = 10
Doc.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekMainDocument
ASKER
Hi, Did you take the printout also? I mean did you add code to print this page ? While previewing it looks good but in the print the watermark takes the first page and the page content jumps to the next page.
No, I didn't do a print out. Will have to give it a try on Monday and let you know if I get the same results, unless someone else here on EE can get you answer sooner :)
Okay, I ran the code and printed out the page. Both the preview and the printed output came of fine...both had the text and watermark appear on the same page. Maybe the printer you are sending it to is what's causing the issue. Can you print to another printer or say to a PDF? If so, do you get the same results?
ASKER
Actually I use the lpr command to print and looks like it is causing the issue. also I use Ecrion to convert document to postscript file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually the application will run on the server without windows environment. objDoc.printout wont work. we can close this question.
You say that the objDoc.PrintOut wont work. Hmm, well the code you are using above uses the Word application object upon which the objDoc object is based upon. So, how you figure objDoc.PrintOut won't work is not clear to me since PrintOut is a method applicable to the Word application document object.
Of course, in your particular code the object might not be called objDoc. It looks like you are using an object called Doc. So Doc.PrintOut() would be what you would likely use. Overall Doc.PrintOut should work just as you using Doc.ActiveWindow.ActivePan e.View.See kView likely works for you.
Of course, in your particular code the object might not be called objDoc. It looks like you are using an object called Doc. So Doc.PrintOut() would be what you would likely use. Overall Doc.PrintOut should work just as you using Doc.ActiveWindow.ActivePan
ASKER
Actually I compose the document in client application and then it is saved in a server. The other application which picks the document and prints it is not running in windows environment.
ASKER
Actually I compose the document in client application and then it is saved in a server. The other application which picks the document and prints it is not running in windows environment./OS
Open in new window