lookup pdf and print

Hi,

This is the situation:

I need to lookup a certain PDF based on the name or barcode number and print the resulting PDF out.

the lookup needs to be done on a webpage.

kind regards,

Koen

At it’s simplest, you should be able to have your web page submit to the Workflow via an HTTP Server Input action.

For example, assume an HTTP Server Input with the action “myTestAction”. If I have a webpage submit to my workflow with the something like the following URL: http://localhost:8080/myTestAction?docID=12345 the resulting XML generated in the workflow will look something like this:

From there, you can read the value out of that XML, retrieve or create your document, and print it.

Disclaimer: The workflow itself should not be exposed to the internet. Make use of secure channels to communicate between your web server (IIS, Apache, etc) and the workflow. For more info on the very basics of this, see the seriews created by Evie here: https://www.youtube.com/playlist?list=PLXD33hUNXfdljfZi5ohKuL__mNAxXmyoY

This sounds like an excellent project :slight_smile:

Is there anything specific we can do to assist? Are you stuck at a particular stage or are you simply looking where to start? Can you provide more details?

Hey Koen,

Can you elaborate a bit more on which part of this solution you’re looking for assistance with?

The overall idea would be to return a webpage containing a form that allows the user to specify which PDF they’d like to print, and that form would submit to a separate workflow process that grabs that information and prints the corresponding PDF.

You could either create the webpage with a static listing of the files in the folder at that time (use folder listing to return XML, convert XML to JSON, use JSON in template script to populate form elements, etc…), or you could do dynamic scripted AJAX calls to the server to request for a current listing of the files. You could even go even more basic and have the customer use a blank text field.

From there you just need to point the form on that webpage to a separate workflow process that reads the submitted data, loads the corresponding PDF (using the Load External Files plugin), and then prints it.

Hi Rod,

I am looking where to start.

I have to build a application for our returns department.

They have to scan an excisting EAN code or type in the name of the product and then print out the corresponding PDF.

The pdf filename contains the ean code and the name of the product. I created this with workflow and that worked out great.
I am not creating a pdf from scratch, just changing the name of a excisting pdf.

I already have built an application in a different enviroment that is working like described above. This program sends out the pdf to a ftp. Workflow picks up that pdf and sends it to the printer.

I must say that my programming skills aren’t that great yet, I am still learning every day.
So any help with this would be great. I just need a step by step description what to do.

kind regards,

Koen

Hi Stephen,

See my answer to Rod.

your solution seems to look like what I need. the only problem is, I don’t know how or where to start but I am definitely going to look into your solution now.

kind regards,

Koen

Hi,

thank you. I am going to look at the series from Evie. they look interesting.

kind regards,

koen

I’m not sure what the best point to start out would be. I don’t think there’s really a right or wrong answer there as you’ll likely be going back and forth between the “front-end” (webpage) and the “back-end” (workflow processes) during development either way.

Getting the JSON data into your template is the easier part in my opinion as you have a workflow plugin that returns a formatted XML file of a folder listing and then another plugin that converts XML to JSON. If your PDFs are located in different folders then it get’s more tricky as you need to compile different listings together.

The hard part will be to use the JSON string as a dataset for however you plan to return match results on the search in the web form. Although those experienced in front-end web development might actually find this part easier if they aren’t experienced in using the Workflow.

Once the form has been submitted it should be pretty easy from there to grab the information you need to find and load the PDF to then be printed.

The below is just a basic general guide to help you start your project and does not include any error management. (I have used the Bootstrap framework to help with styling). So. feel free to customise, extend it to your needs.

DOWNLOAD EXAMPLE

Designer

With that said, start by creating a template with two Web sections:

The first section is a basic html form with an input field and a submit button. The form action is controlled by the submitPDF script:

results.attr(“action”, “http://127.0.0.1:8080/printpdf”);

<div class="container mr3 mt-3 display-3">
    <form id="submitpdf" class="mr-2" method="post">
        <div class="form-group">
            <label for="pdfname">PDF Name</label>
            <input id="pdfname" class="form-control" aria-describedby="pdfName" name="pdfname" placeholder="Enter PDF Name" type="text">
        </div>
        <button class="btn btn-primary" type="submit">Submit</button>
    </form>
</div>

The second section is just a confirmation page that the PDF has been submitted with an option to lookup another PDF. Once you click the button you redirected to the previous page\form. The button here is controlled by the PDFLookup script:

results.attr(“action”, “http://127.0.0.1:8080/pdflookup”);

<div class="container mr3 mt-3">
    <div class="row mt-4">
        <h3>Thank you, PDF has been submitted. </h3>
    </div>
    <div class="row mt-4"></div>
    <form id="pdflookup" class="mr-2" method="get">
        <div class="form-group">
            <button class="btn btn-primary" type="submit">Lookup another PDF</button>
        </div>
    </form>
</div>

Obviously, this is just a basic example with no error management. You could return different messages depending on whether the PDF has failed to submit, print…etc

Workflow

You will need one process starting with the HTTP Server Input that accepts two actions:

  • pdflookup calls the main page where the user can input the PDF name to be printed
  • printpdf returns the confirmation that the PDF has been submitted

You will notice the Job Infos %2 in the Other tab of the HTTP Server Input stores the Request Header (pdflookup or printpdf in this case)

The Text Condition on line 5 redirects the incoming request to the correct Section in the template

Running the example

To run the example:

Backup your current workflow configuration

Open the template and its datamapper config and send to workflow

Import the attached process to your workflow configuration {Click on Workflow Button > Import > Configuration Component). Import the process and the print queue PS_Output

Give the local variable %{workingDir} a path of your choice. The example uses C:\PDFLookup

Send the configuration to the local service

Head to your browser and enter: http://127.0.0.1:8080/pdflookup. You should be presented with the following page.

Enter a PDF name and hit submit. You should see the page below:

Hi Rod,

Great! thank you! I am going to look at it right now.

thank you again for your help with this, I’ll let you know how my progress will be on this project.

regards,

Koen

Edit, I made a slight change to the process by adding the %pdfname} local variable which I use in Load External File and for the name of the file in the PS_OUtput printer queue.

ok thanks. I do get an error now importing it in workflow.

It’s just a Send To Folder printer queue you can recreate yourself as follow:

Also note that the PDFs to lookup are assumed to be in the folder %{workingDir}\PDFs\ which is monitored by the Load External File.

ok, thank you. going to work on it now.

Hi,

just got time to work on this again.
I’m almost there:
I can search and get the result of a directory:
image

Result:

this list what’s within the folder.
Now I want the result to be clickable so the result can be send to the workflow.
I can’t figure out how, it seems simple.
here’s the html:

<table id="table" class="table-grid" data-column-resize="" data-hide-when-empty="" data-detail="detail" style="width:100%;" title="detail">
<tbody>
    <tr data-repeat="">
        <td class="data filename" style="width: 100%;">@f2@</td>
    </tr>
</tbody>