Configuring Margins when printing with PdfViewer

I've downloaded the latest Aspose.Pdf for .NET and am still getting this problem.

  • COI.doc is the Word document I'm working with
  • Word.tif is the result of printing directly from Word.
  • Reader.tif is the result of converting the Word document to a PDF and printing from Acrobat reader. Below is the code for converting to PDF.

Dim fs As FileStream = New FileStream(file, System.IO.FileMode.Open, FileAccess.Read, FileShare.ReadWrite)

Dim document As Document = New Document(fs)

Dim ms As MemoryStream = New MemoryStream

Dim saveOptions As PdfSaveOptions = New PdfSaveOptions

saveOptions.SaveFormat = SaveFormat.Pdf

saveOptions.PrettyFormat = True

saveOptions.Compliance = PdfCompliance.PdfA1b

document.Save("C:\development\COI.pdf", saveOptions)

  • AsposeSimple.tif is the result of the same basic Word->PDF conversion logic and then the following code to print.

Dim viewer As PdfViewer = New PdfViewer

viewer.OpenPdfFile(ms)

viewer.PrintPageDialog = False

viewer.PrintDocument()

viewer.ClosePdfFile()

  • AsposeComplicated.tif is the result of the same Word->PDF conversion and the following logic to print

printerSettings = New PrinterSettings

pageSettings = New PageSettings

printerSettings.PrinterName = "Kyocera TASKalfa 500ci KX"

pageSettings = printerSettings.DefaultPageSettings.Clone()

'pageSettings.Margins.Top = 0

'pageSettings.Margins.Bottom = 0

'pageSettings.Margins.Left = 0

'pageSettings.Margins.Right = 0

'pageSettings.PaperSize = New System.Drawing.Printing.PaperSize("Letter", 850, 1100)

Dim viewer As PdfViewer = New PdfViewer

viewer.OpenPdfFile(ms)

viewer.PrintPageDialog = False

viewer.PrintDocumentWithSettings(pageSettings, printerSettings)

viewer.ClosePdfFile()

Am I doing something wrong? As you can see using PdfViewer is clipping output on the right side of the document.

Thanks,

Will

Hi Will,

We’re investigating this issue at our end. You’ll be updated with the results shortly.

We’re sorry for the inconvenience.
Regards,

Shahzad,

Any progress/update on this?

Thanks,

Will

An addendum.

Out original intent was using the Aspose.Pdf.PdfEditor.Concatenate() method to combine all our documents into one PDF and then print it as such.

While awaiting a resolution to this issue, we are instead using aspose.Words.Document.Print to print, this means that we have to call Print() repetitively for each document. When multiple users are printing concurrently, the individual print jobs are interleaved in the print queue.

Do you have any suggestions as to how to keep the print jobs from each user(session) grouped together?

Thanks,
Will Skou

Hi Will,

We have investigated this issue in detail and noticed that when you copy the PageSettings from the existing printer’s settings, the margins are not “0”. That’s why, you’re having this issue in the printed output in second case. You may set the margins to 0 by adding the following line of code:


pageSettings.Margins = New Margins(0, 0, 0, 0)


I hope this helps. If you find any further questions, please do let us know.
Regards,