Skip to content

Instantly share code, notes, and snippets.

View kinuasa's full-sized avatar

@kinuasa kinuasa

View GitHub Profile
@kinuasa
kinuasa / PdfSharpを使ってPDFフォームに入力するPower Automate for desktopフロー.robin
Created September 2, 2024 05:22
PowerShell経由でPdfSharpを使ってPDFフォームに入力するPower Automate for desktopフロー(動作確認:バージョン 2.47 ) 関連Webサイト:https://rpacommunity.connpass.com/event/329227/
SET DataTable TO { ^['氏名', '年齢', '連絡先'], ['テスト 花子', '25', 'hanahana@***.com'], ['テスト 太郎', '31', 'tarotaro@***.jp'], ['テスト 一郎', '42', 'ichiro@***.com'], ['テスト 次郎', '28', 'jiro@***.com'], ['テスト 花代', '19', 'hanayo@***.com'] }
SET TargetPdfFilePath TO $'''C:\\Test\\PDF\\入力フォームサンプル.pdf'''
SET SaveFolderPath TO $'''C:\\Test\\PDF\\output\\PDFsharp\\'''
SET LibFilePath TO $'''C:\\System\\Lib\\PdfSharp.dll'''
LOOP LoopIndex FROM 0 TO DataTable.RowsCount - 1 STEP 1
@@copilotGeneratedAction: 'False'
Scripting.RunPowershellScript.RunPowershellScript Script: $'''<#
PDFsharp
Install: nuget install PdfSharp -version 1.50.5147
@kinuasa
kinuasa / AcrobatJS_CSV_To_PDF_Field_Set_And_Save_As_Sample.js
Created September 2, 2024 05:15
CSVから読み込んだ値をフィールドに設定してPDFを別名保存するAcrobat JavaScriptのサンプルコード 関連Webサイト:https://rpacommunity.connpass.com/event/329227/
/* CSVデータ(1行目:見出し, フィールド名)を読み込みフォーム入力 */
var stream = util.readFileIntoStream("/C/Test/PDF/output/SrcData.csv");
var lines = util.stringFromStream(stream, "utf-8").split("\n");
var headers = lines[0].split(",");
lines.slice(1).forEach((line, i) => {
var values = line.split(",");
headers.forEach((header, j) => {
var field = this.getField(header);
if (field) field.value = values[j] || "";
});
@kinuasa
kinuasa / Microsoft Print to PDFプリンター経由でテキストファイルをPDFファイルに変換するPower Automate for desktopフロー.robin
Last active September 2, 2024 05:19
Microsoft Print to PDFプリンター経由でテキストファイルをPDFファイルに変換するPower Automate for desktopフロー(動作確認:バージョン 2.47 ) 関連Webサイト:https://rpacommunity.connpass.com/event/329227/
/# <セレクター例>
・印刷結果を名前を付けて保存ダイアログ(メモ帳)
:desktop > window > window[Class="#32770"] > window[Name*="名前を付けて保存"][Class="#32770"]
・名前を付けて保存ダイアログ(その他)
:desktop > window > window[Name*="名前を付けて保存"][Class="#32770"]
・ファイル名入力欄
> pane[Class="DUIViewWndClassName"] > combobox[Id="FileNameControlHost"] > edit[Class="Edit"]
@kinuasa
kinuasa / UploadFileToGoogleDriveUsingAPIClientLibrary.ps1
Created May 7, 2024 01:23
Google API Client Library for .NETを使用してGoogle ドライブにファイルをアップロードするPowerShellスクリプトです。エラー処理は含めていません。 関連Webサイト:https://powerusers.microsoft.com/t5/Power-Automate-Desktop/uploading-file-on-google-drive-using-api-Power-shell-script-PAD/td-p/2730269
Add-Type -AssemblyName "System.Web"
[void][Reflection.Assembly]::LoadFile("C:\System\Lib\Newtonsoft.Json.dll")
[void][Reflection.Assembly]::LoadFile("C:\System\Lib\Google.Apis.dll")
[void][Reflection.Assembly]::LoadFile("C:\System\Lib\Google.Apis.Core.dll")
[void][Reflection.Assembly]::LoadFile("C:\System\Lib\Google.Apis.Auth.dll")
[void][Reflection.Assembly]::LoadFile("C:\System\Lib\Google.Apis.Drive.v3.dll")
$clientId = "(Client ID)"
$clientSecret = "(Client Secret)"
$credentialPath = "C:\wk\GoogleAPI\client_secrets.json"
@kinuasa
kinuasa / FillingOutPdfFormsWithPdfSharp.ps1
Last active September 2, 2024 05:06
PdfSharpを使ってPDFフォームに入力するPowerShellスクリプトです。 関連Webサイト:https://powerusers.microsoft.com/t5/Power-Automate-Desktop/Entering-text-into-a-specific-field-for-a-pdf/td-p/2733417
<#
PDFsharp
Install: nuget install PdfSharp -version 1.50.5147
Copyright (c) 2001-2024 empira Software GmbH, Troisdorf (Cologne Area), Germany
http://docs.pdfsharp.net
MIT License
SET WindowsApplicationDriverPath TO $'''\"C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe\"'''
SET AppId TO $'''mspaint.exe'''
SET WindowsApplicationDriverUrl TO $'''http://127.0.0.1:4723'''
SET ImageFilePath TO $'''\"C:\\Test\\Image\\TEST.png\"'''
System.RunApplication.RunApplication ApplicationPath: $'''cmd''' CommandLineArguments: $'''/k %WindowsApplicationDriverPath%''' WorkingDirectory: $'''C:\\''' WindowStyle: System.ProcessWindowStyle.Normal ProcessId=> AppProcessId
Web.InvokeWebService.InvokeWebService Url: $'''%WindowsApplicationDriverUrl%/session''' Method: Web.Method.Post Accept: $'''application/json''' ContentType: $'''application/json''' RequestBody: $'''{\"desiredCapabilities\":{\"app\":\"%AppId%\",\"deviceName\":\"WindowsPC\",\"platformName\":\"Windows\"}}''' ConnectionTimeout: 30 FollowRedirection: True ClearCookies: False FailOnErrorStatus: False EncodeRequestBody: False UserAgent: $'''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20100312 Firefox/3.
SET WindowsApplicationDriverPath TO $'''\"C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe\"'''
SET AppId TO $'''Microsoft.WindowsCalculator_8wekyb3d8bbwe!App'''
SET WindowsApplicationDriverUrl TO $'''http://127.0.0.1:4723'''
System.RunApplication.RunApplication ApplicationPath: $'''cmd''' CommandLineArguments: $'''/k %WindowsApplicationDriverPath%''' WorkingDirectory: $'''C:\\''' WindowStyle: System.ProcessWindowStyle.Normal ProcessId=> AppProcessId
Web.InvokeWebService.InvokeWebService Url: $'''%WindowsApplicationDriverUrl%/session''' Method: Web.Method.Post Accept: $'''application/json''' ContentType: $'''application/json''' RequestBody: $'''{\"desiredCapabilities\":{\"app\":\"%AppId%\",\"deviceName\":\"WindowsPC\",\"platformName\":\"Windows\"}}''' ConnectionTimeout: 30 FollowRedirection: True ClearCookies: False FailOnErrorStatus: False EncodeRequestBody: False UserAgent: $'''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20100312 Firefox/3.6''' Encoding: Web.Encod
@kinuasa
kinuasa / 指定した日時から直近の平日を求めるPower Automate for desktopフロー.robin
Created February 29, 2024 06:56
指定した日時から直近の平日を求めるPower Automate for desktopフロー(動作確認:バージョン 2.41 ) 関連Webサイト:https://powerusers.microsoft.com/t5/Power-Automate-Desktop/Determining-the-date-of-the-most-recent-weekday/td-p/2630429
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
祝日一覧をデータテーブルに格納
※Google Calendar APIのような祝日を取得するAPIを利用しても可
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#/
SET HolidayTable TO { ^['Date', 'Summary'], ['2024-01-01', '元日'], ['2024-01-08', '成人の日'], ['2024-02-11', '建国記念の日'], ['2024-02-12', '建国記念の日 振替休日'], ['2024-02-23', '天皇誕生日'], ['2024-03-20', '春分の日'], ['2024-04-29', '昭和の日'], ['2024-05-03', '憲法記念日'], ['2024-05-04', 'みどりの日'], ['2024-05-05', 'こどもの日'], ['2024-05-06', 'こどもの日 振替休日'], ['2024-07-15', '海の日'], ['2024-08-11', '山の日'], ['2024-08-12', '休日 山の日'], ['2024-09-16', '敬老の日'], ['2024-09-22', '秋分の日'], ['2024-09-23', '秋分の日 振替休日'], ['2024-10-14', 'スポーツの日'], ['2024-11-03', '文化の日'], ['2024-11-04', '文化の日 振替休日'], ['2024-11-23', '勤労感謝の日'] }
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
# テスト用に日時設定
Text.ConvertTextToDateTime.ToDateTime Text: $'''2024/5/8''' DateTime=> CurrentDateTime
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
指定日の2日前から14日間さかのぼって祝休日かどうかの判定を行う
@kinuasa
kinuasa / kintoneにアップロードした添付ファイルを一括でダウンロードすフロー.robin
Created January 31, 2024 06:00
kintoneにアップロードした添付ファイルを一括でダウンロードするPower Automate for desktopフロー(動作確認:バージョン 2.40 )
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
APIトークンなどの変数設定
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#/
SET APIToken TO $'''(APIトークン)'''
SET SubDomain TO $'''(サブドメイン)'''
Text.FromNumber Number: 6 DecimalPlaces: 0 UseThousandsSeparator: False FormattedNumber=> AppID
SET SaveFolderPath TO $'''C:\\Test\\kintone\\Files'''
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
添付ファイルフィールドのフィールドコードをリストに設定
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#/
@kinuasa
kinuasa / PDFフォームへのデータ入力を自動化するPower Automate for desktopフロー.robin
Last active December 20, 2023 04:20
PDFtkを使ってPDFフォームへのデータ入力を自動化するPower Automate for desktopフロー(動作確認:バージョン 2.39 ) 関連Webサイト:https://note.com/kinuasa/n/nc93aefd55e87
SET PdfFolderPath TO $'''C:\\Test\\受領書'''
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
リストファイル読み込み
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#/
Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''%PdfFolderPath%\\受領書発行リスト.xlsx''' Visible: True ReadOnly: True Instance=> ExcelInstance
Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''受領書発行リスト'''
Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: FirstFreeColumn - 1 EndRow: FirstFreeRow - 1 ReadAsText: True FirstLineIsHeader: True RangeValue=> ExcelData
Excel.CloseExcel.Close Instance: ExcelInstance
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆