Error 255 when saving to PDF

Hello!

I have a simple document builder code:

builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This sample text is saved to the pdf.");
builder.SaveFile("pdf", "testfiles\Save.pdf");
builder.CloseFile();

I run “docbuilder.exe testpdf.docbuilder”, and error is occured:
error: : save file error (255)

What does it mean? What to do?

I noticed, if i delete the line “oParagraph.AddText(“This sample text is saved to the pdf.”);”, no error is occured, but I get an empty pdf document :slight_smile:

DocumentBuilder version: 7.4
Installation method: msi
OS: Microsoft Windows 10 version 10.0 (Build 14393)

Hello @Anton

Please note that symbols \ / : * ? " < > | cannot be used in the file name.
Try running the script with this line like that, for example:

builder.SaveFile("pdf", "testfiles_Save.pdf");

Hello, @Constantine

If I cannot use the symbols / \, how can I change the catalog where the file will be saved in?
I want the file to be saved in the catalog C:\ONLYOFFICE\DocumentBuilder\testfiles, how can i do this?

What I did:
I specified the file path in the method SaveFile, like this: builder.SaveFile("pdf", "testfiles\Save.pdf");
I ran docbuilder.exe via cmd in the catalog C:\ONLYOFFICE\DocumentBuilder

Could you please explain me this situation, i’m a little confused :slight_smile:

P.S. I try runnig with this line builder.SaveFile("pdf", "testfiles_Save.pdf"); and get the same error: error: : save file error (255)

You must use either an absolute or a relative path to the destination folder. For example:

builder.SaveFile("pdf", "C:\Program Files\ONLYOFFICE\DocumentBuilder\testfiles\Save.pdf");
builder.SaveFile("pdf", "./testfiles/Save.pdf");

Please try running Command Line from Administrator and check if it makes any difference.

1 Like

Please try running Command Line from Administrator and check if it makes any difference.

This helps me!!

Thank you a lot! :slight_smile:

1 Like

I’m glad to hear that it works!