Free Support Forum - aspose.com

Aspose.Pdf.Generator.PrintController is missing

Hello support team,

I noticed that the generator class is not availbale anymore with aspose.pdf version 18

was it replaced with something else? if yes let me know please.
If not, what is the alternatives?

Thank you

@rzeylah

Thank you for contacting support.

You can print your documents with Aspose.PDF for .NET API as explained in Working with PDF printing. We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Hi Farhan,

I am asking about this class
Aspose.Pdf.Generator.PrintController (https://docs.aspose.com/display/pdfnet/Aspose.Pdf.Generator.PrintController+Class)

We used this class to save to pdf in older versions of aspose.pdf
This is my code:
Dim DocumentToSave as New PrintDocument
Dim PrintController As New Aspose.Pdf.Generator.PrintController
PrintController.FileName = SavedFileName
DocumentToSave.PrintController = PrintController
DocumentToSave.Print()

The link you sent me is only for printing PDF files.

Thank you

@rzeylah

Would you please elaborate your requirements for which you have been using this class, so that we may investigate and suggest any possible alternative as per your requirements.

@rzeylah

We are investigating your requirements and sample input file is required along with complete code snippet which you were using to achieve your requirements. Kindly add some more details so that we may proceed to assist you.

This is my code:
Thank you

Public Class PrintToPDF

#Region " Private Members "
Private Const ClassName As String = “PrintToPDF”
Private WithEvents mPrintDoc As PrintDocument
Private WithEvents mPrintDialog As PrintDialog
Private WithEvents mPrintPreview As PrintPreviewDialog
Private mFont As Font
Private mBrush As Brush
Private mClaims As Claim()
Private mPrinting As Boolean = Falsepr
Private mCurrentPage As Integer = -1
Private mPageList As ArrayList = New ArrayList
#End Region

#Region " Shared Constructor "
Public Sub New()
mPrintDoc = New PrintDocument
mPrintDialog = New PrintDialog
mPrintPreview = New PrintPreviewDialog
mPrintDialog.Document = mPrintDoc
mPrintPreview.Document = mPrintDoc
mFont = Config.Font
mBrush = Config.Brush
End Sub
#End Region

#Region " Public Shared Methods "

Public Sub Print(ByVal FileName as String)
    Dim Source As String = ClassName & "Print"
    Try
        If mPrinting = True Then
            ErrorHandler.ThrowMsg("Another print job is in progress. Please try printing again later.", MsgBoxStyle.Critical)
            Exit Sub
        End If

        
        GetNumberOfPages()
        If mPageList.Count < 1 Then Exit Try
        
               mPrinting = True
			   Dim PrintController As New Aspose.Pdf.Generator.PrintController
               PrintController.FileName = FileName
               mPrintDoc.PrintController = PrintController
               mPrintDoc.Print()
                End If
        
    Catch ex As Exception
        ErrorHandler.DisplayErr(ErrorsEnum.Unknown, Source, ex, True)
    Finally
        mCurrentPage = -1
        mPageList.Clear()
        mPrinting = False
    End Try
End Sub

#End Region

#Region " Event Handlers "

Private Sub mPrintDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles mPrintDoc.PrintPage
    e.Graphics.PageUnit = GraphicsUnit.Document
    If Config.FormImageEnabled Then
        e.Graphics.DrawImage(Config.Image, Config.FormImagePosition.X, Config.FormImagePosition.Y) 
    End If

    Dim pg As Point = mPageList(mCurrentPage)

    Dim s As New Bitmap(32, 32, e.Graphics)

    If mCurrentPage < mPageList.Count - 1 Then
        mCurrentPage += 1
        e.HasMorePages = True
    Else
        mCurrentPage = 0
        e.HasMorePages = False
    End If
End Sub

#End Region

#Region " Private Shared Methods "
Private Sub GetNumberOfPages()
mCurrentPage = -1
mPageList.Clear()
mPageList.Add(Config.Page)
End Sub
#End Region

End Class

@rzeylah

Thank you for sharing the code snippet.

Please also share a sample file which is being used to specify FileName property of PrintController class, so that we may proceed further to sort this out.

FileName is a string containing the file path to be generated
ex: PrintController.FileName = “C:\GeneratedFile.pdf”

@rzeylah

Thank you for clarifying.

We have recorded your feedback and will let you know as soon as some significant updates will be available in this regard.

The issues you have found earlier (filed as ) have been fixed in Aspose.PDF for .NET 18.12.