3- SVG – Exporting a Print Ready File

SVG Preparation

 

Placeholder support

The Expivi Configurator supports the removal of elements that should not be visualized. These elements include placeholders, explanation texts within the SVG texture themselves, and backgrounds that should not be included in the print export.

All elements within the SVG texture that are marked with the data-placeholder=”true” XML attribute are excluded when requesting the print export. These elements can be made visible however while the visitor is configuring the 3D model.

Printmark support

Similar to the support for placeholders, the Expivi Configurator also supports print marks. These are essential lines and markings for printers that should not be visible to the visitor.

All elements within the SVG texture that are marked with the data-printmark=”true” XML attribute are included when requesting the print export. These elements are not visible while the visitor is configuring the 3D model.

Exporting a Print Ready File

In order to obtain a print ready file for a configuration, the configuration bundle must first be obtained from the Expivi Configurator. This can typically be done by calling:

const configuration_bundle = await window.expivi.saveConfiguration();

This configuration must be sent towards the Expivi backend in order to make the resources available for conversion. This is done by POSTing the configuration in the following manner:

curl -X POST \
  -H "Content-type: application/json"
  -H "Authorization: Bearer <token>"
  -d @body.json \
  https://expivi.net/api/configured_product/bundle

This returns a mapping of the configured product uuids to a number, which is the ID of the configured product in the backend. For example:

[
  "cfc55944-c3cc-4d6b-9e08-4d7b72d5a122": 1234567
]

An API token with write access (such as the Team Owner role) is required to access this endpoint. This API token must never be exposed publicly.

The configuration will only remain available for a period of 3 months. Any operations that work on this resource will fail after this period.

Internally, each print ready file within a product is associated with a media ID. These are referenced within the configured product in the configuration bundle obtained in the first step.

For each media ID in a configured product, a conversion request must be sent to the back end in the following manner:

curl -X POST \
  -H "Content-type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d @body.json \
  https://expivi.net/api/svg/conversion/request/{format}

The output format of the request is determined by the format parameter, which currently supports:

  • PNG
  • PDF
  • SVG
  • TIFF
  • (coming soon: WebP, JPG/JPEG)

The body of the the request should be as follows:

{
    "configured_product_id": <int> = Identifier of configured product (step 2).
    "media_id": <int> = Identifier of svg.
    "resolution": <number> = Used to describe resolution of image (min=0, max=6144),
    "dpi": <number | optional | default: 300> = Density per inch; used to describe resolution of image.
    "hide_placeholders": <boolean | optional | default: false> = Hide placeholders defined in SVG.
    "hide_print_marks": <boolean | optional | default: false> = Hide print markings defined in SVG.
}

This request returns a response of the following format:

{
    "hash": <string> = UUID hash of job. This identifier can be used to request job progress.
    "status": <"in_progress" | "complete" | "not_processing" | "failed"> = Status of job.
    "files": [
        <string> = Url to the converted file.
    ]
}

The hash can be used to retrieve the status of the conversion. This request should be used in a polling factor where the status is used to verify if the job is finished.

The request to check the conversion status will return the same response format as above:

curl -X GET \
  -H "Content-type: application/json" \
  -H "Authorization: Bearer <token>" \
  https://expivi.net/api/svg/conversion/check/{hash}

Once the status is “complete”, the response will contain a URL in the “files” array, at which the converted file can be downloaded.

No authorization is needed to download the resulting file.