Editorial Workflows

PDF in Sidebar

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Workflow to show a PDF file, selected from current folder, in a simple sidebar. Based on: PDF in Browser. Thanks to @olemoritz for immediate help.

Only for iPad.

Shared by: @jakubowiak

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Run Python Script ?
Source Code
#coding: utf-8
import editor
import workflow
import os
import platform

if not platform.machine().startswith('iPad'):
	import console 
	console.alert('iPad Required',
		              'Sorry, this workflow is designed for iPad only.', 'OK',
		              hide_cancel_button=True)
	workflow.stop()

p = editor.get_path()
folder, filename = os.path.split(p)
files = os.listdir(folder)
pdf_files = []
for filename in files:
	if os.path.splitext(filename)[1] == '.pdf':
		pdf_files.append(filename)

action_out = '\n'.join(pdf_files)
workflow.set_output(action_out)
Select from List ?
Title
PDF Files
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
ON
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import os
import urllib
import webbrowser
import ui
import platform

selected_file = workflow.get_input()
if selected_file:
	p = editor.get_path()
	folder, filename = os.path.split(p)
	full_path = os.path.join(folder, selected_file)
	file_url = 'file://' + urllib.quote(full_path)
	v = ui.load_view()
	v['webview1'].load_html('')
	import time
	time.sleep(0.2)
	v['webview1'].eval_js('window.location.href = "'+file_url+'"')
	v.present('sidebar')