Skip to main content
Participating Frequently
Aug 21, 2023 1:28 PM UTC
Question

Create PDF from dynamic HTML

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

31 replies

Participant
May 6, 2025 12:51 PM UTC

Hi,

 

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

Any info would be helpful

Translate
Participating Frequently
Jul 15, 2024 5:33 PM UTC

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

Translate
Raymond Camden
Community Manager
Community Manager
Jul 15, 2024 6:03 PM UTC

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.

Translate
Raymond Camden
Community Manager
Community Manager
Jul 15, 2024 6:26 PM UTC

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?

Translate
Joel Geraci
Community Expert
Community Expert
Aug 21, 2023 3:02 PM UTC

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

Translate
Participating Frequently
Aug 22, 2023 5:12 AM UTC

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

Translate
Participating Frequently
Aug 22, 2023 5:49 AM UTC

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"}
Translate