Skip to main content

CreateFile

Creates a new file. The type of the file which will be created needs to be set.

Syntax​

def CreateFile(self, type: int | str) -> bool

Parameters​

NameTypeDescription
typeint | strThe file type as a hexadecimal integer (OFFICESTUDIO_FILE_XXX values) or a string (docx, xlsx, pptx, pdf, form).
note

The pdf file type creates the same document as docx. To create a PDF form, pass the form file type to the CreateFile and SaveFile methods. The form content is edited with the Document API and the Form API. To edit an existing PDF file with the PDF API, open it with the OpenFile method.

Example​

import os
import docbuilder

builder = docbuilder.CDocBuilder()
builder.CreateFile("docx")

dstPath = os.getcwd() + "/result.docx"
builder.SaveFile("docx", dstPath)
builder.CloseFile()