Print report with large record

Getting your data onto paper - or the web - Discussing the reports features of Base
Post Reply
dstockman12
Posts: 39
Joined: Thu Dec 13, 2007 6:32 pm

Print report with large record

Post by dstockman12 »

Greetings:

This is probably a dumb question, but bear with me. I want to print out one record that can be large (MEMO). I created a report with a text box linked to the desired column in a table. I can only print one page of a large MEMO this way. The rest of the text from the data column is truncated. What approach should I use to print a multi-page document from Base?

More details (if needed).
Main application is an electronic medical record (EMR).
User selects which office note they want to print.
I take the text from the selected office note and send to a table I use specifically for holding text ready to be printed. This data column is what is linked to the text box in the report.
The user can select whether the text goes to plain paper or letterhead (which I create in the report). I have these as 2 different reports.

If reports are not appropriate for this task, would it be better to copy the text to a Writer document and print that? If so, can someone provide a code snippet of doing that? I am pretty good about opening Writer documents as Base Forms and copying text to various controls on the Form, but have never dumped text into a Writer document (without controls - text box, etc.).

Thanks.

Doug
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Print report with large record

Post by Villeroy »

Drag the query or table from the left pane of the datasource window (F4) into some Writer document and see what happens. You can import plain text, text tables or fields this way. From the right pane you can drag selected rows and selected columns.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
dstockman12
Posts: 39
Joined: Thu Dec 13, 2007 6:32 pm

Re: Print report with large record

Post by dstockman12 »

Villeroy:

Thanks for replying. I need to do this programmatically with the click of a button. I did try the copy and paste into Writer as you suggested, and I also had the macro recorder on (to see how to do it with the dispatcher method). However, CR-LFs were removed with the copy and paste into a writer document so this will not work. Any thought on what to try next from OOBasic code, or how to modify the report to support multi-page printing of one long record? Thanks.

Doug
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Print report with large record

Post by Villeroy »

No, you can not write a simple macro for this. It will take some hour(s) of hard work.
Did you try a Base report? I'd think that this takes care of memo fields. If not, there is a professional reporting tool for Base: http://extensions.services.openoffice.o ... /reporting
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
dstockman12
Posts: 39
Joined: Thu Dec 13, 2007 6:32 pm

Re: Print report with large record

Post by dstockman12 »

Villeroy:

I am actually making some progress. I need to do some more work to polish things off, but I have found a work-around. I open a writer document, paste test into the writer document and then print. I have to figure out how to load a letterhead template, then also close the writer document after printing is completed.

Code: Select all

Sub PrintNotePaperPlain(Event As Object)
Dim NoteText As String
Dim Form As Object, Control As Object, FormDoc As Object

Form = Event.Source.Model.Parent
Control = Form.getByName("NoteTB")
NoteText = Control.getCurrentValue

FormDoc = StarDesktop.LoadComponentFromURL("private:factory/swriter", "_blank", 0, array())  '** open new writer document
Wait 200
FormDoc.Text.setString(NoteText)  '*** insert string into writer document
Wait 200
TestPrintDialog  '*** call print dialog and print active document
End Sub

' ********* This opens the print dialog box. ***********************************************
sub TestPrintDialog
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
dim args2(1) as new com.sun.star.beans.PropertyValue

rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dispatcher.executeDispatch(document, ".uno:Print", "", 0, args2())
end sub

More to come before I can solve this question.

Doug
dstockman12
Posts: 39
Joined: Thu Dec 13, 2007 6:32 pm

Re: Print report with large record

Post by dstockman12 »

Villeroy,

I am getting closer. The code is a bit more complicated because I have to identify if text or a graphic needs to be printed. When printing a graphic, I want to open the writer document in landscape mode. Do you know how I set that? I assume I use com.sun.star.beans.PropertyValue but I could not find the Constant names/values that are acceptable. Then, it would be great to allow the graphic file to be inserted into the letterhead document (in addition into plain paper). How can I open a letterhead document (one URL) and insert a graphics URL into the letterhead?

Code: Select all

' ************* Code below used by NOTE_VIEWER_FRM ****************************************************
Sub PrintNotePaperPlain(Event As Object)
Dim NoteText As String, strSQL As String, OrigAutoNum As String
Dim Form As Object, FormDoc As Object, ImageControl As Object, TextBoxControl As Object
Dim Col1 As Object, Result As Object, Coltrol2 As Object, args(1) As New com.sun.star.beans.PropertyValue

Form = Event.Source.Model.Parent
TextBoxControl = Form.getByName("NoteTB")
NoteText = TextBoxControl.getCurrentValue ' get text from Form control that we want to print

' *** form has both  an image box and a text box (overlapping each other), because chartviewer can display either text or image element
ImageControl = Form.getByName("NoteImageControl")

If (ImageControl.EnableVisible) = TRUE  Then ' means we are viewing an image, print image
	Control2 = Form.getByName("TmpNoteViewerTC")
	Col1 = Control2.getByName("OrigAutoNumCol")  ' *** need to get a linknumber to do QRY to locate URL of displayed image
	OrigAutoNum = Col1.getCurrentValue
	strSQL = "SELECT DURL FROM ""NoteDiagnosticsTBL"" WHERE AUTONUM = '" & OrigAutoNum & "'"
	Result = Stmt.executeQuery(strSQL)
	If Result.next() Then
		If LEN(Result.getString(1)) > 2 Then   ' ****  Scan/Image exists so need to set URL to ImageBox
			FileURL = converttoURL(Result.getString(1))
'			args(0).Name = "Orientation"            ' incorrect settings, I want to open up writer document in landscape mode, do not know how
'			args(0).Value = "Landscape"
			FormDoc = StarDesktop.LoadComponentFromURL(FileURL, "_blank", 0, args())  '** open new writer document with graphic inserted.
			Wait 200
			TestPrintDialog
		EndIf
	EndIf
ElseIf Len(NoteText) > 0 Then
	FormDoc = StarDesktop.LoadComponentFromURL("private:factory/swriter", "_blank", 0, array())  '** open new writer document
	Wait 200
	FormDoc.Text.setString(NoteText)  ' insert text we want to print
	Wait 200
	TestPrintDialog
Else
	msgbox "No text selected"
EndIf
End Sub
To print to letterhead, I just open that document instead of "private:factory/swriter" in the LoadComponentFromURL() call

Code: Select all

	FormDoc = StarDesktop.LoadComponentFromURL(ConvertToURL("C:\Documents and Settings\dstockman\My Documents\Patients\LetHeadSuite300.odt"), "_blank", 0, args())  '** open new LetterHead writer document
Thanks for the help. Of note, ReportWriter only supports text box, not a memo, or I am confused.

Doug
Post Reply