With Wordware, tasks that would take software engineers hours or days can be done in minutes. In this recipe, we’ll show you how to add a file input, upload a PDF, and how to interact with it in only 5 steps, no coding required.

Steps

1

Create a New File Input

Start by creating a new Input. Select Input type “File” and File type “PDF DOCUMENT”. Don’t forget to give your input a name! I called mine PDF Input, but it could also make sense to indicate what it is, like “resume” or “report”.

2

Mention the File Input in the Flow

In the editor, type @ to bring up the mention options, and select the PDF Input you just created. Hit Enter. Normally this would create a mention node, but since most AI models can’t “see” files like that we instead add a PDF tool node to process the file first, and then mention the markdown output. Your pdf file is automatically added to the tool, and the tool label is based on the input name. Feel free to change that if you want to.

3

Add a generation, upload the file and run the flow!

Add a simple instruction below the @markdown mention and add a /generation node. Then, click the Input bar and use the File Input field to upload a PDF.

Now, let’s run the flow!

4

Parse the PDF, inspect the markdown result and verify the generation output

Parsing the PDF can take some time, so hang in there! If you parse the same file again the result is usually faster. The @PDF Input.markdown node is replaced by the markdown output of the PDF tool in the runner and fed into the generation node along with the static instruction. The blue line demarcates the generation output from the model.

5

Success!

At this point, you’ve got a working PDF parsing setup! Try it with a different file, or even multiple files in one flow, or across multiple sub flows. Read on to learn of other ways to interact with the PDF tool.

Working with the document page by page

Referencing the full markdown is the most straightforward approach, but for some use cases, you might want to interact with the document page by page. Again, start by opening the mention menu with @. When you select .pages we automatically insert a full loop node for you, along with a mention nodes for the particular page markdown, as well as images detected on that page. Now when you run the flow you can see everything appearing in order, and you could insert these mentions into sub flows to analyze them in isolation.

Interacting with pages as images

If the markdown output is not enough you can actually also interact with the pages as images. Simply flip the toggle “Include pages as images” in the tool node

Now you can access the .screenshots mention, as well as item.pageAsImage inside the loop node. .screenshots is rendered as a list of images and can be passed to models with vision capabilities.

The item.pageAsImage can be used to add the page image as context inside the loop.

Putting it all together

Ok, let’s make the most complete example yet. We’ll add a file input, parse the PDF, loop through the pages and input the markdown and screenshot for each page into a sub flow, and output the results. The sub flow we use: