Developer Programs

Learn

Docs

PrtPDF

API Reference > PrtPDF
SoapActionn/a
Input NamePrtPDF
Output NamePrtPDFResponse
Input Namespacen/a
Group NameXperience
ContainerXP_MsgBus.xsd
PrtPDF.cs
private void ButtonPrintFromFile_Click(object sender, RoutedEventArgs e)
{
    string basePath = Assembly.GetExecutingAssembly().Location;
    basePath = Path.GetDirectoryName(basePath);

    string fileLocation = Path.Combine(basePath, "Pdf", "Sample");
    fileLocation = Path.ChangeExtension(fileLocation, ".pdf");

    // Optional print Options:
    // PrtUNC:       The computer or printer server device and printer name in UNC format.
    // CopyCnt:      The number of copies desired.
    // CollateType:  Either Collated or Uncollated.
    // DuplexType:   Either OneSided, TwoSidedLongEdge or TwoSidedShortEdge.
    // InputBin:     Either AutoSelect, AutoSheetFeeder, Cassette, Manual or Tractor.
    // Orientation:  Either Landscape, Portrait, ReverseLandscape or ReversePortrait.
    // PrtColor:     Either Color, Grayscale, Monochrome.
    // NOTE:  The print options are validated and merged with the selected (or default) print queue
    //        options. Any option that is not valid is ignored and the default option is used.
    PrtOpt_CType options = new PrtOpt_CType()
    {
        PrtUNC = @"\\LKSPRINT\LKS-L2-NORTH-RICOH",
        CopyCnt = 3,
        CollateType = "Collated",
        DuplexType = "OneSided",
        InputBin = "AutoSelect",
        Orientation = "Landscape",
        PrtColor = "Color"
    };

    this.DisplayOutput("A full set of print options was sent.");

    // PDFLoc: The location to the PDF:
    //    Local File: C:/Folder1/Sub-Folder1/TEST.PDF
    //    Remote File: https://somewebsite.com/Documents/TEST.PDF
    // PDFDoc: The actual (encoded) PDF file itself.
    // ParentId: The product's main application window handle that will be the parent of the new
    //    child window.
    // PrtOpt:  Optional print options.  See above for details.
    PrtPDFRq_MType message = new PrtPDFRq_MType()
    {
        ParentId = XperienceContext.Current.WindowManager.MainHostedWindow.WindowId,
        PDFLoc = fileLocation,
        PrtOpt = options,
        BypassDialogBox = “false”
    };

    ICallback context = this.messageBus
                            .Send(message)
                            .RegisterResponseHandler(this.PrintPDFCallback);

    if (!context.Receipt.IsValid())
    {
        string error = MessageHelper.CollectionErrors(context.Receipt.Errors);
        this.DisplayOutput(error);
    }
    else
    {
        this.DisplayOutput(string.Concat("PrtPDF Message Receipt ID: ", context.Receipt.MessageId));
    }
}

Did this page help you?

Last updated Mon Dec 9 2024