Bug 40115 - Export as PDF in Calc does not obey the PageRange instruction in a macro
Summary: Export as PDF in Calc does not obey the PageRange instruction in a macro
Status: RESOLVED INVALID
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.3.3.2 release
Hardware: x86 (IA32) Linux (All)
: medium major
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-15 13:49 UTC by John Moore
Modified: 2015-07-31 07:32 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Macro to export to pdf file (12.23 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-08-07 22:47 UTC, David
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Moore 2011-08-15 13:49:59 UTC
I need to perform several exports from a Calc spreadsheet each week for several other departments.  Each requires a different selection of sheets from the multi-sheet document, and some departments are not allowed to access the data on those sheets.

If I do the export manually, the export works correctly, but is time-consuming.

If I attempt to do this through a macro, although the PropertyValue:
Array("PageRange",0,"1,3,5,7",com.sun.star.beans.PropertyState.DIRECT_VALUE) 
is used, every sheet in the workbook will be placed into the PDF.

My workaround is to do the job manually :-(

Although that works, I have to check every file to be certain I'm not sending inappropriate information to the wrong department.  Automation would be a big improvement.
Comment 1 Björn Michaelsen 2011-12-23 12:34:05 UTC
[This is an automated message.]
This bug was filed before the changes to Bugzilla on 2011-10-16. Thus it
started right out as NEW without ever being explicitly confirmed. The bug is
changed to state NEEDINFO for this reason. To move this bug from NEEDINFO back
to NEW please check if the bug still persists with the 3.5.0 beta1 or beta2 prereleases.
Details on how to test the 3.5.0 beta1 can be found at:
http://wiki.documentfoundation.org/QA/BugHunting_Session_3.5.0.-1

more detail on this bulk operation: http://nabble.documentfoundation.org/RFC-Operation-Spamzilla-tp3607474p3607474.html
Comment 2 John Moore 2012-06-22 10:37:14 UTC
I can confirm that this bug still exists in LO 3.5.3.2
Comment 3 John Moore 2012-06-22 10:42:24 UTC
Here's the test code.  It results in all pages being exported to the PDF.
=====
function export_pdf()
dim sPageStr as string
dim args1(3) as new com.sun.star.beans.PropertyValue
dim x as integer
rem ----------------------------------------------------------------------
rem get access to the document

oDocument   = ThisComponent.CurrentController.Frame
oSheets     = ThisComponent.GetSheets()
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
sPageStr    = "1;5;4"   
rem Comma punctuation makes no difference

rem ----------------------------------------------------------------------

args1(0).Name = "URL"
args1(0).Value = "file:///home/jmoore/Documents/Central/Worksheets/2012/Work.pdf"
args1(1).Name = "FilterName"
args1(1).Value = "calc_pdf_Export"
args1(2).Name = "FilterData"
'args1(2).Value = Array(Array("UseLosslessCompression",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ReduceImageResolution",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SelectPdfVersion",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportNotes",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarks",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenBookmarkLevels",0,-1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsSkipEmptyPages",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsAddStream",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EmbedStandardFonts",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportFormFields",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("AllowDuplicateFieldNames",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerToolbar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerMenubar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerWindowControls",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ResizeWindowToInitialPage",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("CenterWindow",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenInFullScreenMode",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DisplayPDFDocumentTitle",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialView",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Magnification",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Zoom",0,100,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageLayout",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FirstPageOnLeft",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialPage",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Printing",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Changes",0,4,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableCopyingOfContent",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableTextAccessForAccessibilityTools",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportLinksRelativeFsys",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PDFViewSelection",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ConvertOOoTargetToPDFTarget",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarksToPDFDestination",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("_OkButtonString",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EncryptFile",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DocumentOpenPassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("RestrictPermissions",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PermissionPassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageRange",0,"1",com.sun.star.beans.PropertyState.DIRECT_VALUE))
args1(2).Value = Array(Array("UseLosslessCompression",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ReduceImageResolution",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SelectPdfVersion",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportNotes",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarks",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenBookmarkLevels",0,-1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsSkipEmptyPages",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsAddStream",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EmbedStandardFonts",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportFormFields",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("AllowDuplicateFieldNames",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerToolbar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerMenubar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerWindowControls",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ResizeWindowToInitialPage",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("CenterWindow",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenInFullScreenMode",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DisplayPDFDocumentTitle",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialView",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Magnification",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Zoom",0,100,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageLayout",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FirstPageOnLeft",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialPage",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Printing",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Changes",0,4,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableCopyingOfContent",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableTextAccessForAccessibilityTools",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportLinksRelativeFsys",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PDFViewSelection",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ConvertOOoTargetToPDFTarget",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarksToPDFDestination",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("_OkButtonString",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EncryptFile",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DocumentOpenPassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("RestrictPermissions",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PermissionPassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageRange",0,(sPageStr),com.sun.star.beans.PropertyState.DIRECT_VALUE))

oDispatcher.executeDispatch(oDocument, ".uno:ExportToPDF", "", 0, args1())


end function
Comment 4 John Moore 2012-11-28 18:00:56 UTC
I can confirm that this bug still exists in Version 3.6.2.2 (Build ID: 360m1(Build:2)).  I am changing the version on the bug report to reflect this.
Comment 5 John Moore 2013-10-15 21:25:27 UTC
Bug is still present in LO Version 4.0.2.2 (Build ID: 400m0(Build:2)).

I see this is still marked NEW. It's also not assigned to anyone.

I can verify that it is still present in Version: 4.1.2.3
Build ID: 40b2d7fde7e8d2d7bc5a449dc65df4d08a7dd38
Comment 6 David 2014-08-07 10:14:08 UTC
Bug also present in LO Version 4.0.6.2 (Linux .deb 64bits).
Comment 7 David 2014-08-07 10:25:39 UTC
Bug also present in LO Version 4.0.6.2 (Linux .deb 64bits).
Comment 8 David 2014-08-07 22:45:40 UTC
I just tested on LibreOffice 4.2.6(Linux deb 64bits) and is the same. Isn't applied any filter opcion when you export to a pdf file throught macros.
Comment 9 David 2014-08-07 22:47:07 UTC
Created attachment 104249 [details]
Macro to export to pdf file

Try to change any option of the filter, for example password, and when you export the password isn't applied. Not runs any filter type.
Comment 10 John Moore 2015-01-03 18:19:26 UTC
Bug still present in 4.3.3.2.  Updating the version number.

Here's a reduced version of the macro


=============================================
sub export_pdf
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
dim sPageRng   as String
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
sPageRng = "1;4"  ' Comma won't work either
rem ----------------------------------------------------------------------
dim args(2) as new com.sun.star.beans.PropertyValue
args(0).Name = "URL"
args(0).Value = "file:///home/jmoore/Documents/Central/Worksheets/2014/CENTTEST.pdf"
args(1).Name = "FilterName"
args(1).Value = "calc_pdf_Export"
args(2).Name = "FilterData"
args(2).Value = Array(Array("PageRange",0,sPageRng,0))

dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args())


end sub
Comment 11 Maxim Monastirsky 2015-07-31 07:32:40 UTC
Hi,

Your macro is wrong. Try this:

dim fdata(0) as new com.sun.star.beans.PropertyValue
fdata(0).Name = "PageRange"
fdata(0).Value = "1;4"

dim args(1) as new com.sun.star.beans.PropertyValue
args(0).Name = "FilterName"
args(0).Value = "calc_pdf_Export"
args(1).Name = "FilterData"
args(1).Value = fdata

doc = thisComponent
doc.storeToURL ("file:///home/maxim/out.pdf", args())

Closing the bug as INVALID.