Editorial Workflows

Long Bond Paper PDF

unlisted 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: Creates a PDF in long bond paper format.

Forum topic: https://forum.omz-software.com/topic/4012/custom-pdf-paper-size

Shared by: @olemoritz

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
If… ?
Run the block if
%editor:syntax-mode
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
markdown
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
ON
Message
Open a Markdown Document
…End If
Document Text ?
Folded Text
  • Include
  • Replace with:
Convert Markdown ?
Markdown Extras: Footnotes
ON
…Auto-Links
ON
…Strikethrough (~~x~~)
ON
…Superscript (^x)
ON
…Tables
ON
…Smart Quotes etc.
ON
…Strip Metadata Headers
OFF
Generate PDF Document ?
Source
  • HTML Code
  • Web URL
HTML/URL
<!DOCTYPE html> <html> <head><meta charset="utf-8"/> <style> body { font-family: helvetica; font-size: 12pt; } h1 { font-size: 18pt; } h2 { font-size: 16pt; } h3 { font-size: 14pt; } h4, h5, h6 { font-size: 12pt; } a { color: black; } </style> </head> <body> Input </body> </html>
Paper Size
  • A4
  • Letter
Page Margins
0.5in 1.8in 0.5in 0.5in
Filename
Output.pdf
in Dropbox
OFF
Overwrite
ON
Resize PDF (Python Script) ?
Source Code
#coding: utf-8
import workflow
import PyPDF2
import os
import urlparse
import urllib

def url2path(url):
	'''Convert a file:// URL to a file system path'''
	return urllib.url2pathname(urlparse.urlparse(url).path)

new_width = 8.5 * 72
new_height = 13 * 72
out_filename = 'Resized Output.pdf'
in_pdf_path = url2path(workflow.get_input())
docs_dir = os.path.expanduser('~/Documents')
out_pdf_path = os.path.join(docs_dir, out_filename)

with open(in_pdf_path, 'rb') as input_file, open(out_pdf_path, 'wb') as output_file:
	input_reader = PyPDF2.PdfFileReader(input_file)
	output_writer = PyPDF2.PdfFileWriter()
	num_pages = input_reader.getNumPages()
	for i in range(num_pages):
		page = input_reader.getPage(i)
		new_page = output_writer.addBlankPage(new_width, new_height)
		scale = 13.0 / 11.0
		new_page.mergeScaledPage(page, scale)
	output_writer.write(output_file)
# Create a file:// URL to set the action's output (so that it can be followed by a 'Open URL' action):
pdf_url = urlparse.urljoin('file:', urllib.pathname2url(out_pdf_path))
workflow.set_output(pdf_url)
Open URL ?
Open in
  • In-App Browser
  • Default App / Safari
URL
Input
Tab
  • Last-used Tab
  • New Tab
  • Tab with ID:
new pdf
Wait until Loaded
OFF
Reveal Browser Automatically
ON