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 May 27, 2020 2:30 pm

Code: Select all
      public void PrintTbrAdPage(string tbrPageNoToPrint, string localTBRFileName)
      {
         PdfUtil.LoadSpireLicenses();

         var tbrPdf = new PdfDocument(localTBRFileName);
         PdfTextFind[] findResults = null;

         foreach (PdfPageBase page in tbrPdf.Pages)
         {
            findResults = (page.FindText("Page " + tbrPageNoToPrint)).Finds;

            foreach (var find in findResults)
            {
               var pageNumber = find.SearchPageIndex + 1; //0 based index
               tbrPdf.PrintFromPage = pageNumber;
               tbrPdf.PrintToPage = pageNumber;
               tbrPdf.PrintDocument.Print();
            }
         }
      }


I am using Spire.pdf 6.4.11
This code no longer works when we upgraded out licenses.
PrintFromPage and PrintToPage no longer exist.

[email protected]
 
Posts: 110
Joined: Tue May 19, 2015 8:09 pm

Thu May 28, 2020 5:48 am

Hello,

Thanks for your inquiry.
Kindly note that these two properties are obsoleted, please use the new method PdfDocument.PrintSettings.SelectPageRange instead, as shown below. If there is still any question, please provide your input file for further investigation.
Code: Select all
    public void PrintTbrAdPage(string tbrPageNoToPrint, string localTBRFileName)
    {
        var tbrPdf = new PdfDocument(localTBRFileName);
        PdfTextFind[] findResults = null;
        foreach (PdfPageBase page in tbrPdf.Pages)
        {
            //findResults = (page.FindText("Page " + tbrPageNoToPrint)).Finds; //This method is also obsoleted.
            findResults = (page.FindText("Page" + tbrPageNoToPrint, TextFindParameter.None)).Finds;
            foreach (var find in findResults)
            {
                var pageNumber = find.SearchPageIndex + 1; //0 based index
                tbrPdf.PrintSettings.SelectPageRange(pageNumber, pageNumber);
                tbrPdf.Print();
            }
        }
    }


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Thu May 28, 2020 1:11 pm

Thank you.

[email protected]
 
Posts: 110
Joined: Tue May 19, 2015 8:09 pm

Fri May 29, 2020 1:19 am

Hello,

You are welcome.
If you have further questions, just feel free to contact us.
Have a nice day!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Thu Oct 15, 2020 7:36 pm

PdfDocument.PrintSettings.SelectPageRange

Does not exist in my version.

#region Assembly Spire.Pdf, Version=6.4.11.0, Culture=neutral, PublicKeyToken=663f351905198cb3
// C:\Users\Terrence\.nuget\packages\spire.office\5.4.2\lib\netstandard2.0\Spire.Pdf.dll

[email protected]
 
Posts: 110
Joined: Tue May 19, 2015 8:09 pm

Fri Oct 16, 2020 6:44 am

Hello,

Thanks for your post.
Sorry to tell you that our Spire.PDF for .NET Standard does not yet support printing. We have added this feature to our upgrade list. If it is implemented in the future, we will notify you immediately.
We recommend that you use our .NET Framework dlls or .NET Core dlls to print for now. Apologize for the inconvenience caused.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Dec 26, 2025 6:00 am

Hello,

Our latest version already includes netstandatd printing function. Please update and refer to the following code for testing.
website:https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
nuget:https://www.nuget.org/packages/Spire.PDFfor.NETStandard
Code: Select all
// Create a PdfDocument object
PdfDocument doc = new PdfDocument();
// Load the PDF file
doc.LoadFromFile(PdfFileName);
// Specify the printer name
doc.PrintSettings.PrinterName = PrinterName;
// Select the page range for printing
doc.PrintSettings.SelectPageRange(1, 2);
// Print the document
doc.Print();
doc.Dispose();

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF