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.

Thu Jul 21, 2016 11:01 am

Hello ,
I want to print the pdf as number of time as the user want . My pdf is single page and in my code below the user want to print the pdf 3 time , so i write the as below

int NumOfLabel = 3; /* want that the PDF print three time */
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(FileName);

//Use the default printer to print all the pages
//doc.PrintDocument.Print();

//Set the printer and select the pages you want to print

PrintDialog dialogPrint = new PrintDialog();
dialogPrint.AllowPrintToFile = true;
dialogPrint.AllowSomePages = true;
dialogPrint.PrinterSettings.Copies =(short)NumOfLabel;
dialogPrint.PrinterSettings.MinimumPage = 1;
dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count;
dialogPrint.PrinterSettings.FromPage = 1;
dialogPrint.PrinterSettings.ToPage = doc.Pages.Count;

if (dialogPrint.ShowDialog() == DialogResult.OK)
{
doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage;
doc.PrintToPage = dialogPrint.PrinterSettings.ToPage;
doc.PrinterName = dialogPrint.PrinterSettings.PrinterName;
doc.PrintToPage = NumOfLabel;
for (i = 0; i < NumOfLabel; i++)
{
PrintDocument printDoc = doc.PrintDocument;
dialogPrint.Document = printDoc;
printDoc.Print();
}
}

The above code only print single copy of print of pdf 2 and 3rd copy is blank . so what i need to do

abhishek_bnmu
 
Posts: 3
Joined: Mon Dec 02, 2013 7:33 am

Fri Jul 22, 2016 6:13 am

Hi,

Thanks for your inquiry.
We suggest you use following method.
Code: Select all
              PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(FilePath + "Hell0.pdf");
            doc.PrintDocument.PrinterSettings.Copies = 3;
            doc.PrintDocument.Print();


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Sat Jul 23, 2016 5:47 am

Thanks for your replay. you code not worked i think you miss understand . I am posting the fixed code some other developer can use this .
#region new printing Code
PrintDialog dialogPrint = new PrintDialog();
dialogPrint.AllowPrintToFile = true;
dialogPrint.AllowSomePages = true;
dialogPrint.PrinterSettings.Copies =(short)NumOfLabel;
if (dialogPrint.ShowDialog() == DialogResult.OK)
{
for (i = 0; i < NumOfLabel; i++)
{
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(FileName);
doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage;
doc.PrintToPage = dialogPrint.PrinterSettings.ToPage;
doc.PrinterName = dialogPrint.PrinterSettings.PrinterName;
doc.PrintToPage = NumOfLabel;

PrintDocument printDoc = doc.PrintDocument;
dialogPrint.Document = printDoc;
printDoc.Print();
}

abhishek_bnmu
 
Posts: 3
Joined: Mon Dec 02, 2013 7:33 am

Mon Jul 25, 2016 1:33 am

Hi,

Thanks for sharing your codes.
If there is any question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Mon Jan 11, 2021 6:49 am

Hello,
When we provide the number of copies (value in number)for printing in the printer settings,the value is no where respected and only one copy of document is printed by default.
Is there any logic respected for number of copies per each print?
Has this issue already resolved if yes please provide the code snippet for this.

nadafmin
 
Posts: 2
Joined: Mon Jan 11, 2021 6:27 am

Mon Jan 11, 2021 10:05 am

Hello,

Thanks for your inquiry.
Please refer to the following code to set the number of copies for printing. If there are any other questions, just feel free to write back.
Code: Select all
            PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile(@"test.pdf");
            pdf.PrintSettings.PrintController = new StandardPrintController();
            //Set the number of copies of the document
            pdf.PrintSettings.Copies=2;
            pdf.Print();


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Jan 20, 2021 9:40 am

Hello,

Can the code I provided solve your problem? Could you please give us some feedback at your convenience?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Mar 26, 2021 8:41 am

Hello ,

The code provided did not solve the issue.
Could you please revert with some other solution on this.

Thanks and regards,
Minaj Nadaf.

nadafmin
 
Posts: 2
Joined: Mon Jan 11, 2021 6:27 am

Mon Mar 29, 2021 6:56 am

Hello Minaj,

Thanks for your feedback.
I tested the code I provided with the latest Spire.PDF Pack(Hot Fix) Version:7.3.3, but everything works fine. If you are using an older version, please download the latest version to have a try first.

If the issue still occurs after trying, please provide your printer name (e.g. HP LaserJet P1007), your OS information (e.g. Windows7, 64bit) for further investigation. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Apr 08, 2021 10:57 am

Hello,

How is your issue now? Could you please give us some feedback at your convenience?

Sincerely,
Brian
E-icelbue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF