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.

Mon Sep 29, 2014 2:33 am

Hello ,
im yuuki

Could you advice me..
I want to print a PDF file on direct.
PDF file is the size such as A3, A4, A5.
(The size of the PDF that is in one file is fixed)

I want to print in the paper conforming to the size of the PDF file.
I want the same thing as "Select the Paper Source by PDF page size" in the print options AdobeReader.

Is there such a function?
If not, what do I need to select the paper to fit the size of the PDF file?
(change PrintDocument pagesize ??)

yuuki
 
Posts: 9
Joined: Fri May 30, 2014 10:31 am

Mon Sep 29, 2014 3:45 am

Dear yuuki,

Thanks for your inquiry.

Yes. Please refer to the code below:
Code: Select all
PdfDocument pdf = new PdfDocument("Map.pdf");
pdf.PageScaling = PdfPrintPageScaling.ActualSize;


Best regards,
Burning
E-iceblue Support Team
Last edited by burning.liu on Mon Sep 29, 2014 7:06 am, edited 1 time in total.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Mon Sep 29, 2014 6:10 am

Hello, im yuuki.

Thanks for your quick response.
I tried it already.

However, PDF files of A3 is resulting in the output at A4.
Is there a function that will set the page size to be output automatically from the size of the PDF file?
("Select the Paper Source by PDF page size" in the print options of AdobeReader)

Do I need would have to be set manually on PrintDocument.DefaultPageSettings.PaperSize?
and How do I know which page size of the PDF file that has been read?

thanks your support..

yuuki
 
Posts: 9
Joined: Fri May 30, 2014 10:31 am

Mon Sep 29, 2014 7:15 am

Dear yuuki,

Thanks for your reply.

For your requirement, please refer to the code below:
Code: Select all
PaperSize paper = new PaperSize("A3", (int)PdfPageSize.A3.Width, (int)PdfPageSize.A3.Height);
paper.RawKind = (int)PaperKind.A3;
pdf.PrintDocument.DefaultPageSettings.PaperSize = paper;
//set the page size to be output automatically from the size of the PDF file:
pdf.PageScaling = PdfPrintPageScaling.ActualSize;


Best regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Mon Sep 29, 2014 9:20 am

hello,

Thanks for your reply.

HOW do I know which page size of the PDF file that has been read?
I want to set printer pazesize that paper size of read PDF file ..

I cant get paper size from read PDF file?
(PdfDocument.PageSettings.Size ?? i wanto get about PDF files System.Drawing.Printing.PaperKind.. )

thanks your support..

yuuki
 
Posts: 9
Joined: Fri May 30, 2014 10:31 am

Mon Sep 29, 2014 9:56 am

Dear yuuki,

Thanks for your reply.

Of cource you can get page size of the PDF files and you can set the PaperSize with page size.
Please try the code below:
Code: Select all
SizeF size = pdf.Pages[0].Size;
PaperSize paper = new PaperSize("Custom", (int)size.Width, (int)size.Height);
paper.RawKind = (int)PaperKind.Custom;
pdf.PrintDocument.DefaultPageSettings.PaperSize = paper;
pdf.PageScaling = PdfPrintPageScaling.ActualSize;

Best regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Tue Sep 30, 2014 6:20 am

hello,

Thank you for advice.
It is a flow that creates a PaperSize from the size of the first page.
But correspondence is different by printer CustomPaperSize
It is likely to be dealt with by creating a PaperSize such as A3, A4, A5 from the size of the first page.

Thank you all.

Code: Select all
'exsample
            If pdfDoc.Pages(0).Size.Equals(New Drawing.SizeF(842.0, 1191.0)) Then
                Return PaperKind.A3
            ElseIf pdfDoc.Pages(0).Size.Equals(New Drawing.SizeF(595.0, 842.0)) Then
                Return PaperKind.A4
            ElseIf pdfDoc.Pages(0).Size.Equals(New Drawing.SizeF(xxxx, xxxx)) Then
                Return PaperKind.xxxxx
            End If

yuuki
 
Posts: 9
Joined: Fri May 30, 2014 10:31 am

Tue Sep 30, 2014 7:06 am

Dear yuuki,

You're welcome.
Please feel free to contact us if you have any problems.

Best regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Sat Dec 30, 2017 3:04 pm

Dear sir,

I want to set print page size in width and height at a time of printing a PDF document ..
Plz help

shivyadav.k007@gmail.com
 
Posts: 1
Joined: Mon Dec 11, 2017 6:40 am

Mon Jan 01, 2018 9:40 am

Hello,

Thanks for your inquiry. Do you want to set printting page size once when the PDF has different page size? Please describe it in detail.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Dec 31, 2018 11:20 am

Hi,

I have generated a PDF document in US legal size.

I am trying to set the PDF document to US legal size, in the below mentioned line

pdfdocument.PrintDocument.PrinterSettings.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("custom", 216, 356);

The printer is not printing in US legal paper.

Please suggest.

Thanks
Venkat

VENKEETS@GMAIL.COM
 
Posts: 6
Joined: Thu Apr 19, 2018 8:06 am

Wed Jan 02, 2019 1:52 am

Hi Venkat,

Thank you for your inquiry.
Please download the latest hotfix Spire.PDF Pack(Hot Fix) Version:4.12.7 and refer to the code below to reach your goal.
Code: Select all
Spire.Pdf.PdfDocument pdfdocument= new Spire.Pdf.PdfDocument();
pdfdocument.LoadFromFile(input);

PaperSize paper = new PaperSize("Custom", 216, 356);
paper.RawKind = (int)PaperKind.Custom;

pdfdocument.PrintSettings.PaperSize = paper;
pdfdocument.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, true);

pdfdocument.Print();


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Wed Jan 02, 2019 7:11 am

Hi Jane,

Thanks for your immediate response.

I will do as you suggested and let you know my feedback.

I have 2 sets of

1) Graph and Listing reports with landscape paper size
2) Audit with Legal paper size

Both reports needs to be set to duplex and flipped accordingly.

Please suggest, what needs to done in terms of printing to duplex printer.

Thanks
Venkat

VENKEETS@GMAIL.COM
 
Posts: 6
Joined: Thu Apr 19, 2018 8:06 am

Wed Jan 02, 2019 8:36 am

Hi Venkat,

Please refer to the code below to print in duplex mode.
Code: Select all
pdfdocument.PrintSettings.Duplex = Duplex.Default;


Besides, there's a common way to print the document in the original PDF size without giving certain size values. Hope it helps.
Code: Select all
//load the document you need print
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(FileName);

//get the page size
SizeF size = doc.Pages[0].Size;

//instantiate PaperSize object
PaperSize paper = new PaperSize("Custom", (int)size.Width/72*100, (int)size.Height/72*100);
paper.RawKind = (int)PaperKind.Custom;

//set the paper size
doc.PrintSettings.PaperSize = paper;

//choose the fit size mode
doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, true);
//duplex
pdfdocument.PrintSettings.Duplex = Duplex.Default;
//print
doc.Print();


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Fri Jan 04, 2019 1:55 am

Dear Venkat,

Greetings from e-iceblue!
Has your issue been resolved? Your feedback would be greatly appreciated!

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.PDF