Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Dec 15, 2021 7:03 pm

When I print directly from SQL ReportServer everything is spaced correctly. When I print to the exact same printer from FreeSpire the page seems to be moved over and down an extra 1/2 inch. See attached zip of two .xps Files. This is the code I am currently using:

Code: Select all
var result = rs.Render("PDF", deviceInfo, out mimeType, out encoding, out encoding, out warning, out streamId);

PdfDocument pdf = new PdfDocument();

pdf.PageSettings.Margins.All = 0f;

pdf.LoadFromBytes(result);

//pdf.PageSettings.Size = new SizeF(8.5f, 11);

pdf.PageSettings.Margins.All = 0f;

var printerName = await GetPrinterName(printer);

pdf.PrintSettings.PrinterName = printerName;

//pdf.PrintSettings.PaperSize.Height = 1100;
//pdf.PrintSettings.PaperSize.Width = 850;

pdf.Print();


I have tried setting the page margin both before and after I LoadFromBytes with no visible results. I don't know how to set the margin for PrintSettings. Where is the extra margin coming from?
Print Results.zip

randygordey
 
Posts: 6
Joined: Tue Dec 14, 2021 4:37 pm

Thu Dec 16, 2021 3:33 am

Hello,

Thanks for your inquiry!

I simulated a PDF file and did an initial test with the code you provided, but did not reproduce your issue. Besides, you can use pdf.PrintSettings.SetPaperMargins(0, 0, 0, 0); to adjust the paper margins of the printing result.

If the issue still exists after you set the paper margins, please provide us with the PDF file that you were using for further investigate. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Thu Dec 16, 2021 2:46 pm

I added
Code: Select all
pdf.PrintSettings.SetPaperMargins(0, 0, 0, 0)
with no effect.

I then changed my code to first save it as a Pdf file and use
Code: Select all
LoadFromFile
rather than
Code: Select all
LoadFromBytes
. When I open the saved PDF file in it looks fine. However, using FreeSpire.PDF to print it it still gets the extra margin. I have attached the PDF.

F1285.zip

randygordey
 
Posts: 6
Joined: Tue Dec 14, 2021 4:37 pm

Fri Dec 17, 2021 6:58 am

Hello,

Thanks for sharing more information!

I tested the PDF file you provided and printed it with Microsoft XPS Document Writer printer to XPS, but still did not reproduce the issue you mentioned. Here I attached the XPS file I generated. To help us quickly reproduce your issue, please provide us with the following information. Thanks again for your cooperation!

Besides, if you just need to generate the XPS file, you can use pdf.SaveToFile("res.xps", FileFormat.XPS); to achieve it.

1. Your system information (E.g. Win7, 64 bit) and region setting (E.g. China, Chinese)
2. The target framework of your project (E.g. .net framework 4.8.0)
3. The type of your project (E.g. console application)

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Tue Jan 04, 2022 5:58 am

Hello,

Hope you are doing well!

Has the issue been solved now? Could you please provide us with the information I mentioned in the last post for further investigate?

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Tue Jan 04, 2022 9:03 pm

I am using .Net Framework 4.7.1
The type of project is ASP.Net web API
I am running currently on Windows 10
I use Visual Studio 2019 Version 16.11.8

No, this hasn't been resolved.

randygordey
 
Posts: 6
Joined: Tue Dec 14, 2021 4:37 pm

Wed Jan 05, 2022 6:17 am

Hello,

Thanks for sharing more information!

I simulated a web application with .Net Framework 4.7.1 on Win10, and used the FreeSpire.PDF for net 7.8.9 to print F1285.pdf, but still not reproduce your issue. Here I attached the whole project and generated XPS file for your reference. Please run it on your side, if this issue only appears in your project, please provide us with your entire project for further investigate. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.PDF

cron