GroupDocs.Viewer Javaで cdr を html、jpg、png、pdf に変換する
If you need to cdr を html に変換 (or to JPG, PNG, and PDF) quickly and reliably, you’ve landed on the right tutorial. In this guide we’ll walk through everything you need—from installing GroupDocs.Viewer for Java to rendering CorelDRAW (CDR) files into web‑friendly HTML pages, high‑quality images, and universally readable PDFs. By the end, you’ll be able to integrate these conversions into any Java application with just a few lines of code.

GroupDocs.Viewer for Javaで CDR ファイルをレンダリング
クイック回答
- CDR を HTML に変換するライブラリは何ですか? GroupDocs.Viewer for Java。
- CDR を JPG、PNG、PDF にも変換できますか? はい—同じ Viewer API を異なるビューオプションで使用します。
- ライセンスは必要ですか? テスト用には無料トライアルまたは一時ライセンスで動作しますが、本番環境では正式なライセンスが必要です。
- 必要な Java バージョンは? JDK 8 以上。
- バッチ変換はサポートされていますか? はい、同じ Viewer インスタンスでファイルをループ処理すれば可能です。
“cdr を html に変換” とは何ですか?
Converting cdr to html means transforming a CorelDRAW vector file into standard HTML markup, optionally embedding images and styles so the design can be viewed directly in a web browser without needing the original design software. The process preserves the original layout, colors, and vector shapes by converting them into scalable SVG elements or raster images embedded in the HTML, enabling accurate visual representation across browsers while keeping file size low.
なぜ cdr を html、jpg、png、または pdf に変換するのですか?
You can render a single CDR source into four widely supported formats, each serving a distinct purpose: HTML for instant web preview, JPG/PNG for raster images, and PDF for printable, archivable documents. This flexibility lets you serve the optimal file type to any client, reduce storage duplication, and future‑proof your assets.
前提条件
Before we start, make sure you have:
- ライブラリと依存関係 – Maven プロジェクトに GroupDocs.Viewer を追加します。
- Java Development Kit (JDK) – バージョン 8 以上がインストールされていること。
- 基本的な Java の知識 – コードスニペットを理解するために必要です。
必要なライブラリ、バージョン、依存関係
Add the following Maven configuration to your pom.xml (unchanged from the original tutorial):
<repositories>
<repository>
<id>repository.groupdocs.com</id>
<name>GroupDocs Repository</name>
<url>https://releases.groupdocs.com/viewer/java/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-viewer</artifactId>
<version>25.2</version>
</dependency>
</dependencies>
ライセンス取得手順
GroupDocs.Viewer は無料トライアル、テスト用の一時ライセンス、または正式購入オプションを提供しています:
- 無料トライアル – GroupDocs リリースページ からダウンロード。
- 一時ライセンス – GroupDocs 一時ライセンスページ でリクエスト。
- 購入 – GroupDocs 購入ページ から永続ライセンスを取得。
GroupDocs.Viewer for Java の設定
Viewer is the core class that loads a document and provides rendering methods for all supported output formats.
Maven でのインストール
The Maven snippet above will pull in all required JARs automatically. Just run mvn clean install after saving the file.
ライセンス初期化
Viewer is the core class that loads a document and provides rendering methods for all supported output formats. Initialize your license before rendering any documents:
import com.groupdocs.viewer.License;
License lic = new License();
lic.setLicense("path/to/your/license/file.lic");
実装ガイド
Below you’ll find step‑by‑step examples for each output format. The code blocks are identical to the original tutorial; we only added explanatory text around them.
GroupDocs.Viewer を使用して cdr を html に変換する方法
Load a CDR file and call the HTML rendering API – that’s all you need to generate web‑ready markup. The process requires setting up file paths, creating an HtmlViewOptions instance, and invoking viewer.view(). This two‑step pattern works for any document size and preserves vector fidelity.
CDR ドキュメントを HTML にレンダリング
概要: CDR ファイルをウェブフレンドリーな HTML に変換し、簡単に共有できるようにします。
ステップ 1 – ファイルパスの設定
import java.nio.file.Path;
Path outputDirectory = TestFiles.getOutputDirectoryPath("RenderingCdr");
Path pageFilePathFormat = outputDirectory.resolve("cdr_result_{0}.html");
ステップ 2 – Viewer の初期化とレンダリング
HtmlViewOptions は HTML レンダリングを構成し、リソースを埋め込むか別々に保存するかを設定できます。以下のコードは各ページを個別の HTML ファイルとしてレンダリングし、画像を Base64 文字列として埋め込みます。
import com.groupdocs.viewer.Viewer;
try (Viewer viewer = new Viewer(TestFiles.SAMPLE_CDR)) {
HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources(pageFilePathFormat);
viewer.view(options); // Render the document into HTML format
}
GroupDocs.Viewer を使用して cdr を jpg に変換する方法
You can produce high‑quality JPEG images from a CDR source in just two lines of code. First, configure JpgViewOptions with the desired quality, then call viewer.view(). This approach is ideal for thumbnails, email attachments, or any scenario where a compact raster image is needed.
CDR ドキュメントを JPG にレンダリング
概要: CDR ソースから高品質な JPEG 画像を生成します。
ステップ 1 – ファイルパスの設定
Path pageFilePathFormat = outputDirectory.resolve("cdr_result_{0}.jpg");
ステップ 2 – Viewer の初期化とレンダリング
JpgViewOptions は JPEG のレンダリング設定(圧縮品質や出力ファイル名など)を定義します。以下の例は各ページを個別の JPEG ファイルとして保存します。
import com.groupdocs.viewer.options.JpgViewOptions;
try (Viewer viewer = new Viewer(TestFiles.SAMPLE_CDR)) {
JpgViewOptions options = new JpgViewOptions(pageFilePathFormat);
viewer.view(options); // Render the document into JPG format
}
GroupDocs.Viewer を使用して cdr を png に変換する方法
PNG 出力はロスレスのラスタ画像を提供し、アーカイブやさらなるグラフィック処理に最適です。PngViewOptions を使用してすべてのピクセルを保持し、ドキュメントをページ単位でレンダリングします。
CDR ドキュメントを PNG にレンダリング
概要: アーカイブやデザイン目的のロスレス PNG 画像を生成します。
ステップ 1 – ファイルパスの設定
Path pageFilePathFormat = outputDirectory.resolve("cdr_result_{0}.png");
ステップ 2 – Viewer の初期化とレンダリング
PngViewOptions は PNG のレンダリングパラメータを指定し、透明背景のサポートも含みます。コードは自動的にページごとに PNG を作成します。
import com.groupdocs.viewer.options.PngViewOptions;
try (Viewer viewer = new Viewer(TestFiles.SAMPLE_CDR)) {
PngViewOptions options = new PngViewOptions(pageFilePathFormat);
viewer.view(options); // Render the document into PNG format
}
GroupDocs.Viewer を使用して cdr を pdf に変換する方法
Turning a CDR file into PDF gives you a universally readable, print‑ready document. PdfViewOptions handles vector to raster conversion internally, preserving layout and fonts without requiring Adobe Illustrator.
CDR ドキュメントを PDF にレンダリング
概要: CDR ファイルを汎用的に閲覧可能な PDF に変換します。
ステップ 1 – ファイルパスの設定
Path pageFilePathFormat = outputDirectory.resolve("cdr_result.pdf");
ステップ 2 – Viewer の初期化とレンダリング
PdfViewOptions は PDF の生成を制御し、フォント埋め込みやページレイアウトのカスタマイズを可能にします。このスニペットはすべてのページを含む単一の PDF を作成します。
import com.groupdocs.viewer.options.PdfViewOptions;
try (Viewer viewer = new Viewer(TestFiles.SAMPLE_CDR)) {
PdfViewOptions options = new PdfViewOptions(pageFilePathFormat);
viewer.view(options); // Render the document into PDF format
}
実用的な活用例
- Web ポータル: HTML 変換を使用して CDR デザインをサイトに直接埋め込む。
- 画像ギャラリー: JPG/PNG 出力を展開して高速ロードのギャラリーや製品カタログに使用する。
- ドキュメント共有: 印刷可能で読み取り専用のバージョンが必要なクライアント向けに PDF を提供する。
- アーカイブ: ソフトウェアの変更に関係なく将来のアクセス性を保証するために複数形式で保存する。
- クロスプラットフォーム統合: 生成されたファイルを OCR、分析、デジタル資産管理システムなどの下流サービスに供給する。
パフォーマンス上の考慮点
- Viewer インスタンスを速やかに破棄(try‑with‑resources の例のように)してメモリを解放します。
- バッチ処理: 同じ Viewer 設定で CDR ファイルのコレクションをループし、オーバーヘッドを削減します。
- リソース割り当て: GroupDocs.Viewer はファイル全体をメモリに読み込まずに最大 500 ページまでレンダリングできますが、非常に複雑な図面はヒープサイズの増加が有益な場合があります。大規模変換時は CPU と RAM の使用状況を監視してください。
よくある落とし穴とトラブルシューティングのヒント
- フォントが見つからない: 出力が異なる場合、サーバーに必要なフォントがあることを確認するか、
PdfViewOptionsで埋め込んでください。 - 大きなファイル: 200 MB を超える CDR ファイルは、
OutOfMemoryErrorを回避するためにページ単位で処理することを検討してください。 - 画像品質が不適切: JPEG が過度に圧縮されている場合は、
JpgViewOptionsのsetQuality値を調整してください。 - ライセンスエラー: ライセンスファイルのパスが正しいこと、ライセンスのバージョンが Viewer ライブラリのバージョンと一致していることを確認してください。
結論
GroupDocs.Viewer for Java を使用して cdr を html に変換する方法と、JPG、PNG、PDF への変換方法を示しました。簡潔なコードスニペットとベストプラクティスのヒントに従うことで、これらの変換を任意の Java ベースのワークフローに組み込み、ユーザーに柔軟で高品質な出力を提供できます。
次のステップ
- カスタムページサイズや透かしなどの高度なレンダリングオプションを試してみてください。
- 変換パイプラインを REST API と組み合わせて、オンデマンドのファイル変換を提供します。
- コミュニティに参加し、GroupDocs フォーラム で質問してください。
よくある質問
Q: パスワード保護された CDR ファイルを変換できますか?
A: はい。パスワードパラメータを受け取る Viewer インスタンスでファイルをロードします(API ドキュメント参照)。
Q: 一度に変換できるページ数に制限はありますか?
A: 明確な上限はありませんが、非常に大きなファイルはより多くのメモリを必要とする可能性があるため、ページ単位で処理することを検討してください。
Q: HTML 出力にフォントが埋め込まれますか?
A: HtmlViewOptions.forEmbeddedResources を使用すると、フォントは Base64 で埋め込まれ、ブラウザ間で一貫したレンダリングが保証されます。
Q: JPEG の品質はどのように制御しますか?
A: JpgViewOptions の setQuality(int) メソッドで 1〜100 の値を指定できます。
Q: Linux サーバーで CDR ファイルを変換できますか?
A: もちろんです。JDK がインストールされていれば、GroupDocs.Viewer はプラットフォームに依存しません。
最終更新日: 2026-08-19
テスト環境: GroupDocs.Viewer 25.2 for Java
作者: GroupDocs