Make blank pdf and rtf

Hi,

I’ve posted before about a blank pdf or rtf data and then using that in a script to make the blank pdf or rtf file. I can’t find the post about how I made the blank pdf or rtf, but I think it was in TextEdit. Funny but I can’t find that post. Then I read that blank file to get the headers or whatever. Also, isn’t there a way in unix to make a blank pdf or rtf?

Thanks,
kel

Hello.

I don’t know about how to make an empty rtf, but I guess you could save an empty text-edit document as rtf?

If you want it preset with fontsizes and such, then I guess you can set up that in an html document, (emtpy) that you then save as rtf.

When it comes to empty pdf documents, this works for me:

I make an empty text file, that starts with !%PS
then I convert the resulting .ps file to pdf with ps2pdf. By the way, post script is great language for creating graphs.

This is the commands I issue in a terminal window, you don’t see the ^C that ends the input of the cat command.

This is a do shell script that does the same, except tests it, (for some reason I get an error message I supress when I run this from a do shell script).

do shell script "echo \"!%PS\" >~/Desktop/emptyfile.ps ;  ps2pdf ~/Desktop/emptyfile.ps ~/Desktop/emptyfile.pdf 2>/dev/null ; true"

man textutil – that should get you where you want to go.

Hi,

I used textutil to make the rtf, but I cannot find the man page for ps2pdf. I’ll just try the script.

Thanks a lot,
kel

Hi McUsr,

Your script made the post script file, but not the pdf file. It wouldn’t convert to pdf in Preview also.

Do I need to download something to get ps2pdf?

Edited: it’s not in /usr/bin also.

Thanks,
kel

Hello Kel.

I thought really that postcript was included on your machine. Try apropos postscript (or man -k postscript) in a terminal window. If this doesn’t work, then there is a ghostscript pacakage you can download at macports.org.
By the way: The fun with postscript is that it is a programming language in its own, and has trigonmetric functions and such.

I get this:

kelhome$ man -k postscript
cupstestdsc(1) - test conformance of postscript files
grops(1) - PostScript driver for groff
img-ps(n) - Img, Adobe PostScript Format (ps)
pfbtops(1) - translate a PostScript font in .pfb format to ASCII

That’s ok. I think I’ll use the other method of writing the data of a blank file to file. It doesn’t look nice, but works.

Thanks a lot,
kel

Hello.

How do you make a blank pdf? Can you make CUPS do it? :slight_smile: And I am sorry that you didn’t have ghostscript installed, as the years go by, I have a harder and harder time figuring out what comes out of the box, and what not. Sorry about that.

Hi McUsr,

In TextEdit, I export the text file as pdf. Then read the file to get the data:

set pdf_ref to choose file
set pdf_data to read pdf_ref as data

Then I can use the data to create more blank pdf:

property pdf_data : «data rdat255044462D312E330A25C4E5F2E5EBA7F3A0D0C4C60A342030206F626A0A3C3C202F4C656E677468203520302052202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A78012B5408040001E700E30A656E6473747265616D0A656E646F626A0A352030206F626A0A31310A656E646F626A0A322030206F626A0A3C3C202F54797065202F50616765202F506172656E74203320302052202F5265736F7572636573203620302052202F436F6E74656E7473203420302052202F4D65646961426F78205B30203020363132203739325D0A3E3E0A656E646F626A0A362030206F626A0A3C3C202F50726F63536574205B202F504446205D203E3E0A656E646F626A0A332030206F626A0A3C3C202F54797065202F5061676573202F4D65646961426F78205B30203020363132203739325D202F436F756E742031202F4B696473205B203220302052205D203E3E0A656E646F626A0A372030206F626A0A3C3C202F54797065202F436174616C6F67202F5061676573203320302052203E3E0A656E646F626A0A382030206F626A0A28556E7469746C6564290A656E646F626A0A392030206F626A0A284D6163204F5320582031302E382E352051756172747A20504446436F6E74657874290A656E646F626A0A31302030206F626A0A284B656C76696E2048616B6B6569290A656E646F626A0A31312030206F626A0A285465787445646974290A656E646F626A0A31322030206F626A0A28443A32303133303932353231303633305A303027303027290A656E646F626A0A31332030206F626A0A28290A656E646F626A0A31342030206F626A0A5B205D0A656E646F626A0A312030206F626A0A3C3C202F5469746C65203820302052202F417574686F7220313020302052202F50726F6475636572203920302052202F43726561746F7220313120302052202F4372656174696F6E446174650A313220302052202F4D6F644461746520313220302052202F4B6579776F72647320313320302052202F4141504C3A4B6579776F72647320313420302052203E3E0A656E646F626A0A787265660A302031350A303030303030303030302036353533352066200A30303030303030363137203030303030206E200A30303030303030313235203030303030206E200A30303030303030323638203030303030206E200A30303030303030303232203030303030206E200A30303030303030313037203030303030206E200A30303030303030323239203030303030206E200A30303030303030333531203030303030206E200A30303030303030343030203030303030206E200A30303030303030343236203030303030206E200A30303030303030343737203030303030206E200A30303030303030353039203030303030206E200A30303030303030353336203030303030206E200A30303030303030353738203030303030206E200A30303030303030353937203030303030206E200A747261696C65720A3C3C202F53697A65203135202F526F6F74203720302052202F496E666F203120302052202F4944205B203C31336334313461393330393636653331653935316366646233623130326437353E0A3C31336334313461393330393636653331653935316366646233623130326437353E205D203E3E0A7374617274787265660A3737340A2525454F460A»

set f to choose file name
set ref_num to open for access f with write permission
try
	write pdf_data to ref_num as data
	close access ref_num
on error err_msg
	close access ref_num
	error err_msg
end try

All that data! :slight_smile:

Edited: here’s the rtf script if anyone needs it:

set theText to ""
do shell script "echo " & quoted form of theText & " | textutil -stdin -output '/Users/kelhome/Desktop/Blank1.rtf' -format txt -convert rtf"

Have a good day,
kel