You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置MS Flow的Post请求调用Docker部署的PdfReactor REST API转HTML为PDF

Got it, let's walk through how to set up that HTTP POST request for PDFreactor in Docker with Microsoft Flow—this should get your HTML-to-PDF conversion working smoothly.

Step 1: Confirm Your Docker PDFreactor Endpoint

First, make sure you have the correct endpoint for your running PDFreactor container. By default, the REST API endpoint is:
http://<your-docker-host-ip>:9423/service/rest

To verify the service is reachable, you can test it with a simple curl command or Postman:

curl http://localhost:9423/service/rest

You should get a JSON response confirming the API is active. If not, double-check your Docker port mapping (you need -p 9423:9423 in your docker run command to expose the port).

Step 2: Configure the HTTP POST Request in Microsoft Flow

Now let's build the request in Flow:

  • Add an HTTP action to your Flow, set the method to POST
  • Paste your PDFreactor endpoint into the URI field
  • Under Headers, add a key-value pair:
    • Key: Content-Type
    • Value: application/json
  • For the Body, use a JSON payload tailored to your HTML source. Here are two common scenarios:

Scenario 1: Directly embed HTML content

If you have the HTML inline or stored as a variable in Flow, use this payload:

{
  "content": "<!DOCTYPE html><html><body><h1>My Converted PDF</h1><p>This is a test from Microsoft Flow + PDFreactor</p></body></html>",
  "outputFormat": "PDF",
  "pageSize": "A4",
  "margin": {"top": "2cm", "bottom": "2cm", "left": "1.5cm", "right": "1.5cm"}
}

Scenario 2: Pull HTML from a file (e.g., SharePoint)

If your HTML is stored in a file, first add a Get file content action to retrieve the HTML text, then reference it in the payload:

{
  "content": "@{body('Get_file_content')}",
  "outputFormat": "PDF"
}
Step 3: Save the Generated PDF

PDFreactor returns the PDF as binary data in the response body. To save it:

  • Add a Create file action (e.g., for SharePoint, OneDrive, or Azure Blob Storage)
  • Set the File content to the Body output from your HTTP action
  • Define a filename (e.g., converted-document.pdf)
Step 4: Troubleshooting Pro Tips
  • CORS Issues: If Flow throws a cross-origin error, update your PDFreactor Docker config to allow Flow's domain. You can add a CORS_ALLOWED_ORIGINS environment variable when starting the container.
  • External Resources: If your HTML references images/CSS from external URLs, ensure the Docker container has network access to those resources.
  • API Limits: Check PDFreactor's documentation for rate limits or payload size restrictions if you're converting large HTML files.

内容的提问来源于stack exchange,提问作者JaDDeL

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 14:17:46