Set "Fit To Page"

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
charuVas1
Posts: 8
Joined: Thu Jun 19 2008

Set "Fit To Page"

Post by charuVas1 »

Hi,

I have developer version of Amyuni PDF Converter Dll 3.01a. I am passing a txt or xls file to the pdf printer to convert it to pdf. The code (in VB.net) is as follows-

Public WithEvents cdi As CDIntfEx.CDIntfExClass = New CDIntfEx.CDIntfExClass
sub IntiliazePrinter()
cdi.PDFDriverInit("PDFPrinter")
cdi.DriverInit("PDFPrinter")
cdi.FileNameOptionsEx = &H1 + &H2 + &H80 + &H10
cdi.DefaultFileName = Path.GetTempPath & "abc.pdf"
cdi.SetPrinterParamStr("Activation Error Title", "")
cdi.SetPrinterParamStr("Activation Error Text", "")
cdi.EnablePrinter("","")
cdi.CaptureEvents(1)
cdi.SetDefaultConfigEx()
'Create delegates to Events fired by the PDF Converter
AddHandler cdi.EnabledPre, AddressOf EnablePre_Function
AddHandler cdi.EndDocPost, AddressOf EndDocPost_Function
AddHandler cdi.StartDocPost, AddressOf StartDocPost_Function
end sub

sub PrintButton_Click
PrintDocument1.PrinterSettings.PrinterName = "PDFPrinter"
strPDFPrint = "C:\Users\Administrator\Desktop\Scan-Features.txt"
streamToPrint = New System.IO.StreamReader(strPDFPrint)
printFont = New Font("Arial", 10)
printDocument1.Print()
end sub
sub PrintDocument_printpage() 'this event is fired everytime a page is printed
Try
Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = e.MarginBounds.Left
Dim topMargin As Single = e.MarginBounds.Top
Dim line As String = Nothing

' Calculate the number of lines per page.
linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics)

' Print each line of the file.
While count < linesPerPage
line = streamToPrint.ReadLine()
If line IsNot Nothing Then
yPos = topMargin + count * printFont.GetHeight(e.Graphics)
e.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())
count += 1
Else
Exit While
End If
End While
' If more lines exist, print another page.
If (line IsNot Nothing) Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
end sub

Private Sub EnablePre_Function()
cdi.EnablePrinter("","")
cdi.CaptureEvents(1)
cdi.SimPostscript = True 'Simulate a PostScript printer
cdi.HorizontalMargin = 0
cdi.VerticalMargin = 0
cdi.Orientation = 0
cdi.PaperSize = 9 'a4 paper
cdi.ImageOptions = 0
cdi.SetDefaultConfig() 'Make the values default
End Sub

The file is printed to pdf however the content doesnt fit in the page. Is there a "Fit To Page" Option, so that the content will not get cut?

Thank you
Charu
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Re: Set "Fit To Page"

Post by Joan »

Hello,

There is a FitToPage features in the latest version 4.0 of the PDF Converter.

Please make sure that the page settings of the PDF Printer is the same as the page settings of the document to be printed.
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Post Reply