/* Antenna House PDF Tool API V8.0 .NET Interface sample program 概要:画像ファイルのPDF化(90度回転) Copyright 2013-2026 Antenna House, Inc. */ using System; using PdfTkNet; namespace ImageToPdf_2 { class Program { static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("usage: ImageToPdf_2.exe image-file output-pdf"); return; } try { using (PtlParamInput inputImage = new PtlParamInput(args[0])) using (PtlParamOutput outputFile = new PtlParamOutput(args[1])) using (PtlPDFDocument doc = new PtlPDFDocument()) using (PtlPages pages = doc.getPages()) { // 画像のページ作成に使うパラメータクラス using (PtlParamImagePage paramImagePage = new PtlParamImagePage()) { // 画像の描画に使うパラメータクラス using (PtlParamDrawImage paramDrawImage = new PtlParamDrawImage()) { // 回転角度を設定 paramDrawImage.setRotate(90); // 入力画像ストリームの設定 paramDrawImage.setImageStream(inputImage); // ページに挿入する画像パラメータの設定。 paramImagePage.setImage(paramDrawImage); } // 用紙タイプの設定 PAPER_IMAGE_SIZE /* 画像サイズに合わせる */ paramImagePage.setPaperType(PtlParamImagePage.PAPER_TYPE.PAPER_IMAGE_SIZE); // ページの追加 pages.append(paramImagePage); } // ファイルに保存します。 doc.save(outputFile); } } catch (PtlException pex) { Console.WriteLine(pex.getErrorCode() + " : " + pex.getErrorMessageJP()); pex.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine("-- 完了 --"); } } } }