Skip to main content
Participating Frequently
August 21, 2023
Question

Create PDF from dynamic HTML

  • August 21, 2023
  • 3 replies
  • 4055 views

Hi Team, I need to create pdf from dynamic html.
So I have HTML file, inline CSS and json data.

How I can  use new rest API's to create PDF.
I tried following steps - 
1.Create a zip file from html, css and json file.

2.Generate access token.

2.Upload them to adobe cloud and get asset ID.

3.Call api- https://pdf-services-ue1.adobe.io/operation/htmltopdf

but it's not working.

Can any one help me on this? As new rest api documentation is not clear

3 replies

Participant
May 6, 2025

Hi,

 

Was this issue resolved. We too have a similar issue for one specific case.

Any info would be helpful

Participating Frequently
July 15, 2024

Hi Raymond, it's blocking us in PROD environment. can you please help?

Raymond Camden
Community Manager
Community Manager
July 15, 2024

I'm working with someone else who sent me some sample HTML, but no data. If you can quickly send me a MINIMAL example that includes the HTML + all assets, ie, the zip, and your data, I will try to reproduce.

Raymond Camden
Community Manager
Community Manager
July 15, 2024

Query, the other person's HTML is missing this:

 

 <script src='./json.js' type='text/javascript'></script>

 

Can you confirm if your templates have this?

Joel Geraci
Community Expert
Community Expert
August 21, 2023

Are you bundling the JSON in the ZIP? If you run the index.html file from localhost does it display properly?

Participating Frequently
August 22, 2023

Yes, I am builiding json in zip.
Yes, If I run index.html from localhost it displaying properly.

Participating Frequently
August 22, 2023

My steps - 

1.To get access token
 
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=<client_id>' \
--data-urlencode 'client_secret=<client_secret>'
 
resp - it is returning access-token
 
2.To get upload URI and asset id
 
curl --location --request POST 'https://pdf-services.adobe.io/assets' \
--header 'X-API-Key: <client_id>' \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "mediaType": "application/json"
}'
 
resp - upload_uri and assest_id
 
3.to upload file
 
curl -i --location -g --request PUT '<presigned upload url>' \
--header 'Content-Type: application/json' \
--data-binary '<zip_file_path>'
 
resp - status - 200
 
4.To create pdf
 
curl -i --location --request POST 'https://pdf-services.adobe.io/operation/htmltopdf' \
--header 'x-api-key: <client_id>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <access_token>' \
--data-raw '{
    "assetID": "<assest_id>",
    "json": "{}"
    "includeHeaderFooter": true,
    "pageLayout": {
        "pageWidth": 11,
        "pageHeight": 8.5
    }
}'
 
 
resp - HTTP/1.1 400 Bad Request
{"reason":"Validation error Request id: wdqkjdc.","message":"Bad Request"}