[Writer] Export to Non-searchable PDF(full content as image)

Creating a macro - Writing a Script - Using the API

[Writer] Export to Non-searchable PDF(full content as image)

Postby BenDev » Mon Jun 17, 2019 9:59 pm

Hi,

I've been asked to export .odt file to PDF file with full content as image, in more common called "non-searchable" PDF.
The main goal is to keep content integrity when the PDF will be imported in another solution that will extract the images for them to be analysed.
If the content in the PDF is in Text format, the solution would have first to do a rendering of the PDF to convert its content to an image. At this point, there could be differences between original PDF content and the Image created...

I've already found how to set specific parameters and to export to PDF file, as shown in this function:

Code: Select all   Expand viewCollapse view
'_________________________________________________________________________________

Sub Pdf_Locked_Export(oDoc as object, FolderExportPath as String, FileName as String)

      dim aMediaDescriptor()
      dim aFilterData()
   
      'PDF version
      REM 0=PDF 1.4
      REM 1=PDF/A1 which disables any passwords in the export dialog
      bas_PushArray aFilterData,MakePropertyValue("SelectPdfVersion",0)
     
      'PDF parameters
      bas_PushArray aFilterData,MakePropertyValue("UseTaggedPDF",false)
      bas_PushArray aFilterData,MakePropertyValue("ExportBookmarks",true)
      bas_PushArray aFilterData,MakePropertyValue("EmbedStandardFonts",true)
     
      'Images
      bas_PushArray aFilterData,MakePropertyValue("UseLosslessCompression",true)
      bas_PushArray aFilterData,MakePropertyValue("Quality",100)
      bas_PushArray aFilterData,MakePropertyValue("ReduceImageResolution",true)
      bas_PushArray aFilterData,MakePropertyValue("MaxImageResolution",300)
     
      'Viewer parameters
      bas_PushArray aFilterData,MakePropertyValue("InitialView",1)
      bas_PushArray aFilterData,MakePropertyValue("Magnification",1)
      bas_PushArray aFilterData,MakePropertyValue("PageLayout",0)
      bas_PushArray aFilterData,MakePropertyValue("CenterWindow",true)
      bas_PushArray aFilterData,MakePropertyValue("OpenBookmarkLevels",1)
     
      bas_PushArray aFilterData,MakePropertyValue("HideViewerToolbar",true)
      bas_PushArray aFilterData,MakePropertyValue("HideViewerMenubar",true)
      bas_PushArray aFilterData,MakePropertyValue("HideViewerWindowControls",true)
      bas_PushArray aFilterData,MakePropertyValue("DisplayPDFDocumentTitle",true)
     
      'Links
      bas_PushArray aFilterData,MakePropertyValue("ExportBookmarksToPDFDestination",true)
      bas_PushArray aFilterData,MakePropertyValue("ConvertOOoTargetToPDFTarget",true)
      bas_PushArray aFilterData,MakePropertyValue("ExportLinksRelativeFsys",false)
      bas_PushArray aFilterData,MakePropertyValue("PDFViewSelection",0)
     
      'Sécurity
      bas_PushArray aFilterData,MakePropertyValue("EncryptFile",true)
      bas_PushArray aFilterData,MakePropertyValue("RestrictPermissions",true)
      bas_PushArray aFilterData,MakePropertyValue("PermissionPassword","MyPassword")
      bas_PushArray aFilterData,MakePropertyValue("Printing",2)
      bas_PushArray aFilterData,MakePropertyValue("Changes",0)
      bas_PushArray aFilterData,MakePropertyValue("EnableCopyingOfContent",false)
      bas_PushArray aFilterData,MakePropertyValue("EnableTextAccessForAccessibilityTools",false)
     
      bas_PushArray aMediaDescriptor,MakePropertyValue("FilterName","writer_pdf_Export")
      bas_PushArray aMediaDescriptor,MakePropertyValue("FilterData",aFilterData)

      oDoc.storeToURL(convertToUrl(FolderExportPath & FileName), aMediaDescriptor)
     
end sub

'_________________________________________________________________________________

sub bas_PushArray(xArray(),vNextElement)

   Dim iUB,iLB as Integer
   iLB = lBound(xArray())
   iUB = uBound(xArray())
   If iLB > iUB then
   iUB = iLB
   redim xArray(iLB To iUB)
   else
   iUB = iUB +1
   redim preserve xArray(iLB To iUB)
   endif
   xArray(iUB) = vNextElement
   
end Sub

'_________________________________________________________________________________

function MakePropertyvalue(aName as string, avalue as variant ) as variant
                     
  dim Arg as new com.sun.star.beans.PropertyValue     
  Arg.name = aName
  Arg.value = avalue
  MakePropertyvalue = Arg

end function

'_________________________________________________________________________________


For this I used the parameters given at this page (if it can help someone at the same time):
PDF export parameters

This creates the PDF well secured, but the content remains as text.
So I was wondering if there was a way to directly create a non-searchable PDF from LibreOffice or to convert the exported PDF to this needed format?
Maybe using Javascript or Python function?

Thanks in advance for any help, clue or idea...
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby Zizi64 » Mon Jun 17, 2019 10:37 pm

I've been asked to export .odt file to PDF file with full content as image, in more common called "non-searchable" PDF.

And what about the OCR softwares? Those softwares can re-convert the picture to text in a few millisec...
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8062
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Mon Jun 17, 2019 10:52 pm

@Zizi64:

Thanks for your answer, but I think you've misunderstood my question.
I don't need to convert PDF image to text.
I need to export an .odt to a PDF with the content of the PDF as an image (so not text).

By the way, even if it was in the sens PDF (as image) to .odt (as text), OCR software won't be able to recreate the exact layout of the original PDF, losing then the integrity of the original content of the PDF (text + layout)...
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby Zizi64 » Tue Jun 18, 2019 6:22 am

I don't need to convert PDF image to text.
I need to export an .odt to a PDF with the content of the PDF as an image (so not text).

Yes I understood it.

By the way, even if it was in the sens PDF (as image) to .odt (as text), OCR software won't be able to recreate the exact layout of the original PDF, losing then the integrity of the original content of the PDF (text + layout)...

A modern OCR software can recognize the character type, the bold, italic state of the characters, the page margin values, etc.
And a person who OCR-ed your document (at least pure text), can recreate the full layout in some minutes by the usage of the styles in LibreOffice - based on the layout of the .pdf file.


I suppose you it is enough to export your document to .pdf format with more strict security options.
You can set a password for File Encryption and Permission and you can disable the copying of the content. I just tried it in my LibreOffice 6.1.6 (The password is Zizi64 in the sample file):

disabled_copy.pdf
(31.96 KiB) Downloaded 30 times


The function is exist in the AOO too, but I have not tried it in AOO. I am using LibreOffice.
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8062
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby RoryOF » Tue Jun 18, 2019 8:50 am

My experience with OCR is as Zizi64 says - a modern commercial OCR program can give excellent rendering of an original document, preserving format and illustrations.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29053
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Tue Jun 18, 2019 9:23 am

Thanks a lot for your effort on answering, but it seems that you didn't read the whole content of my subject.
Maybe there is a displaying bug on it, I don't know (as it is well displayed on my side...).

So:
I suppose you it is enough to export your document to .pdf format with more strict security options.

Well, as I explained it in the subject: no, it's not enough => "The main goal is to keep content integrity when the PDF will be imported in another solution that will extract the images for them to be analysed.
If the content in the PDF is in Text format, the solution would have first to do a rendering of the PDF to convert its content to an image. At this point, there could be differences between original PDF content and the Image created...
"
So, it's a development context prerequisite linked to specification.

You can set a password for File Encryption and Permission and you can disable the copying of the content. I just tried it in my LibreOffice 6.1.6

As explained in the subject, I already know how to do that, and besides, I've posted a sample of code to share the function if it could help someone...

So my question is really "how to create a non-searchable PDF(full content in the PDF needs to be as an image)" and not "is there a workaround to avoid creating non-searchable PDF"...
Thanks a lot for your understanding on this :oops:
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby RoryOF » Tue Jun 18, 2019 9:35 am

What you want to do may be beyond the PDF generation capabilities of OpenOffice and LibreOffice; you will probably have to use a commercial product. I think that the Adobe PDF generation products are probably the most advanced and suggest you investigate those.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29053
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby JeJe » Tue Jun 18, 2019 9:45 am

The first search results give a solution? You wouldn't expect OO or LO to do everything but you can make the pdf with them and convert it using other means.

https://acrobatusers.com/tutorials/crea ... -documents
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 518
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Tue Jun 18, 2019 9:46 am

@RoryOF:
Thanks,
Yeah, I've already checked this, there are third-party softwares that are doing this, but I wanted to check if I had maybe missed something on LO or OO capabilities on this point, as integrating a third-party step can often be a logistical, administrative and legally constraint...
That's why I was looking for users return who may have better experience than mine on this point ;)
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby RoryOF » Tue Jun 18, 2019 9:52 am

A way to make a PDF document non-searchable would be to export the texts as graphics from the editor in which they were written, or in some way convert them to graphics - tiff, png or as you wish, at high resolution to preserve quality as much as possible - then place these graphics in a document to be converted to a PDF. This does not easily allow formatting of charts and other graphical illustrations in the flow of the text so that they can be extracted - these might be best positioned each to a separate page.

It will still be possible, albeit with some effort, to OCR the graphic representations of the text and reduce it to plain text, should one desire to do so.

We can only answer from our own experience and use of software.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29053
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby John_Ha » Tue Jun 18, 2019 11:16 am

You need to do it outside AOO/LO.

Draw has File > Export ..., where you can export as an image but I cannot see how to get the Writer page into Draw. Insert > From File ..., allows you to insert .rtf files (very low capability) and html files.

Perhaps create the PDF with text as normal and then find a way to convert each page of the PDF to an image which you then put in another PDF. PDFSAM allows PDF files to be split, merged etc.

File > Print > Fax ..., creates an image using Windows' fax driver - can you intercept the file?

Use a virtual image printer such as Virtual ImagePrinter or Zan Image Printer to produce images of the .odt pages which you then collate into a PDF. The easiest way to do this would be to create a "template" .odt file where you insert the page images directly into the \Pictures folder. Now use LO to create the PDF.

It seems PDFill Image Writer does exactly what you want - it creates a PDF of images from any document.

Showing that a problem has been solved helps others searching so, if your problem is now solved, please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.
AOO 4.1.6, Windows 7 Home 64 bit

See the Writer Manual, the Writer FAQ, the Writer Tutorials and the Writer guide.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 6649
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby RoryOF » Tue Jun 18, 2019 2:05 pm

https://www.zamzar.com/convert/odt-to-png/ will convert an .odt file to png; other graphics formats are also available on same conversion site.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29053
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Tue Jun 18, 2019 2:17 pm

Thanks for your answers.

I've finally found the theorical solution (works if I do it manually) to stay within Writer all along the process.

    1) Export each page of the document with the filter "writer_jpg_Export" and appropriate parameters (I mean 300 dpi and A4 format). Each Image will be stored in a temporary folder.
    2) Create a new temporary document with no marges at all.
    3) For each Image, create a pagebreak and import the image at full size, with position at middle horizontally and vertically
    4) Export the temporary document to Pdf

With this process I will get the PDF non-searchable version of the .odt document.

I will get back to this thread when I will have coded this export function, so it could help someone else looking for such operation...
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby RoryOF » Tue Jun 18, 2019 2:37 pm

JPG is a lossy compression, so for better quality TIFF or PNG may be better, perhaps at 600 dpi.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29053
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Tue Jun 18, 2019 2:41 pm

Jpeg at 300 dpi is what is needed in the development context prerequisite linked to specification for the project i'm working on ;)
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby John_Ha » Tue Jun 18, 2019 3:13 pm

John_Ha wrote:I cannot see how to get the Writer page into Draw.

See also [Solved] How to open a odt document with Draw.

It seems strange that there is a filter "writer_jpg_Export" when Writer doesn't use it???

See [Solved] Export Writer document page to JPEG in JAVA

Do a google search with open office writer jpg Export or similar - it finds millions of hits including the Export As Images extension which probably has code you could hack.
AOO 4.1.6, Windows 7 Home 64 bit

See the Writer Manual, the Writer FAQ, the Writer Tutorials and the Writer guide.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 6649
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Tue Jun 18, 2019 3:30 pm

It seems strange that there is a filter "writer_jpg_Export" when Writer doesn't use it???


Maybe I forgot to mention that I'm working on a project on LibreOffice (see my specification in my signature).

LO has a function to export as Jpeg, Png, etc...
This filter is the one that should be use in code to do the same as the user interface does.

For example:
Code: Select all   Expand viewCollapse view
sub writer_to_jpeg(doc, pxWidth, pxHeigth)

    url = "YourFullURLPathToTheFile"

    dim filterdata(2) as new com.sun.star.beans.PropertyValue
    filterdata(0).Name = "PixelWidth"
    filterdata(0).Value = pxWidth
    filterdata(1).Name = "PixelHeight"
    filterdata(1).Value = pxHeigth
    filterdata(2).Name = "Quality"
    filterdata(2).Value = 100
   

    dim args(2) as new com.sun.star.beans.PropertyValue
    args(0).Name = "FilterName"
    args(0).Value = "writer_jpg_Export"
    args(1).Name = "FilterData"
    args(1).Value = filterdata()
    args(2).Name = "Overwrite"
    args(2).Value = True
       
    'doc.store()
    doc.storeToURL(url, args())

end sub


Just note that this step only export the page where the cursor is active.

So I won't need to use Java for this step until I'm on LO.
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby AOOisdead » Tue Jun 18, 2019 3:38 pm

If the second stage is a software that does image analysis, why bother converting to pdf at all? couldn't you just leave it in writer_jpg_export and whatever the next stage of the software is wouldn't have to do image extraction from the PDF?
Libreoffice 6.2.2
User avatar
AOOisdead
Banned
 
Posts: 32
Joined: Wed Mar 27, 2019 12:25 am

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Tue Jun 18, 2019 3:44 pm

@AOOisdead:

Yeah, right, but the PDF File is the type asked for archiving, and then keeping PDF content exact integrity when retrieving the PDF content in the final solution is also a requirement in the development context prerequisite linked to specification for the project i'm working on ;)
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Tue Jun 18, 2019 5:13 pm

@John_Ha:
Showing that a problem has been solved helps others searching so, if your problem is now solved, please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.


No problem, I know this rule and I do it when a subject I've opened get its solution.
For now, to my point of vue, the solution has not yet been provided.
As I said, I will post the code of the function that does the full operation but I won't be able to code it in the next 24h due to my planning at work...

If you consider that the "theorical" answer I've already posted is enough to set the topic to state [Solved], just tell me and I will do it.
But in this case, will I be able to post the final solution with the code when I will have written it?
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby Lupp » Tue Jun 18, 2019 5:41 pm

The thread is too long for me meanwhile to be sure, but I feel there not was a plausible reason given for the requirement of the pdf "archive" files NOT to be searchable.

What I might understand regarding the intention to create an archive is to want the files not editable as far as simple means are considered. On printed pages text is only present in the same way as printed images and graphics are. Images may be used as an easier storable surrogate for printouts. Text in an image is, however, much easier than high-quality graphics re-converted to editable text by everyday means. And images stored as files are much easier, more inconspicious, and much faster accessible than archived paper.

Anyway a judgement concerning the question whether or not pdf is an appropriate means to achieve the aspired levels of security, safety, and protection, requires actually profound knowledge of pdf (and of probable alternatives). I wouldn't expect to find many true pdf experts here. And even experts may only be able to give their view of the present state, but be unaware of developments to be expected.

For my part I can give you a (hopefully) complete list of the FilterData proprties supported by recent LibrOffice with the writer_pdf_Export filter:
Code: Select all   Expand viewCollapse view
UseLosslessCompression
Quality
ReduceImageResolution
MaxImageResolution
UseTaggedPDF
SelectPdfVersion
ExportNotes
ViewPDFAfterExport
ExportBookmarks
OpenBookmarkLevels
UseTransitionEffects
IsSkipEmptyPages
ExportPlaceholders
IsAddStream
FormsType
ExportFormFields
AllowDuplicateFieldNames
HideViewerToolbar
HideViewerMenubar
HideViewerWindowControls
ResizeWindowToInitialPage
CenterWindow
OpenInFullScreenMode
DisplayPDFDocumentTitle
InitialView
Magnification
Zoom
PageLayout
FirstPageOnLeft
InitialPage
Printing
Changes
EnableCopyingOfContent
EnableTextAccessForAccessibilityTools
ExportLinksRelativeFsys
PDFViewSelection
ConvertOOoTargetToPDFTarget
ExportBookmarksToPDFDestination
SignPDF
_OkButtonString
Watermark
EncryptFile
PreparedPasswords
RestrictPermissions
PreparedPermissionPassword
SignatureLocation
SignatureReason
SignatureContactInfo
SignaturePassword
SignatureCertificate
SignatureTSA
On Windows 10: LibreOffice 6.2 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2491
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Tue Jun 18, 2019 10:56 pm

@Lupp:
Yeah I know, I found this thread a little too long too because I had to re-explain few times why the question of the thread is not "why thoses requirements?", but "any idea how to deal with thoses requirements?" ;)

The thread is too long for me meanwhile to be sure, but I feel there not was a plausible reason given for the requirement of the pdf "archive" files NOT to be searchable.

So again, yes, there are reasons, one part is about legal terms due to legal protocole of the client and as I repeat since the beginning the imposed specifications, and the other part is about the whole technical process that works behind. So don't worry, we really know what we're doing with such Pdf and why our context requires to deal with Pdf in this special project case... ;)
Sometimes you own the choice of the material and procedures, sometimes not, depending of the project.

This said, thanks a lot for the update of the list of the FilterData properties :)
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby Zizi64 » Wed Jun 19, 2019 6:36 am

If you want to achieve all steps of this task in the AOO/LO, then there is a workaround method:

1.: You can export the document into pdf format (manually or by a macro),
2.: and then you can open the PDF in the Draw application (manually or by a macro). The LibreOffice has a PDF-import function by default, but you must install a PDF-import extension for the Apache OpenOffice.
3.: You can select all of objects on each page - manually or by a macro,
4.: and you can Convert the objects into one huge pixergraphic image (To Bitmap) on each page (manually or by a macro)
5.: And finally you can export the multipage Draw document from the Draw applcation into PDF format... (manually or by a macro)

The working speed depends on the size of the original document. The Draw can not handle so well the huge size PDF files.
Last edited by Zizi64 on Wed Jun 19, 2019 2:33 pm, edited 1 time in total.
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8062
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Wed Jun 19, 2019 9:20 am

@Zizi64:

Thanks, I've already Checked this out, and it's effectively a way better possibility because of less steps and less difficulty of programmation I suppose (for now only suppose 'cause I've not searched yet how to manage Draw module and functions).

But in my context, the .odt file will be deployed on lots of computers, and I don't control how LO will be installed (I just control to impose the minimal version of LO to use and that the Writer module has to be installed).
So if LO has been installed without Draw module for example (I thought I saw it was possible on installation step options), I don't want the process to run into trouble...

As I said sooner, the context imposed on the specification is really strict :?
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby Zizi64 » Wed Jun 19, 2019 12:08 pm

So if LO has been installed without Draw module for example (I thought I saw it was possible on installation step options), I don't want the process to run into trouble...

There is not any option in the Windows LO installer to eliminate a single application. All of the applications will be installed.


The LO is a real integrated application: there is only one core application named "soffice", and it will work as "Writer" or "Calc" or "Draw" - depended on the settings.
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8062
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Wed Jun 19, 2019 12:12 pm

@Zizi64:

Ok, thanks for this information.
I will check the Draw way of this process then ;)
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby Lupp » Wed Jun 19, 2019 1:18 pm

I would suggest you avoid the 'Draw' step.
You may better use the writer_jpg_Export filter and collect the images into your final as-if archive in .pdf format (or into an actual .zip archive). How to export a .jpg per page is demonstrated in the attached file. The code is based on one I wrote for a different task, and the adaption is very raw. It worked satisfyingly for me nonetheless in different versions of LibO from V 5.2.0 up to V 6.3.0.beta1. It definitely cannot work in AOO, and it failed in LibO V 5.1.4.
Attachments
demo_ExportToJpgPerPage.odt
(107.44 KiB) Downloaded 24 times
On Windows 10: LibreOffice 6.2 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2491
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Wed Jun 19, 2019 5:48 pm

@Lupp:

Thanks for the sample, even if I had already posted (little higher in this thread) the function to do it ;)
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby Lupp » Wed Jun 19, 2019 6:06 pm

The posts "little higher" I had in mind were
posting.php?mode=reply&f=20&t=98391#pr472535 and
posting.php?mode=reply&f=20&t=98391#pr472521 probably.

Since I was not aware of a well suiting solution under the (imo) relevant aspects, I wanted to suggest another promising way.

Of course, the code will not be contaiend in the files to work on, but in a another file, best .ods, working as a kind of batch file.
On Windows 10: LibreOffice 6.2 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2491
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Writer] Export to Non-searchable PDF(full content as im

Postby BenDev » Wed Jun 19, 2019 6:22 pm

No problem, I'm always gratefull for the effort of someone way of solution even if I may already have knowledge of it :)

By the way, I was talking about this post higher :
viewtopic.php?f=20&t=98391&p=472551#p472443
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests