Embedding print jobs in external web pages

The Euler platform allows you to embed print jobs directly into your application or website using an iFrame. This feature is perfect for integrating print job visualization into dashboards, internal tools, or external platforms.

Supported URLs

To embed a print job, you must use a Signed URL for one of the following paths:

  1. Embed by print ID:
    Use this URL format when you know the print ID:
    /app/[org-slug]/print/embed/[print-id]
  2. Embed by device and path:
    Use this URL format when referencing the device and print path:
    /app/[org-slug]/print/embed/ref/[device-slug]/[print-path]

These URLs must be signed to ensure secure and authorized access. For details on generating Signed URLs, refer to the Signed URLs Documentation.

Example code

Below is an example of how to embed a print job using an iFrame:

<iframe
  src="https://www.euler3d.com/app/my-org/print/embed/abc123?signed-url-parameters-here"
  width="1000"
  height="800"
  frameborder="0"
  allowfullscreen>
</iframe>

Notes

  • Replace my-org with your organization slug.
  • Replace abc123 with your print ID or the relevant device slug and print path.
  • Ensure the src attribute contains a valid Signed URL.

End-to-end example

This FastAPI application demonstrates how to securely embed print jobs from the Euler platform into a webpage using Signed URLs. By leveraging the create_signed_url function implemented in the Signed URLs Documentation, the app dynamically generates a secure URL for a given organization and print ID, then serves an HTML page with the Signed URL embedded in an iFrame.

from fastapi import FastAPI, HTTPException
from fastapi.responses import HTMLResponse
import os

# Import your signing logic
from .euler_signed_url import create_signed_url

app = FastAPI()

# Load credentials from environment variables
API_TOKEN_ID = os.getenv("API_TOKEN_ID")
API_SECRET = os.getenv("API_SECRET")

@app.get("/", response_class=HTMLResponse)
async def render_iframe(org_slug: str, print_id: str):
    try:
        # Generate the Signed URL
        url = f"https://www.euler3d.com/app/{org_slug}/print/embed/{print_id}"
        signed_url = create_signed_url(API_TOKEN_ID, API_SECRET, url, ttl_seconds=3600)
    except ValueError as e:
        raise HTTPException(status_code=400, detail=str(e))

    # Return the HTML page with the iframe
    html_content = f"""
    <!DOCTYPE html>
    <html>
    <head>
        <title>Embedded Print Job</title>
    </head>
    <body>
        <iframe src="{signed_url}" width="800" height="600" frameborder="0" allowfullscreen></iframe>
    </body>
    </html>
    """
    return HTMLResponse(content=html_content)

# Run the app using uvicorn (example: uvicorn main:app --reload)