Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > Sample Code
  New Posts New Posts RSS Feed - Create button to print PDF page
  FAQ FAQ  Forum Search   Register Register  Login Login

Create button to print PDF page

 Post Reply Post Reply
Author
Message
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Topic: Create button to print PDF page
    Posted: 03 Apr 13 at 8:39PM
It's imported from the helping section.
Thanks to tado/Tom!

Hi,
I'm using QuickPDF version 8.13 with C# to print PDF file to printer.
Is there any way to add the Print button to page 3 (for ex), and then when user open the PDF they can print out page 3 by clicking to that button.

Thanks
Tom

 I've done, here is the code:

void AddPrintButton(QuickPDFAX0813.PDFLibrary qp, string buttonName, int pageNumber)
        {
            if (pageNumber > 0)
            {
                qp.SetOrigin(1);

                //set the page where the button appear
                qp.SelectPage(pageNumber);

                //get the size of the button
                var buttonWidth = qp.GetTextWidth(buttonName);
                var buttonLocation = (qp.PageWidth()) - (buttonWidth) - 30;

                var fieldIndex = qp.NewFormField(buttonName, 2);               
                qp.SetFormFieldPrintable(fieldIndex, 0);
                qp.SetFormFieldBounds(fieldIndex, buttonLocation, 70, buttonWidth, 20);
                qp.SetFormFieldFont(fieldIndex, qp.GetFormFontCount());
                qp.SetFormFieldTextSize(fieldIndex, 10);
                qp.SetFormFieldBorderColor(fieldIndex, 1, 0, 0);
                qp.SetFormFieldBorderStyle(fieldIndex, 1, 0, 0, 0);
                qp.SetFormFieldColor(fieldIndex, 1, 0, 0);
                qp.SetFormFieldCaption(fieldIndex, buttonName);
                qp.SetFormFieldValue(fieldIndex, "");
                qp.SetFormFieldHighlightMode(fieldIndex, 3);
                qp.FormFieldJavaScriptAction(fieldIndex, "U", "this.print({" +
                 "bUI: false," +
                 "bSilent: true," +
                 "bShrinkToFit: true," +
                 "nStart: " + (pageNumber - 1).ToString() + "," +
                 "nEnd: " + (pageNumber - 1).ToString() + "});");    // have -1 because the Acrobat Javascript PDF start page from 0
            }           
        }
Back to Top

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store