Created
September 2, 2024 05:28
-
-
Save kinuasa/86af4f027da2f5f672af3c59e42bf744 to your computer and use it in GitHub Desktop.
Power Automate for desktopによるPDF処理のサンプルフロー(動作確認:バージョン 2.47 ) 関連Webサイト:https://rpacommunity.connpass.com/event/329227/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /# ★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆ | |
| PDF処理のサンプルフロー | |
| ★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#/ | |
| **REGION PDFファイルからテキストを抽出 | |
| Pdf.ExtractTextFromPDF.ExtractText PDFFile: $'''C:\\Test\\PDF\\テスト用PDFファイル(テキスト有り).pdf''' DetectLayout: False ExtractedText=> ExtractedPDFText | |
| Display.ShowMessageDialog.ShowMessage Title: $'''取得したテキスト''' Message: ExtractedPDFText Icon: Display.Icon.Information Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed | |
| Pdf.ExtractTextFromPDF.ExtractText PDFFile: $'''C:\\Test\\PDF\\テスト用PDFファイル(テキスト無し).pdf''' DetectLayout: False ExtractedText=> ExtractedPDFText | |
| Display.ShowMessageDialog.ShowMessage Title: $'''取得したテキスト''' Message: ExtractedPDFText Icon: Display.Icon.Information Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed | |
| **ENDREGION | |
| **REGION PDFファイルからテーブルを抽出 | |
| Pdf.ExtractTablesFromPDF.ExtractTablesFromPage PDFFile: $'''C:\\Test\\PDF\\テスト用PDFファイル.pdf''' PageNumber: 3 MultiPageTables: True SetFirstRowAsHeader: True ExtractedPDFTables=> ExtractedPDFTables | |
| **ENDREGION | |
| **REGION PDFファイルから画像を抽出 | |
| Pdf.ExtractImagesFromPDF.ExtractImages PDFFile: $'''C:\\Test\\PDF\\テスト用PDFファイル.pdf''' ImagesName: $'''PDFファイルから抽出''' ImagesFolder: $'''C:\\Test\\PDF\\output''' | |
| **ENDREGION | |
| **REGION PDFファイルの分割 | |
| SET TargetPdfFilePath TO $'''C:\\Test\\PDF\\テスト用PDFファイル(10p).pdf''' | |
| File.GetPathPart File: TargetPdfFilePath RootPath=> RootPath Directory=> Directory FileName=> FileName FileNameWithoutExtension=> FileNameNoExtension Extension=> FileExtension | |
| LOOP LoopIndex FROM 1 TO 255 STEP 1 | |
| Pdf.ExtractPages PDFFile: TargetPdfFilePath PageSelection: LoopIndex ExtractedPDFPath: $'''%Directory%\\output\\%FileNameNoExtension%_%LoopIndex%.pdf''' IfFileExists: Pdf.IfFileExists.Overwrite ExtractedPDFFile=> ExtractedPDF | |
| ON ERROR PageOutOfBoundsError | |
| END | |
| ERROR => LastError Reset: True | |
| IF LastError.ActionIndex > 0 THEN | |
| EXIT LOOP | |
| END | |
| END | |
| **ENDREGION | |
| **REGION PDFファイルの結合 | |
| Pdf.MergeFiles PDFFiles: $'''\"C:\\Test\\PDF\\10p\\テスト用PDFファイル(10p)_01.pdf\", \"C:\\Test\\PDF\\10p\\テスト用PDFファイル(10p)_02.pdf\", \"C:\\Test\\PDF\\10p\\テスト用PDFファイル(10p)_03.pdf\"''' MergedPDFPath: $'''C:\\Test\\PDF\\output\\テスト用PDFファイル(結合済み3p).pdf''' IfFileExists: Pdf.IfFileExists.Overwrite PasswordDelimiter: $''',''' MergedPDF=> MergedPDF | |
| Folder.GetFiles Folder: $'''C:\\Test\\PDF\\10p''' FileFilter: $'''*.pdf''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.Name SortDescending1: True SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files | |
| Pdf.MergeFiles PDFFiles: Files MergedPDFPath: $'''C:\\Test\\PDF\\output\\テスト用PDFファイル(結合済み).pdf''' IfFileExists: Pdf.IfFileExists.Overwrite PasswordDelimiter: $''',''' MergedPDF=> MergedPDF2 | |
| **ENDREGION | |
| **REGION WordファイルからPDFファイルへの変換 | |
| SET TargetWordFilePath TO $'''C:\\Test\\PDF\\テスト用Wordファイル.docx''' | |
| Word.LaunchWord.LaunchAndOpen Path: TargetWordFilePath Visible: True ReadOnly: True Instance=> WordInstance | |
| Word.CloseWord.CloseAndSaveAs Instance: WordInstance DocumentFormat: Word.WordFormat.PDF DocumentPath: $'''C:\\Test\\PDF\\output\\Wordファイルからの変換.pdf''' | |
| **ENDREGION | |
| **REGION ExcelファイルからPDFファイルへの変換 | |
| SET TargetExcelFilePath TO $'''C:\\Test\\PDF\\テスト用Excelファイル.xlsx''' | |
| Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: TargetExcelFilePath Visible: True ReadOnly: True Instance=> ExcelInstance | |
| @@copilotGeneratedAction: 'False' | |
| Scripting.RunVBScript.RunVBScript VBScriptCode: $'''Const xlTypePDF = 0 | |
| Const xlQualityStandard = 0 | |
| GetObject(\"%TargetExcelFilePath%\").ExportAsFixedFormat xlTypePDF, \"C:\\Test\\PDF\\output\\Excelファイルからの変換.pdf\", xlQualityStandard, False, False, , , False''' ScriptOutput=> VBScriptOutput | |
| Excel.CloseExcel.Close Instance: ExcelInstance | |
| **ENDREGION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment