How to use REST API PdfReactor / MS Flow Post Request

345 Views Asked by At

I would like to convert a simple html file to PDF using PDF Reactor and MS Flow.

I set up a PdfReactor running in a docker container.

Can somebody help me to get the http post request right to have PdfReactor convert the file to pdf?

Screenshot of the MS Flow I'm trying to build

PdfReactor Documentation

2

There are 2 best solutions below

0
On

NEW Flow HTTP Request Picture

With this request i was able to pass through the payload.

The content of the "html" Variable is going to look like this.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Inspectionlist 0583 / 16.05.2020</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.Stil1 {
 font-size: 36px;
 font-weight: bold;
}
.Stil11 {font-size: 44px}
.Stil12 {font-size: 36px}
-->
</style>
</head>

<body>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="39%"><div align="center" class="Stil1">
      <p><span class="Stil11">I n s p e c t i o n s </span> <br>
  16.05.2020<br>
        </p>
      </div></td>
    <td width="32%"><div align="center"><span class="Stil11"><span class="Stil12">Ship-No.:</span> <span class="Stil1">0583</span></span> <br>
      </div></td>
  </tr>
</table>

<table width="100%"  border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#999999">
  <tr bgcolor="#CCCCCC">
    <th width="20" scope="col"><strong>No.</strong></th>
    <th width="70" scope="col"><strong>Start of insp. </strong></th>
    <th width="70" scope="col"><strong>End of insp. </strong></th>
    <th width="30" scope="col"><strong>Class.</strong></th>
    <th width="30" scope="col"><strong>Yard</strong></th>
    <th width="30" scope="col"><strong>Owner</strong></th>
    <th width="158" scope="col"><strong>Responsible</strong></th>
    <th width="30" scope="col"><div align="center"><strong>BGN</strong></div></th>
    <th width="481" scope="col"><strong>Description</strong></th>
    <th width="130" scope="col"><strong>Pre-Inspection Yard </strong><strong>Contractor</strong></th>
  </tr>
 <tr>
    <td width="20"><div align="center"><span class="Stil8"></span></div></td>
    <td width="70"><div align="center"><span class="Stil8"><B><FONT SIZE="6">No Inspections!<B></FONT> </span></div></td>
    <td width="70"><div align="center"><span class="Stil8"></span></div></td>
    <td width="30"><div align="center"><span class="Stil8"></span></div></td>
    <td width="30"><div align="center"><span class="Stil8"></span></div></td>
    <td width="30"><div align="center"><span class="Stil8"></span></div></td>
    <td><div align="center"><span class="Stil8"></span></div></td>
    <td width="30"><div align="center"><span class="Stil8"></span></div></td>
    <td><p align="left" class="Stil3 Stil6"><strong>No.</strong>  &nbsp;&nbsp;<strong>Location:</strong>      <br><br>
      <br></p>
          </td>
    <td><div align="center"><span class="Stil8"><br>
    </span></div>      <div align="center"></div></td>
  </tr>
</table>
<center> printed on: 15.05.2020 - 19:15 </center>
</body>
</html>

After the conversion the pdf is not readable by e.g acrobat, do you guys know what i'm missing?

0
On

The payload for most of POST methods of the PDFreactor Web Service must be in XML, JSON or ZIP format (see also https://www.pdfreactor.com/product/doc_html/index.html#payload).

So you should set the „body“ of your request to a JSON like the following:

{
    document: "Your File Content"
}