Customized PDF creation using Ghostscript, Dynamo and Python


#1

Hi All,

This will be a “work in progress topic” as I need to explain Fully how to achieve this.

First the basics: Revit 2016, Dynamo 1.3, Dyno Browser 0.6.1, Ghostscript 9.21, Redmon 1.9 and Python

Ghostscript can be downloaded here https://www.ghostscript.com/download/

Redmon can be downloaded here http://pages.cs.wisc.edu/~ghost/redmon/

There are tons of write-up about Ghostscript online so feel free to read about it so you have an idea on how it works.

Graph Image

Below is a video of the concept and proof that

The python script allows Ghostscript to create PDF from Revit with the following features

a. Customized PDF naming - achieved via a parameter
b. Customized File Location
c. AutoDetect titleblock sizes A0, A1, A2, A3 and A4 - achieved via a parameter and predefined print settings
d. once a parameter is added on the sheet you can filter this so you can only create PDF based on this filter

There are couple of instructions on how to do this and once set-up (one time) you can use Ghostscript as a normal PDF creator - Solely for Revit only.

As I said its work in progress so bear with me…thanks…

Continuation…

Setting up Ghostscript and Redmon

  1. Download (from the link above) and Install Ghostscript 64 bit and Redmon 64 bit, just standard install
  2. Create folder on your C:\ drive named “GhostscriptPDF” and a sub-folder “PDF_RevitExport”

Follow this short video on how to configure

dyn…is here

GhostscriptPDF_python_WIP_v1.dyn (9.1 KB)

let me know if you have any issues.

Note: Please make sure you have a “SheetSize” parameter and your printsettings name should be like “Ghostscript_A0” etc.

enjoy…and lastly I have no association nor connection to Ghostscript and Redmon I just use it coz its currently free and it works…pls. save your revit model before trying any graphs…


Help with renaming multiple pdf files - First Dynamo graph
#2

Is there a question here? @Zach_Kron do we need a special category for work samples?


#3

@Konrad_K_Sobon no question just simply sharing my code for an alternative way on creating pdf from revit. It will be great if there is another category for work examples as you suggest. I have other graphs (simplified) version that would be useful.


#4

Can you please post the sample files in that case? I don’t see any links here other than the video.


#5

Hm… I don’t even see the video link.

The topic is really interesting though!


#6

Hi…video is now available.


#7

…continuation…see post #1


#8

I’m all for adding a “WIP” category or some such if it looks like something that is starting to emerge . . . are there other posts you can think of that his this kind of subject? The DynaShapes post is the only other one I know of


#9

Yeah these are not questions so i would at least like to see them be categorized differently. It’s nice to have a place to drop work examples, and working scripts/definitions.


#10

Hi,
@Zach_Kron, @Konrad_K_Sobon

If you add WIP, then challenges could be a category too?
For the crazy ideas that could leed to… who knows what, a pool of creativity, like the one that created Dynamo in the first place

Marcel


#11

“Share”?
"This category is for example Dynamo files, sample datasets, small tutorials, or Works in Progress. "


#12

:point_up: This


#13

Coming back to the original post :slight_smile:
This looks really interesting, though I see margin for optimizing.
Firstly the necessity of managing print settings for each page size is annoying…
The Installation of various programs is another thing which minimizing would do good. What does redmon do ghostscript cannot do?

I would like to propose the following changes: Just print all pages to the maximum page size and crop the pdf afterwards page by page using al crop matrix prepared by dynamo. I am not a programmer, but I can contribute the necessary ghostscript code for cropping… anybody interested?


#14

Thanks for your comments.

Apologies as my original post are not complete and less explanation, below are some additional information

Yes you are correct, couple of program installations are a bit annoying and not to include the settings and making it to work to what you want
But, I must stressed that whatever time and annoyance was involved if you get the results you desire I think it’s all worth it.

The reason for this post was to introduced an “alternative” solution to the current issue on Plotting to PDF from Revit

These are the common issue,

  1. Quality of the output PDF
  2. Filename of the output PDF, generally a user wants to have his/her own filenaming convention
  3. Is the PDF creator/printer free?
  4. Is there an Auto-save function? Generally any free PDF creator/printer out there that has an Auto-save function are not free (Adobe Acrobat for example)
  5. PDF Creator (the actual name of the program) has an Auto-save function but needs a lot of setting up to achieve per machine if used
  6. If you need to plot to different sizes you need to set this up on Revit and match every single sheet to the PrintSettings (in Dynamo)
  7. And lastly the time you spent making the dynamo graph to work depending on the complexity either you need to plot to a specific paper size or Printsettings etc.

So currently in the Revit world (without the use of Dynamo or paid PDF creator programs) there’s still a lot of settings you need to do (i.e Print Settings, Renaming of the PDF)
As an alternative to the current “Norm” on Revit using Dynamo to create PDF, why not use Ghostscript, Python and Redmon to achieve all of the above in one sweep
Ghostscript is a free PDF printer (used by so many PDF programs like CutePDF, PDF creator to name a few), Redmon is a “Printer Port” or Redirected Port Monitor (it’s not a printer)

The magic happens when you PDF via Ghostscript, it sends it to the Redirected Port Monitor “RedMon” and plots it to PDF.
Where is the “Magic” Redmon has the ability to redirect/sets the PDF to

  1. Pre-defined Quality
  2. Location of the output PDF
  3. The FILENAMING convention
  4. It can also set to plot to JPG, TIFF and EPS (this is an extra bonus)

Now, how will all this works on Revit? Luckily we have Dynamo, Dynamo Player or Dyno Browser
I have made a Python script attached above to be able to achieve this “Tall Order”

The python script includes and can be downgraded to the user’s taste (needs a bit of know-how on coding)

  1. It can distinguish what Sheet size and apply the appropriate print settings (you need to have a Sheetsize parameter and pre-defined Print settings)
  2. You can have any file naming you want
  3. Plots, Wait until next one is finished and AUTOSAVE to the folder location of your choice
  4. It create/writes the settings for Redmon to used (very important)

And yes you are right there’s a bit of coding and only few probably would understand what I have written above and be able to manipulate it to suit their needs and even to what you suggested
I will create a new code based on your suggestion and post the graph

thanks


#15

Hey 4bimfercesp,
I am glad you are interested. Maybe we can make this work like a charm…
I have developed a ghostscript post processing of multipage pdf files a couple of months ago. It works the way described above. KenS from Artifax (owner of ghostscript) was so kind to help me with the appropriate Postscript commands.

My workflow basically needed a pdf-printer (I use pdfcreator, too) and ghostscript to do the post-processing.
There is one potential problem with my workflow: the cut area may still contain drawing elements which contribute to the file size and may contain (invisible) information not ment to be published…


#16

@j.pf
The multiple pdf is already available in the archi-lab package and it can be found in the forum how to set it up

Whats not available was autosave (depending on your pdf writer) and custom filenaming (achievable but a lot of nodes need to be used) and eveything needs to match depending on your list of sheets to print and also papersize recognition is an issue. As i explained above this can be done using the above Ghostscript.

I am not sure why you would use pdf creator with your ghostscript. As far as i know PDF Creator is built using Ghostscript and also CutePDF uses Ghostscript. Are you aware that Ghostscript is also a PDF printer? Whats its lacking is a port to use and this is why i used redmon.

I would suggest you try the above and see the difference to what you have done. I am sure you will have question but if you follow the above video for setting up (takes only 10mins) install and setup.

Let me know how you get on…

Thanks…