Im finding that the Print method is taking an absolute age to complete.
Hi,
- OS (Windows Version or Linux Version)
- Architecture (32 / 64 bit)
- Please supply us with the input document that is causing the issue
- Are you facing this issue will all document or only with specific document?
As soon as you get these pieces of information to us we’ll start our investigation into your issue.
Sub PrintSampleDoc(PrinterName As String)
Dim doc As Document = GetSampleDoc()
Dim settings As New System.Drawing.Printing.PrinterSettings
settings.PrinterName = PrinterName
doc.Print(settings, "CustomDocName")
End Sub
Private Function GetSampleDoc() As Document
Dim l As License = New License()
l.SetLicense("\\MyLicenseLocation\Aspose.Words.lic")
Dim doc As New Document()
'Once the builder is created, its cursor is positioned at the beginning of the document.
Dim builder As New DocumentBuilder(doc)
'Specify font formatting before adding text.
builder.Font.Size = 16
builder.Font.Bold = True
builder.Font.Color = System.Drawing.Color.Blue
builder.Font.Name = "Arial"
builder.Underline = Underline.Dash
builder.Write("This text")
builder.Underline = Underline.None
builder.Write(" is inserted at the beginning of the document and demonstrates ")
'Set shading and border around a run of text, then clear the border.
builder.Font.Shading.ForegroundPatternColor = System.Drawing.Color.Cyan
builder.Font.Shading.Texture = TextureIndex.TextureSolid
builder.Write("various font")
builder.Font.Shading.ClearFormatting()
builder.Font.Border.LineStyle = LineStyle.Single
builder.Write(" formatting ")
builder.Font.Border.ClearFormatting()
builder.Writeln("options.")
builder.InsertParagraph()
'Specify paragraph formatting before calling InsertParagraph or Writeln.
builder.ParagraphFormat.Borders.LineStyle = LineStyle.Single
builder.ParagraphFormat.Borders.LineWidth = 1.5
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center
builder.ParagraphFormat.Shading.ForegroundPatternColor = System.Drawing.Color.LightBlue
builder.ParagraphFormat.Shading.Texture = TextureIndex.TextureSolid
builder.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(0.3)
builder.ParagraphFormat.SpaceBefore = 12
builder.ParagraphFormat.SpaceAfter = 12
builder.Font.Name = "Arial"
builder.Font.Size = 12
builder.Write("This fragment demonstrates use of paragraph formatting to specify ")
builder.Writeln("alignment, spacing, borders and shading.")
builder.ParagraphFormat.ClearFormatting()
'Insert another section and demonstrate page setup properties.
builder.MoveToDocumentEnd()
builder.Font.Size = 12
builder.InsertBreak(BreakType.SectionBreakNewPage)
builder.PageSetup.PaperSize = Aspose.Words.PaperSize.A5
builder.PageSetup.Orientation = Orientation.Landscape
builder.Writeln("This text is in a section with different page size and orientation.")
builder.Writeln("Insert an image into the document here.")
'Move to a position in the header.
builder.MoveToMergeField("MyHeader")
builder.Font.ClearFormatting()
builder.Font.Italic = True
builder.Write("This text is inserted into the header.")
Return doc
End Function
Hi,
PrintDocument doc = new PrintDocument();<o:p></o:p>
doc.PrinterSettings.PrinterName = @"\192.168.0.2\hp LaserJet 1010 Series Driver";<o:p></o:p>
doc.PrintPage += Doc_PrintPage;<o:p></o:p>
doc.Print();
============================================================================
private void Doc_PrintPage(object sender, PrintPageEventArgs e)<o:p></o:p>
{<o:p></o:p>
e.Graphics.DrawImage(Image.FromFile(@“Common\test.jpg”), e.MarginBounds.Left, e.MarginBounds.Top);<o:p></o:p>
}
This code just prints an image. Please let us know if you have any more queries.
The code below took 8 secs to run
Dim ts As DateTime = Now
Dim doc As PrintDocument = New PrintDocument()
doc.PrinterSettings.PrinterName = txtPrinter.Text
AddHandler doc.PrintPage, AddressOf Doc_PrintPage
doc.Print()
Dim dur As TimeSpan = Now.Subtract(ts)
MsgBox(dur.TotalSeconds) '8 secs
My original code takes 110 secs today
Hi,