Main Content

zipTemplate

Package DOM HTML and PDF template in zip file

Description

example

zipTemplate(unzippedTemplateFolder) zips (compresses and puts in a zip file) the unzipped DOM template in unzippedTemplateFolder. The resulting zipped template file name is the name specified in unzippedTemplateFolder, plus the file extension htmtx or pdftx. The zipTemplate function zips all of the files in the unzipped template folder, including files in subfolders. The zipped template folder structure duplicates the folder structure of the unzipped template. The file names in the unzipped template must contain only ASCII characters.

Use this syntax if you created the unzipped template by unzipping a template created in any of these ways:

  • Used mlreportgen.dom.Document.createTemplate

  • Copied the template from a default DOM template

  • Created the template without using the DOM API or DOM templates and the zipped file complies with the conditions listed in “Tips”.

example

zipTemplate(zippedTemplate,unzippedTemplateFolder) zips the unzipped DOM template into the file specified by zippedTemplate.

zipTemplate(zippedTemplate,unzippedTemplateFolder,mainDocument) zips the unzipped DOM template into the file specified by zippedTemplate. Use the mainDocument argument to specify the name of main document in the unzipped template if the main document name in the unzipped template is not report.html or root.html and your document part template library file, if it exists, is in a file called docpart_templates.html.

example

zipTemplate(zippedTemplate,unzippedTemplateFolder,mainDocument,partTemplates) zips the unzipped DOM template into the file specified by zippedTemplate. Use this syntax when the unzipped template includes a document part template library file whose file name is not docpart_templates.html. You must specify mainDocument as the third argument, even if the main document file is called report.html or root.html.

Examples

collapse all

Zip the template myTemplate into a zip file called myTemplate.htmtx.

zipTemplate('myTemplate');

Zip the template myTemplate into a zip file called myReportTemplate.htmtx.

zipTemplate('myReportTemplate.htmtx','myTemplate');

Zip a template whose main part is mainpart.html and whose part template library file is documentpart_templates.html.

zipTemplate('myTemplate.htmtx','myTemplate',...
    'mainpart.html','documentpart_templates.html');

Input Arguments

collapse all

Path to folder containing unzipped template, specified as a character vector. The file names in the unzipped template must contain only ASCII characters.

Full path for the zipped DOM template, including the file extension .htmtx or .pdftx, specified as a character vector.

Main document file name, including the file extension, specified as a character vector.

Document part library file name, including the file extension, specified as a character vector.

Tips

  • If you created the unzipped template by unzipping a template created by using mlreportgen.dom.Document.createTemplate or copying the template from a default DOM template, you can use either of these syntaxes with no further action:

    zipTemplate(zippedTemplate,unzippedTemplateFolder)

    You can also use either of those two syntaxes if the unzipped template was created without using the DOM interface and the template complies with the following requirements.

    • The main document file is named either report.html or root.html.

    • The unzipped template either does not include a document part template library file, or it includes a document part template library file named docpart_templates.html.

    • The unzipped template stores images in a folder named images.

    If the unzipped template main document file is not named either report.html or root.html, use the mainDocument input argument.

    If the unzipped template includes a document part template library file with a name other than docpart_templates.html, use the partTemplates input argument.

    If the unzipped template stores images in a folder other than one named images in the root folder of the template, include a text file called _imgprefix in the folder that contains images for the unzipped template. In the _imgprefix file, you can include a prefix for the DOM interface to use to generate names images appended to documents. For example, if the _imgprefix file contains the prefix graphic, the generated image names are graphic1.png, graphic2.png, and so on. If you leave the _imgprefix file empty, then the generated images use the prefix image.

Version History

Introduced in R2014b