ViewPro Frequently Asked Questions (FAQs)
How to Print Visual Basic Forms in Vector Format
How to Increase Print Quality for Bitmap
Embed Third-party ActiveX Charts in Report Pages
Print OLE objects (such as Excel Charts in vector format)
PrintForm Location and Size
Multiple Columns
Is There a Total Page Limit on My Report?
Print to Large Size Paper for Plotter (such as HP DesignJet)
Adjust On-screen Page Size to Fit Control Size
Add More Pages to Report or Remove Pages from Report
___________________________________________________________________________
How to Print Visual Basic Forms in Vector Format
Q. Visual Basic's PrintForm function prints a VB form in bitmap format. This results in very poor printing quality. How can I solve this problem with ViewPro?
A. To print a Visual Basic form in good quality, you must print the form in vector format. ViewPro
has provided a DrawForm function to print Visual Basic Forms in vector format:
DrawForm(frm As Form, vp As Control, x As Long, y As Long, w As Long)
where
frm = a Visual Basic Form to be printed in vector format
vp = ViewPro control
x = x coord of the VB form top-left corner on printed page
y = y coord of the VB form top-left corner on printed page
w = the VB form width on the printed page.
This function allows you to freely specify the location and size of the Visual Basic form on the
printed page. Since the Visual Basic form is printed in vector format, the form can be freely scaled
to any size on the printed page without losing print quality.
Back To Top
___________________________________________________________________________
How to Increase Print Quality for Bitmap
Q. I am very interested in the process your product accomodates where you scan a form, add labels to the form, then tell viewpro what data goes with which labels. But I would like to be able to print not only the contents of the labels, but also the original image that is on the form. Now, I know this is possible, but the print quality of that image isn't very good. It seems that the quality is lower than that of the original scan. Is there anything I can do to improve the image quality so I can print the entire form with data onto blank paper?
A. To print high quality bitmaps, your bitmap sizes need to be large enough so that the bitmap resolution can match (or at least be close to) the printer's resolution. For instance, if your printer's resolution is 300 DPI and you want to print a 4'' x 3'' bitmap at 300 DPI, your bitmap size needs to be 1200 pixels x 900 pixels (note: 1 dot-per-inch is equivalent to 1 pixel-per-inch). So, you need to use a lowe screen resolution (small bitmap size) for visual design and a high printer resolution (large bitmap size) for printing.
Back To Top
___________________________________________________________________________
Embed Third-party ActiveX Charts in Report Pages
Q. How can I print third-party ActiveX Charts such as MSChart and First Impression?
A. You can draw third-party ActiveX charts on ViewPro report pages, and you can freely specify
the locations and sizes of your charts on the report pages. The following code shows how to draw
an MSChart on a report page.
Const INCH = 1440
'Clear clipboard
Clipboard.Clear
'Copy MSChart to clipboard
MSChart1.EditCopy
'Wait until chart picture has been sent to the clipboard
For i = 1 To 100000
DoEvents
If Clipboard.GetFormat(3) = True Then
Exit For
End If
Next
ViewPro1.StartDoc
'Specify chart location and size on page
ViewPro1.CurrentX = 1 * INCH
ViewPro1.CurrentY = 2 * INCH
ViewPro1.ObjectWidth = 5 * INCH
ViewPro1.ObjectHeight = 4 * INCH
'Draw chart from clipboard
ViewPro1.Picture = Clipboard.GetData(3)
'or Draw a WMF chart from disk file
'ViewPro1.Picture = LoadPicture ("chart1.wmf")
ViewPro1.EndDoc
ViewPro1.Action = 0
Back To Top
___________________________________________________________________________
Print OLE Objects (such as Excel Charts in vector format)
Q. How can I print OLE objects (such as Excel Charts in vector format) onto ViewPro page?
A. You can first copy your OLE object to clipboard and then use ViewPro's PrintClipboard to
print the object on preview page. The following is the sample VB code.
Dim i As Integer
Const INCH = 1440
Clipboard.Clear
'copy ole object to clipboard
OLE1.Copy
'wait until the ole object has been copied to the clipboard
For i=1 to 100000
If Clipboard.GetFormat(3) Then
Exit Do
End If
Next
ViewPro1.StartDoc
'Specify object location and size
ViewPro1.CurrentX = 1*INCH
ViewPro1.CurrentY = 1*INCH
ViewPro1.ObjectWidth = 3*INCH
ViewPro1.ObjectHeight = 2*INCH
'Print ole object on preview page
ViewPro1.PrintClipboard
ViewPro1.EndDoc
ViewPro1.Action = 0
Back To Top
___________________________________________________________________________
Q. I need to know if ViewPro will allow me to print VB5 forms like the standard printer object, but
give me the ability to easily control page orientation and make the form stretch to fit the page.
VB5's built-in printer object (PrintForm method) will allow me to print a form, but I can't control
the orientation, size, etc.
A. ViewPro allows you to print VB forms, and you have the full control over the form sizes on the
pages and orientation, etc. You use CurrentX and CurrentY to control the location, and
ObjectWidth and ObjectHeight to control the size.
The example below gets the size of a form (Form1) and draws the form image on the current page
with image location at (1,1) inches and width = 9 inches, keeping the original aspect ratio.
Const INCH = 1440
Dim w as integer, h as integer
'Use landscape page
ViewPro1.Orientation = 1
'Get the form size
ViewPro1.GetFormSize Form1.hWnd
w = ViewPro1.ObjectWidth
h = ViewPro1.ObjectHeight
'Keep the form aspect ratio
ViewPro1.ObjectWidth = 9*INCH
ViewPro1.ObjectHeight = ViewPro1.ObjectWidth * (h/w)
ViewPro1.CurrentX = 1*INCH
ViewPro1.CurrentY = 1*INCH
'Place the form onto the current page
ViewPro1.PrintForm Form1.hWnd
Back To Top
___________________________________________________________________________
Q. How do I add columns to the ViewPro object? I want to create a multi-column report.
A. You may write a custom function to add mulit-columns to a report. The ViewPro demo also
provides the sample source code. Basically, multi-columns are just long narrow running paragraphs
that switch to the next column when reaching a certain bottom margin. ViewPro's Paragraph2 (or
Paragraph) supports multi-paragraphs with arbitrary paragraph width specified by ObjectWidth.
Back To Top
___________________________________________________________________________
Is There a Total Page Limit on My Report?
Q. Is There a Total Page Limit on My Report?
A. You can generate your reports in two ways. One way is generate all report pages and hold them on memory. The limit may be a few hundred pages, depending on the available RAM. Another way is generate a report page by page (generate a page, save it to disk, and repeat; after generating all pages, load them from disk for preview and print). This way, there is no page limit.
Back To Top
___________________________________________________________________________
Print to Large Size Paper for Plotter (such as HP DesignJet)
Q. I want to print to large size paper for plotter (such as HP DesignJe). What is the page size limit?
A. If you use the default unit (1440 twips = 1 inch), the page dimension limit is 32 K twips. This is because the x and y arguments for Windows API functions are limited to 32K. Accordingly, the largest page size is about 22 inches x 22 inches (with 1440 x 22 < 32K). If you use a smaller custom unit (with SetCustomUnit method), you can increase the page size limit. For example, If you set 1 inch = 720 (SetCustomUnit 720), the largest page size is 44 inches x 44 inches.
___________________________________________________________________________
Adjust On-screen Page Size to Fit Control Size
The on-screen page size depends on the Zoom value. You can use GetCalcZoom to calculate the
needed Zoom value. Since the Zoom value is integer (not continuous), the control width may need
to be slightly adjusted. The code below can be used to match page size with control size.
'--------------------------------
Private Sub Form_Load()
'Use pixel mode for form
Me.ScaleMode = 3
'Calculate needed zoom value
ViewPro1.MarginLeft = 0
ViewPro1.MarginTop = 0
ViewPro1.MarginRight = 0
ViewPro1.MarginBottom = 0
ViewPro1.Zoom = ViewPro1.GetCalcZoom(ViewPro1.Width)
ViewPro1.AmbientColor = RGB(255, 255, 255)
ViewPro1.SetPagePosition 1, 0
ViewPro1.SetPagePosition 2, 0
ViewPro1.HideScrollBar 1, 1
ViewPro1.HideScrollBar 2, 1
'Slightly adjust control width
ViewPro1.PageToClient ViewPro1.PageWidth, 0
ViewPro1.Width = ViewPro1.X
'Adjust page height
ViewPro1.PageSize = 14
ViewPro1.PageWidth = ViewPro1.PageWidth
ViewPro1.PageHeight = ViewPro1.PageWidth * ViewPro1.Height / ViewPro1.Width
'Draw lines along page edges
ViewPro1.StartDoc
ViewPro1.PenWidth = 100
ViewPro1.PageBorder = 1
ViewPro1.EndDoc
ViewPro1.Action = 0
ViewPro1.MouseZoom = False
End Sub
___________________________________________________________________________
Add More Pages to Report or Remove Pages from Report
Q. I would like to avoid having to define a fixed number of pages up front as the size of the report is not generally known until it is complete. Is there any way I can get around this?
A. You can generate your report page by page. That is, generate a page and save it to a file; and
then generate next page and save it, and so on. After generating pages, you can use ImportPage to
preview/print them (if you like, you can also use one ViewPro control to generate pages, and use
another ViewPro control to preview them). A sample coding procedure is presented below.
'---------------------------
'Generate and save page 1
ViewPro1.StartDoc
'draw your objects here
ViewPro1.EndDoc
ViewPro1.ExportPage page1.emf",1
ViewPro1.Action = 0
'Generate and save page 2
ViewPro1.StartDoc
'draw your objects here
ViewPro1.EndDoc
ViewPro1.ExportPage "page2.emf",1
ViewPro1.Action = 0
'Generate and save other pages
'...
'Preview page 1
ViewPro1.StartDoc
ViewPro1.ImportPage "page1.emf"
'If you like. draw (overlay) more objects here
ViewPro1.EndDoc
ViewPro1.Action = 0
'If you like, you can combine all pages into a single document
ViewPro1.StartDoc
ViewPro1.ImportPage "page1.emf"
ViewPro1.NewPage
ViewPro1.ImportPage "page2.emf"
'import other pages
'....
ViewPro1.EndDoc
ViewPro1.Action = 0
___________________________________________________________________________