Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On 07-02-11 08:34, Nils Andresen wrote:
Hi,
I am trying to export documents to pdf. I have a macro which worked
most of the time using OOo, but it does not work in LO.
I use this code..
--- cut ---
  cDestFile = Left(cSourceFile, Len(cSourceFile) - 4) + "pdf"
  cDestURL = ConvertToUrl( cDestFile )
  Dim oExportOptions(4) as New com.sun.star.beans.PropertyValue
  oExportOptions(0).name = "FilterName"
  oExportOptions(0).value = "writer_pdf_Export"
  oExportOptions(1).name = "Author"
  oExportOptions(1).value = "..."
  oExportOptions(2).name = "Comment"
  oExportOptions(2).value = "..."
  oExportOptions(3).name = "DocumentTitle"
  oExportOptions(3).value = "..."
  oExportOptions(4).Name = "Overwrite"
  oExportOptions(4).Value = True
  oDoc.storeToURL( cDestURL, oExportOptions )
--- cut ---

However, in my experiance this only worked in OOo when the
"SaveFileAs" dialog showed pdf as a format to "save as".
When OOo did not had this option, the macro would not work either.
None of my LO installations have this SaveAs format and the macro
fails in all of my LO installations.
I know there was another way to export to pdf (using "export" instead
of "save as") - but I can't find it anymore...

Any ideas/suggestions ?

Yours,
Nils

When enabling the 'exparimantal features i was able to record a new macro.

After lookign at thing code, i know why this 'record new macro' is under
the experimantal features.. ;-)

This is the code (the linke starting with 'args1(2).Value ' is a loooong
line!!!):
sub exportPDF
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///C:/TEMP/Untitled%201.pdf"
args1(1).Name = "FilterName"
args1(1).Value = "writer_pdf_Export"
args1(2).Name = "FilterData"
args1(2).Value = Array( Array("UseLosslessCompression", 0, false,
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,true,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,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),
Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),
Array("ExportFormFields",0,true,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("",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE))

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

end sub

-- 
Unsubscribe instructions: E-mail to users+help@libreoffice.org
List archive: http://listarchives.libreoffice.org/www/users/
*** All posts to this list are publicly archived for eternity ***

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.