Showing results for 
Search instead for 
Did you mean: 

Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!

Input PDFs (they are images)


Hello all!


I am a bit stuck, I originally posted this in the designer forums but did not get many responses. 


The problem I have is: We currently receive pdf documents which have been faxed to us. These are hand written order forms. We need to take these forms and run some form of handwriting OCR on them to help our data input guys out.


My idea is to write a python tool which can convert the pdf to a jpg. We can then take this jpg and upload it to either azure or google ocr then get the results back. We have tested the azure ocr and it worked great.


So far I have written the python which does the pdf to jpg and am trying and failing to make this into a tool in alteryx (At the moment I am getting a "typeError:__init__ () takes 2 positional arguments but 4 were give" but i think i can work this out).


Can someone please advise if what I am doing will actually work or if there is a better way to do this?


Thank you!





This is a really cool use case!


I think what you want to do is certainly very possible, it's just a matter of the implementation details.  At the moment I see 2 possible ways to get the data into the custom tool:

1. Import the PDFs as BLOBs using the Blob Input developer tool.  The Python tool can then use the raw byte data to convert to jpg and send to the appropriate cloud API

2. Send the Python tool a list of filenames.  For each file name, the tool can import the PDF, convert to JPG, and send it to the API


Which method you use really depends on the nature of the API and the PDF-to-JPG package you chose.  Most likely, 2 will be the easiest option.


What kind of data is returned from the Azure/Google API?


I would encourage you to give it a go.  If you run into any issues or errors, you can post them in this forum.  There is a bit of a trick to munge your Python code into a custom tool, but there are lots of smart people here to help.


Hi @tlarsen7572 


So I have managed to get my python working but with a error. I have attached the yxi file, this is ugly, i made this following the beginngers guide to python tools. This is currently giving me the error below.


Error: Python Convert PDF to Jpeg (7): Traceback (most recent call last):
File "", line 171, in ii_push_record
Boost.Python.ArgumentError: Python argument types in
OutputAnchor.push_record(OutputAnchor, str)
did not match C++ signature:
push_record(class SRC::Python::OutputAnchor {lvalue}, class boost::shared_ptr<struct SRC::Python::ConstRecordRef> record, bool no_auto_close=False)


If anyone could help with how to fix this i would appreciate it! The way this tool works is you can drop a text input tool in front of it with the file location of a pdf. This will then create in the same location a jpg.


With regards to the data from azure this comes back as json which should be ok to parse out.





Very close, see attached for a corrected python file (in a txt extension, because Alteryx's forum doesn't like me attached python scripts...).  All of my changes have comments preceding them, so I hope they are easy to find.  In summary, the changes I made were:


  1. When you add the summary field to the record info in ii_init, save the field instance to a property.  We will use that instance later to populate the string value.
  2. In ii_push_record, you are assigning the out_record to a string.  This is invalid; out_record needs to be a recordref object.
  3. In your if statement in ii_push_record, populate the summary field with the set_from_string function
  4. Just after the if statement in ii_push_record, create the out_record recordref object by calling finalize_record on your record creator.


Now everything should least it does on my system.


Thank you so much @tlarsen7572 I have attached my tool which successfully converts pdfs to jpegs. I have tested with the directory tool and it worked great!


Thank you again for your help on this! Here is the tool!






Hi @tlarsen7572 


Just a update for you as i know you were interested. I have successfully completed this now! I am using the read api on azure, this makes it a little more complicated because you have to post, then use a get to get the results as it has some processing time. This has worked amazingly well.





Thanks for sharing the update, @clant!  This is a really cool use-case for Alteryx, I am glad you were able to get it working.  I am bookmarking this thread in case I ever have to do any kind of OCR extraction.  As a department (Internal Audit), we sometimes have to deal with PDF/paper docs; I could see this being very helpful around things like contract analysis.  Definitely next-level stuff.

Hi @clant, currently I am trying to do exactly what you did, but after reading this thread and downloading your zip file, i still dont really get how the whole thing works on Alteryx. Do you mind sharing your workflow or elaborate further of how this (python script) is incorporated into Alteryx before utilizing read api on azure?


Thank you in advance for your help. Appreciate it.