Saving a Notebook as a pdf

Can a IGOR Notebook be saved as a PDF? I'm also having a problem with formatting the Notebook. It looks like I want it to in the window but when I save it as a non-IGOR file type the formatting is all off. What Im trying to do is create report, with formatting, that can be opened up in a text editor like WORD, WORDPAD, or NOTEPAD and look like it does in the Notebook window. Thanks in advance for any help.

ssmith911
As it seems this is not possible directly (windows):
hrodstein: "On Macintosh printing to PDF is built-into the system. On Windows you have to install a program like Adobe PDF Printer or CutePDF." in
http://www.igorexchange.com/node/5382

However, I assume you want to use the RTF export feature.
Have a look at
DisplayHelpTopic "SaveNotebook"

HJ
Here is a code snippet I have been using to automatically generate report notebooks as PDF-files on a windows machine:

if (AutoSaveResults==1)
    PrintNotebook Results   // set PDFCreator or similar program as default printer with automatic saving enabled, save as "C:\temp\test02.pdf"
    sleep/T 300 // wait 5 seconds for the PDF-printer to finish
    setdatafolder root:
    string ScriptString, TargetString
    TargetString=ParseFilePath(1, S_FileName, ":", 1, 1)    // extract the parent folder of the source file
    TargetString=ParseFilePath(5, TargetString, "\\", 0, 0) // convert to windows notation
    TargetString += SerialNumberString+"_Result.pdf"    // append sensible file name
    ScriptString="cmd.exe /C move C:\\temp\\test02.pdf \"" + TargetString + "\""    // enclose the destination in quotes if there should be spaces
    ExecuteScriptText/B ScriptString    // move and rename the resulting pdf
endif


This snippet relies on an older version of PDFCreator but I am sure that other and newer programs offer the same functionality. Attached is a screenshot of the PDFCreators Options page showing how to setup the automatic printing. Have a look at Formats/PDF/Compression when the resulting files get to large or images turn up ugly. Depending on the compression settings the PDF files are approx. 100 times smaller than the RTF-files Igor generates.

The results look pretty much like the Igor notebook but are not editable, although you can still copy the content.
Clipboard.png
Using Win2pdf solves the pdf issue. So the next thing is formatting. No matter what I've tried the saved pdf or printed version does not look the same as the notebook window. Is there something the margins or tabs that I'm missing. I've attached a screen shot of the window and the pdf generated from it. Thanks in advance for the help.

ssmith
Quote:
No matter what I've tried the saved pdf or printed version does not look the same as the notebook window.


You did not say exactly what looks different. I see that the column labels are shifted but I'm not sure if I'm missing something else.

When you print, the width of text may be somewhat different from what is on the screen. This may be caused by font substitution or rendering at higher resolution or something else that I'm not aware of.

When text gets wider, it causes text to shift to the next tab stop relative to what is on screen.

You are using default tab stops. I think you will get better results if you explicitly set the tab stops at the appropriate positions and if you make sure that there is some margin for error so that, if text grows wider, it does not push into the next tab stop.
On the related topic of specifying the tab stops (which definitely helped me with my table layouts), there must be a better way to do it than this:
variable LWid = 170
variable CWid = 45
variable ROff = 5
Notebook Results newRuler=ResultTable, justification=0, tabs={LWid+3*8192,LWid+1*CWid+ROff+2*8192,LWid+2*CWid+3*8192,LWid+3*CWid+ROff+2*8192,LWid+4*CWid+3*8192,LWid+5*CWid+ROff+2*8192}
Notebook Results newRuler=ResultTableHead, justification=0, tabs={LWid+0.5*CWid+1*8192,LWid+1*CWid,LWid+2.5*CWid+1*8192,LWid+3*CWid,LWid+4.5*CWid+1*8192}
Notebook Results newRuler=ResultTableHeadSub, justification=0, tabs={LWid+1*8192,LWid+1*CWid+1*8192,LWid+2*CWid+1*8192,LWid+3*CWid+1*8192,LWid+4*CWid+1*8192,LWid+5*CWid+1*8192}

Somehow Igor resisted all my other attempts to programmatically generate a tab specification. Did I miss something or does it really only work when everything is put into one line?

Another option would be to to copy a table-object to your notebook. This however has the drawback that the vertical alignment of the cells gets messed up. First it drops down a point when being copied to the notebook, then another point when printing. Should still be okay when you are just dealing with numbers, but for text it starts to cut of some of the lowercase letters.
Quote:
Did I miss something or does it really only work when everything is put into one line?


You didn't miss anything. But I would use local variables to hold your tab stop positions to make the command easier to edit and read.

Quote:
Another option would be to to copy a table-object to your notebook. This however has the drawback that the vertical alignment of the cells gets messed up. First it drops down a point when being copied to the notebook, then another point when printing. Should still be okay when you are just dealing with numbers, but for text it starts to cut of some of the lowercase letters.


I see that, using PNG 4X graphics and printing with Adobe PDF printer on Windows 8.

Using EMF graphics it looks a lot better. Choose Edit->Export Graphics to export the table as EMF and paste into a notebook.

Changing the font to a fixed width font, Consolas, helped make formatting easier. Thanks for the help. One last thing can anyone tell me how to programmatically do Page Setup for the printing of a Notebook? PageMargins in the Notebook section doesn't seem to do it...unless of course I'm doing it wrong. Thanks again.

ssmith
Getting back to the original question, it appears that in Windows 10, I'm able to print to pdf, although I can't completely automate it.

First step is to use the printsettings command to select the proper output:
printsettings setprinter="Microsoft Print to PDF"
This sets the printer to the built-in Microsoft print to pdf output. Once this is set, you can use the PrintNotebook to print to .pdf.

Executing the "PrintNotebook" command then creates the "Save Print Output As" dialog that allows you to navigate to the location where you want to save the .pdf and enter the filename. I don't think that there's a way to set the path and filename with the PrintSettings or PrintNotebook command.

If anyone knows a way to populate the path and filename for this dialog, I'd be interested, but this is a way to generate the prompt for a pdf without having to use third-party software.

Six years later from your posting Jeremy and I want to do the windows 10 printing of a pdf.  The approach works nicely but, as you say, it would be even nicer if the path and file names for the pdf could be programmed.  Did you find a solution?