添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Do you want to: Suggest a feature / Report a bug / Ask a how-to question
For feature suggestions, describe the result you would like to achieve in detail:
For bug reports, provide the steps to reproduce and if possible a minimal demo of the problem:
Use this code:
builder.SetTmpFolder(".")
builder.OpenFile(“test.pdf”);
builder.SaveFile(“jpg”, “image.jpg”);
builder.CloseFile();

Actual result: error (save): file not opened!
Expected result: image.jpg file with first page of pdf.

DocumentBuilder version: 7.4.0
Installation method: installer (docbuilder_x64.exe).
OS: Win 10

This error usually means that the file wasn’t found. Please check the name of the file that you are opening and the directory that you are setting up a temp folder with SetTmpFolder method.

Also, check out this page to find out how to save the document into image formats:
https://api.onlyoffice.com/docbuilder/integrationapi/net/cdocbuilder/savefile

Update : Document Builder does not support opening of PDF since basically nothing can be done with it. Please use any other format, for instance, DOCX.

By the way, keep in mind that Document Builder does not serve as a conversion service hence cannot perform certain actions as a complete converter.

As a workaround, it is possible to get image as a thumbnail of the document as it is shown in the documentation:

.docbuilder

builder.SaveFile("image", "./thumbnail.png", "<m_oThumbnail><format>4</format><aspect>1</aspect><first>false</first><width>1000</width><height>1000</height></m_oThumbnail>");

The format parameter is responsible for resulting image format:

  • format - the image file format used to create a thumbnail (can be of the following values: 3 - for a JPG file, 4 - for a PNG file);
  • That said, since you are using .docbuilder scripting, here is example of script that will make a JPG image of the first page of the document:

    builder.OpenFile("Sample.docx");
    builder.SaveFile("image", "./Sample.jpg", "<m_oThumbnail><format>3</format><aspect>1</aspect><first>true</first><width>1000</width><height>1000</height></m_oThumbnail>");
    builder.CloseFile();
    

    By the way, both articles reference the same functionality but in different programming languages.

    Let me know if misunderstand your request.