Aspose.Total for C++ を使用すると、2つの簡単な手順でC++アプリケーション内のJSONをMOBIに解析できます。まず、 Aspose.Cells for C++ を使用すると、JSONをPDFにエクスポートできます。その後、 Aspose.Words for C++ を使用して、PDFをMOBIに変換できます。
JSON形式をC++でMOBIに変換する
変換要件
VisualStudioのパッケージマネージャーコンソールからInstall-PackageAspose.Total.Cpp
を使用してインストールします。
または、 ダウンロード からオフラインMSIインストーラーまたはDLLをZIPファイルで取得します。
// Load the JSON. | |
intrusive_ptr<Aspose::Cells::IWorkbook> wkb = Factory::CreateIWorkbook(u"sourceFile.json"); | |
// Save in PDF format. | |
wkb->Save(u"convertedFile.pdf", SaveFormat_Pdf); | |
// Load the PDF. | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"sourceFile.pdf"); | |
// supports DOC, DOT, DOCM, DOTX, DOTX, FLATOPC, RTF, WordML, MOBI, CHM, ODT, OTT, PS, PCL, EPUB file formats | |
// Save in DOC format. | |
doc->Save(u"convertedFile.doc"); |
C++でレイアウトを設定してJSON形式をMOBIに変換する
JSONをMOBIに解析するときに、 IWorkbook クラスを使用してJSONをロードすることにより、行と列のサイズを設定することもできます。ワークシートのすべての行に同じ行の高さを設定する必要がある場合は、 SetStandardHeight ICells コレクションのメソッド。同様に、ワークシートのすべての列に同じ列幅を設定するには、ICellsコレクションの SetStandardWidth メソッドを使用します。
// Load the JSON. | |
intrusive_ptr<Aspose::Cells::IWorkbook> wkb = Factory::CreateIWorkbook(u"sourceFile.json"); | |
// accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// setting the height of all rows in the worksheet to 25 | |
worksheet->GetICells()->SetStandardHeight(25); | |
//Setting the width of all columns in the worksheet to 20.5 | |
worksheet->GetICells()->SetStandardWidth(20.5); | |
// save in PDF format. | |
wkb->Save(u"convertedFile.pdf", SaveFormat_Pdf); | |
// Load the PDF. | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"sourceFile.pdf"); | |
// supports DOC, DOT, DOCM, DOTX, DOTX, FLATOPC, RTF, WordML, MOBI, CHM, ODT, OTT, PS, PCL, EPUB file formats | |
// Save in DOC format. | |
doc->Save(u"convertedFile.doc"); |
C++で透かしを使用してJSON形式をMOBIに変換する
APIを使用して、透かしを使用してJSONをMOBIに解析することもできます。 MOBIドキュメントに透かしを追加するには、最初にJSONをPDFに変換して、透かしを追加します。透かしを追加するには、 ドキュメント クラスを使用して新しく作成したPDFファイルを読み込み、テキスト透かしにさまざまなプロパティを設定します。 SetTextメソッドを呼び出し、TextWatermarkOptionsの透かしテキストとオブジェクトを渡します。透かしを追加した後、ドキュメントをMOBIに保存できます。
// Load the JSON. | |
intrusive_ptr<Aspose::Cells::IWorkbook> wkb = Factory::CreateIWorkbook(u"sourceFile.json"); | |
// Save in PDF format. | |
wkb->Save(u"convertedFile.pdf", SaveFormat_Pdf); | |
// Load the PDF. | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"sourceFile.pdf"); | |
// Set different properties for text watermark | |
auto options = System::MakeObject<TextWatermarkOptions>(); | |
options->set_FontFamily(u"Arial"); | |
options->set_FontSize(36); | |
options->set_Color(System::Drawing::Color::get_Black()); | |
options->set_Layout(WatermarkLayout::Horizontal); | |
options->set_IsSemitrasparent(false); | |
// Set text for the watermark | |
docx->get_Watermark()->SetText(u"Test", options); | |
// supports DOC, DOT, DOCM, DOTX, DOTX, FLATOPC, RTF, WordML, MOBI, CHM, ODT, OTT, PS, PCL, EPUB file formats | |
// Save in DOC format. | |
doc->Save(u"convertedFile.doc"); | |