Javaを介してPDFをPSDに変換する

Adobe ® Acrobat Readerを使用せずに、Java J2SE、J2EE、J2MEアプリケーション内の任意の場所でPDFファイルをPSDにエクスポートします。

 

2つの簡単なステップでpdfファイルをJavaでPSD画像に変換できます。まず、 Aspose.PDF for Java を使用すると、PDFをJPEGにエクスポートできます。その後、 Aspose.Imaging for Java Image Processing APIを使用して、JPEGをPSDにレンダリングできます。どちらのAPIも、 Aspose.Total for Java パッケージに含まれています。

Java経由でPDFをPSDにエクスポート

  1. ドキュメント クラスを使用してPDFファイルを開きます
  2. JpegDeviceクラスオブジェクトを初期化し、 Process を使用してPDFをJPEGにレンダリングしますメソッド。
  3. Image クラスを使用してJPEGファイルをロードします
  4. save 方法

変換要件

Maven ベースのプロジェクトから直接Aspose.Total for Javaを簡単に使用できますそして、pom.xmlにライブラリを含めます。

または、 ダウンロード からZIPファイルを取得することもできます。

// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats
// load PDF with an instance of Document
Document document = new Document("input.pdf");
// create an object of JpegDevice
JpegDevice renderer = new JpegDevice();
// convert first of a particular PDF page to JPEG format
renderer.process(document.getPages().get_Item(1), "output.jpeg");
// load JPEG file
Image image = Image.Load("output.jpeg");
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats
// save JPEG to PSD file format
image.save("output.psd", new PsdOptions());

Javaを介して単一ファイルでPDFをPSDに変換する

APIを使用すると、PDFファイルをPSDの単一ファイルにエクスポートすることもできます。すべてのページを変換するには、最初にPDFドキュメントを1つのTIFFファイルにレンダリングし、その後、TIFFファイルをPSDにエクスポートできます。 Document クラスを使用して入力ファイルを開き、Resolution、TiffSettings、およびTIFFデバイスオブジェクトを作成できます。 process を使用して単一のTIFF画像を取得できますjava.io.OutputStream TiffDevice クラスのメソッド。最後に、 Image クラスを使用してTIFFファイルをロードし、 save メソッド。

// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats
// load PDF with an instance of Document
Document pdfDocument = new Document("input.pdf");
// Create Resolution object
Resolution resolution = new Resolution(300);
// Create TiffSettings object
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.setCompression(CompressionType.None);
tiffSettings.setDepth(ColorDepth.Default);
tiffSettings.setShape(ShapeType.Landscape);
// Create TIFF device
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
// Convert a particular page and save the image to stream
tiffDevice.process(pdfDocument, 1, 1, "output.tif");
// load TIFF file
Image image = Image.Load("output.tif");
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats
// save TIFF to PSD file format
image.save("output.psd", new PsdOptions());

Javaを介して透かし付きのPDFをPSDに変換する

APIを使用して、PSDドキュメントに透かしを入れたPDFファイルをPSDにエクスポートすることもできます。透かしを追加するには、最初にPDFをJPEGに変換し、透かしを追加します。透かしを追加するには、 Image クラスを使用して画像ファイルを読み込み、 Graphics クラスをImageオブジェクトで初期化し、新しい[Matrix]( https://reference.aspose.com/imaging/java/ com.aspose.imaging/Matrix)オブジェクトを作成し、変換と変換を目的の角度に設定し、 Graphics.drawString メソッド。画像に透かしを追加した後、JPEGをPSD形式で保存できます。

// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats
// load PDF with an instance of Document
Document document = new Document("input.pdf");
// create an object of JpegDevice
JpegDevice renderer = new JpegDevice();
// convert first of a particular PDF page to JPEG format
renderer.process(document.getPages().get_Item(1), "output.jpeg");
// load JPEG
Image image = Image.load("output.jpeg");
// create and initialize an instance of Graphics class
Graphics graphics= new Graphics(image);
// create an instance of Font
Font font = new Font("Times New Roman", 16, FontStyle.Bold);
// create an instance of SolidBrush and set its properties
SolidBrush brush = new SolidBrush();
brush.setColor(Color.getBlack());
brush.setOpacity(100);
Size sz = graphics.getImage().getSize();
// create an object of Matrix class for transformation
Matrix matrix = new Matrix();
// first a translation then a rotation
matrix.translate(sz.getWidth() / 2, sz.getHeight() / 2);
matrix.rotate(-45.0f);
// set the Transformation through Matrix
graphics.setTransform(matrix);
// draw a string using the SolidBrush and Font objects at specific point
graphics.drawString("Watermark by Aspose.Imaging for Java", font, brush, 0, 0);
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats
// save JPEG to PSD file format
image.save("output.psd", new PsdOptions());

Javaを介してPDFをPSDファイルに変換および回転

APIを使用すると、必要に応じて出力PSD画像を回転させることもできます。 Image.rotateFlipメソッドを使用すると、画像を90/180/270度回転し、画像を水平または垂直に反転できます。ライブラリは、すべての醜い詳細をカプセル化しながら、複雑な操作を実行するための簡単なメソッドを提供します。画像に適用する回転と反転のタイプを指定できます。画像を回転および反転するには、 Image クラスを使用して変換されたJPEG画像をロードし、Imageを呼び出すことができます。適切な RotateFlipType を指定しながらrotateFlipメソッド。

// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats
// load PDF with an instance of Document
Document document = new Document("input.pdf");
// create an object of JpegDevice
JpegDevice renderer = new JpegDevice();
// convert first of a particular PDF page to JPEG format
renderer.process(document.getPages().get_Item(1), "output.jpeg");
// load JPEG file
Image image = Image.Load("output.jpeg");
// roate image
image.RotateFlip(RotateFlipType.Rotate270FlipNone);
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats
// save JPEG to PSD file format
image.save("output.psd", new PsdOptions());

PDF の変換オプションを Java で探索

PDF を APNG に変換 (アニメーション化されたポータブル ネットワーク グラフィックス)
PDF を DICOM に変換 (医療におけるデジタル イメージングと通信)
PDF を DXF に変換 (Autodesk 図面交換フォーマット)
PDF を EMZ に変換 (Windows 圧縮拡張メタファイル)
PDF を IMAGE に変換 (画像ファイル)
PDF を JPEG2000 に変換 (J2K画像フォーマット)
PDF を SVGZ に変換 (圧縮されたスケーラブルなベクター グラフィックス)
PDF を TGA に変換 (Truevision グラフィックス アダプター)
PDF を WMF に変換 (Windows メタファイル)
PDF を WMZ に変換 (圧縮された Windows メタファイル)
PDF を CSV に変換 (カンマ区切りの値)
PDF を DIF に変換 (データ交換フォーマット)
PDF を EXCEL に変換 (スプレッドシートのファイル形式)
PDF を FODS に変換 (OpenDocument フラット XML スプレッドシート)
PDF を MD に変換 (マークダウン言語)
PDF を ODS に変換 (OpenDocument スプレッドシート)
PDF を SXC に変換 (StarOffice Calc スプレッドシート)
PDF を TSV に変換 (タブ区切りの値)
PDF を TXT に変換 (テキストドキュメント)
PDF を XLAM に変換 (Excel マクロ有効アドイン)
PDF を XLSB に変換 (Excel バイナリ ワークブック)
PDF を XLSM に変換 (マクロが有効なスプレッドシート)
PDF を XLTM に変換 (Excel マクロ有効テンプレート)
PDF を XLTX に変換 (Excel テンプレート)
PDF を XLT に変換 (Excel 97 - 2003 テンプレート)
PDF を DOCM に変換 (Microsoft Word 2007 マルコ ファイル)
PDF を DOT に変換 (Microsoft Wordテンプレートファイル)
PDF を DOTM に変換 (Microsoft Word 2007+ テンプレート ファイル)
PDF を DOTX に変換 (Microsoft Wordテンプレートファイル)
PDF を FLATOPC に変換 (Microsoft Word 2003 ワードプロセッサML)
PDF を GIF に変換 (グラフィカル交換フォーマット)
PDF を MARKDOWN に変換 (軽量マークアップ言語)
PDF を ODP に変換 (OpenDocument プレゼンテーション形式)
PDF を ODT に変換 (OpenDocument テキスト ファイル形式)
PDF を OTP に変換 (OpenDocument標準フォーマット)
PDF を OTT に変換 (OpenDocument テンプレート)
PDF を PCL に変換 (プリンターコマンド言語)
PDF を POT に変換 (Microsoft PowerPoint テンプレート ファイル)
PDF を POTM に変換 (Microsoft PowerPoint テンプレート ファイル)