I have been asked to convert PPT class lectures to PDF, keeping the PPT notes information. There
is a print mode for that in PPT but it shrinks the slide down to nothing to make room for the
notes text. What I really want is to generate a PDF where the notes become PDF comments, preferably defaulting to closed, with a little ? mark or something similar in a corner to open them.
I found out how to export notes from powerpoint to a text file
http://www.pptfaq.com/FAQ00481.htm
and this creates a simple flat file like:
slide 1:
blah
blah
slide 2:
blah blah
Very easy to parse.
PDF-XChange viewer does have a comment import function. Sadly, it only accepts FDF and xFDF, which is way more complex than I need. Probably if I could find a description of XFDF somewhere it shouldn't be too horrible to use Perl (or whatever) to convert from the text to the XFDF.
In the meantime...
Any chance for adding some sort of simple text file import method? Obviously I could go through the PDF one slide at a time and paste them in, and basically that is all it would need to do.
Failing that, any pointers to a text -> xfdf converter for this purpose?
Thanks.
import comments from a simple file?
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
mathog
- User
- Posts: 34
- Joined: Tue Jan 05, 2010 4:48 pm
Re: import comments from a simple file?
Ah, "export comments" can make an xfdf. Ok, I see pretty much what the format is. Must the "name"mathog wrote: Probably if I could find a description of XFDF somewhere it shouldn't be too horrible to use Perl (or whatever) to convert from the text to the XFDF.
be a UUID (or at least that's what it looks like it is) or could those be any unique strings?
I don't see where the shape is being saved, unless it is in the rectangle numbers somewhere.
Note, when I place a comment in the upper left corner, export to xfdf, open a different PDF,
import the xfdf, the comment is now down at the bottom of each slide. (2.5, build 190.0).
Thanks.
-
mathog
- User
- Posts: 34
- Joined: Tue Jan 05, 2010 4:48 pm
Re: import comments from a simple file?
Here is a minimal .xfdf which seems to work. Near as I can tell the "name" field only needs to match for the two parts of the comment. All of the <p> and <span> stuff seems to have to be on one line or it picks up funny characters, probably the CR or CRLF which show up funny sometimes. I could not do this as an attachment. Lines that don't end in ">" were wrapped by the browser, they should be on a single line in the .xfdf.
Anyway, not too hard to work from this and plain text to generate an .xfdf that can be imported.
Anyway, not too hard to work from this and plain text to generate an .xfdf that can be imported.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<annots>
<text icon="Help" title="Slide 1 addition notes" creationdate="D:20110301121809-08'00'" subject="Sticky Note" page="0" date="D:20110301121820-08'00'" flags="print,nozoom,norotate" name="slide1" rect="5.00,100.00,300.00,605.00" color="#FFFF00">
<contents-richtext>
<body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:7.0.8" xfa:spec="2.0.2" style="font-size:12.0pt;text-align:left;color:#000000;font-weight:normal;font-style:normal;font-family:Arial;font-stretch:normal">
<p><span style="font-family:Arial;font-size:12.0pt">This is a comment for the first page with a double CR buried in it.</span></p>
</body>
</contents-richtext>
<popup open="no" page="0" date="D:20110301121820-08'00'" flags="invisible,nozoom,norotate" name="slide1" rect="31,700,600,792"/>
</text>
</annots>
</xfdf>-
Paul - PDF-XChange
- Site Admin
- Posts: 7443
- Joined: Wed Mar 25, 2009 10:37 pm
Re: import comments from a simple file?
Hi mathog,
I don't see a special feature being added before V3 is released. I think you are on the right path here, the import you suggested seems reasonable,
was it successful?
I don't see a special feature being added before V3 is released. I think you are on the right path here, the import you suggested seems reasonable,
was it successful?
Best regards
Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
-
mathog
- User
- Posts: 34
- Joined: Tue Jan 05, 2010 4:48 pm
Re: import comments from a simple file?
Sort of successful. A bit rocky in places.Paul - Tracker Supp wrote:I think you are on the right path here, the import you suggested seems reasonable, was it successful?
An example .xfdf and the corresponding PDF are attached. Open the pdf and then import the comments. The problem I am having are:
1. I can't make heads or tails of what the rectangle values represent. I know they are supposed to be
[x1 y1 x2 y2], but well, look at the values and then the comment positions. The ones in the sample were derived by moving the "?" and comment text box around inside the program, and then exporting the comment. The .xfdf does not have references to the original file (as there is no original file when these are derived from a script) like the ones in the export comments .xfdf. That may be screwing up the coordinate system somehow.
2. Mouse over "?" results in truncated pop up text on long comments. Double clicking the "?" opens a box which does hold all the text. See for instance the comment in page 3.
3. In the comments pane on the left side there seems not to be a mode which displays the entire comment on a per slide basis. That is, the little downward black arrow at the end of the text must be clicked to read each one. It would be nice if in the comments properties there was a checkbox for
"fully open comments for current page". It would even suffice if there was some "fully open all comments" mode for this pane.
4. There is either "show all comments" or "hide all comments". Unfortunately these act on both the comments pane and the slides. Options to "hide/show all comments in page tab" would be good, then we could read the comments in the comment pane without having to leave the icon on the slide. This would be almost exactly analogous to the notes in PPT.
Thanks.
You do not have the required permissions to view the files attached to this post.
-
mathog
- User
- Posts: 34
- Joined: Tue Jan 05, 2010 4:48 pm
Re: import comments from a simple file?
mathog wrote:5. Also double click a "?" and the text comes up somewhat transparent. Grab that text box and move itPaul - Tracker Supp wrote:I think you are on the right path here, the import you suggested seems reasonable, was it successful?
and it becomes completely opaque. It returns to transparency after clicking elsewhere on the page. Is there some reason it cannot remain transparent during the drag?
Thanks.
-
mathog
- User
- Posts: 34
- Joined: Tue Jan 05, 2010 4:48 pm
Re: import comments from a simple file?
Here is how to do it, at least in PPT 2003
In PPT
1. tools -> macro ->security
set to medium
2. alt f11 to start VBA editor
3. make sure project is highlighted in left hand pane
insert->module
4. Paste in the following, which is a script that converts PPT notes to an .xfdf file. Be careful about line wrapping the "<body" line, for instance, is very long, and it has to go in as one line in the module.
5 run -> run sub
name the file and save it
In PDF-Xchange viewer:
1. comments -> import comments
2. select xfdf format in the file selector
3. select the file you just created
Bingo, the slides should now be commented.
If new presentations are made by copying this one and deleting the slides the module will tag along and won't need to be created again.
In PPT
1. tools -> macro ->security
set to medium
2. alt f11 to start VBA editor
3. make sure project is highlighted in left hand pane
insert->module
4. Paste in the following, which is a script that converts PPT notes to an .xfdf file. Be careful about line wrapping the "<body" line, for instance, is very long, and it has to go in as one line in the module.
Code: Select all
Sub ExportNotesXFDF()
'
' David Mathog, Caltech 3/2/2011. version 0.0.1
' Export PPT notes to .xfdf format so that they may
' be applied as comments to a PDF file. This is a modification of the text export
' module here: http://www.pptfaq.com/FAQ00481.htm
'
' The timezone for the generator is hardcoded, look for "strPDFtz". There should be
' a way to set it in the script, not sure how though.
'
'
Dim oSlides As Slides
Dim oSl As Slide
Dim oSh As Shape
Dim strFileName As String
Dim intFileNum As Integer
Dim lngReturn As Long
Dim intNewSlide As Integer
Dim strPDFcomments As String ' Variable for accumulating PPT notes, per slide
Dim intPDFpage As Integer ' Page numbers inside PDF, 0 to N-1
Dim strPDFqpos As String ' location for the "?" icon
Dim strPDFtpos As String ' location for the text pop up
Dim strPDFdate As String
Dim strPDFqstyle As String ' style for the "?"
Dim strPDFtstyle As String ' style for the comment text
Dim strPDFtz As String ' Time zone where this was generated
Dim strPDFtitle As String ' like "Slide 1 additional notes"
Dim strPDFpagename As String ' like "slide2"
Dim strPDFtext As String ' all comment text for this slide
Dim strPDFxeol As String ' line delimiter within a comment
strPDFqpos = "1,-18,21,2" ' rectangle position for ?
strPDFtpos = "0,-97,529,0" ' rectangle position for text box
strPDFxeol = " "
strPDFtz = "-08'00'" ' PST
strPDFdate = "D:" _
& Format$(Now, "yyyy") _
& Format$(Now, "mm") _
& Format$(Now, "dd") _
& Format$(Now, "hh") _
& Format$(Now, "nn") _
& Format$(Now, "ss") _
& strPDFtz
intNewSlide = 1
strPDFqstyle = "font-size:12.0pt;text-align:left;" _
& "color:#000000;font-weight:normal;font-style:" _
& "normal;font-family:Arial;font-stretch:normal"
strPDFtstyle = "font-family:Arial;font-size:12.0pt"
' Get a filename to store the collected text
strFileName = InputBox("Enter the full path and name of file to hold extracted notes (as xfdf)", "Output file?")
' did user cancel?
If strFileName = "" Then
Exit Sub
End If
' is the path valid? crude but effective test: try to create the file.
intFileNum = FreeFile()
On Error Resume Next
Open strFileName For Output As intFileNum
If Err.Number <> 0 Then ' we have a problem
MsgBox "Couldn't create the file: " & strFileName & vbCrLf _
& "Please try again."
Exit Sub
End If
Close #intFileNum ' temporarily
' Get the notes text
Set oSlides = ActivePresentation.Slides
For Each oSl In oSlides
For Each oSh In oSl.NotesPage.Shapes
If oSh.PlaceholderFormat.Type = ppPlaceholderBody Then
If oSh.HasTextFrame Then
If oSh.TextFrame.HasText Then
If intNewSlide > 0 Then
intNewSlide = 0
intPDFpage = oSl.SlideIndex - 1
strPDFpagename = "Slide" & CStr(oSl.SlideIndex)
strPDFcomments = strPDFcomments _
& "<text icon=""Help""" _
& " title=""" & strPDFpagename & " additional notes""" _
& " creationdate=""" & strPDFdate & """" _
& " subject=""Sticky Note""" _
& " page=""" & CStr(intPDFpage) & """" _
& " flags=""print,nozoom,norotate""" _
& " Name=""" & strPDFpagename & """" _
& " rect=""" & strPDFqpos & """" _
& " color=""#FFFF00"">" & vbCrLf
strPDFcomments = strPDFcomments _
& "<contents-richtext>" & vbCrLf _
& "<body xmlns=""http://www.w3.org/1999/xhtml"" xmlns:xfa=""http://www.xfa.org/schema/xfa-data/1.0/"" xfa:APIVersion=""Acrobat:7.0.8"" xfa:spec=""2.0.2""" _
& " style=""" & strPDFqstyle & """>" & vbCrLf
End If
strPDFcomments = strPDFcomments _
& "<p><span style=""" & strPDFtstyle & """>" _
& oSh.TextFrame.TextRange.Text & strPDFxeol
End If
End If
End If
Next oSh
' close out the xml for this slide
strPDFcomments = strPDFcomments _
& "</span></p></body></contents-richtext>" & vbCrLf _
& "<popup open=""no""" _
& " page=""" & CStr(intPDFpage) & """" _
& " Date=""" & strPDFdate & """" _
& " flags=""invisible,nozoom,norotate""" _
& " Name=""" & strPDFpagename & """" _
& " rect=""" & strPDFtpos & """/>" & vbCrLf _
& " </text>"
intNewSlide = 1
Next oSl
' now write the text to file
Open strFileName For Output As intFileNum
' Print the header
Print #intFileNum, "<?xml version=""; 1#; "" encoding=""; UTF - 8; ""?>"
Print #intFileNum, "<xfdf xmlns=""http://ns.adobe.com/xfdf/"" xml:space=""preserve"">"
Print #intFileNum, "<annots>"
Print #intFileNum, strPDFcomments
' Print the footer
Print #intFileNum, "</annots>"
Print #intFileNum, "</xfdf>"
Close #intFileNum
' show what we've done
lngReturn = Shell("NOTEPAD.EXE " & strFileName, vbNormalFocus)
End Sub
name the file and save it
In PDF-Xchange viewer:
1. comments -> import comments
2. select xfdf format in the file selector
3. select the file you just created
Bingo, the slides should now be commented.
If new presentations are made by copying this one and deleting the slides the module will tag along and won't need to be created again.
-
Stefan - PDF-XChange
- Site Admin
- Posts: 19930
- Joined: Mon Jan 12, 2009 8:07 am
Re: import comments from a simple file?
Many thanks for sharing your code here mathog,
I do hope it would be useful for other people reading these forums
Cheers,
Stefan
I do hope it would be useful for other people reading these forums
Cheers,
Stefan