473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Print using GDI+ and plain PrintDocument object to a pdf file

hi,

What is the cleanest and effective way to use the PrintDocument object
to print
directly to a pdf file "myfile.pdf" (with no prompt to the user: just
print to file and make pdf) ?

Does anyone have a simple code snippet? Either VB or C# will be
perfect.

-Pam

Apr 12 '07 #1
7 6492
Pam,

This is dependent on the print driver that you are using. Have you
tried setting the PrintFileName property on the PrinterSettings instance
used with your PrintDocument?

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"pamela fluente" <pa***********@libero.itwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
hi,

What is the cleanest and effective way to use the PrintDocument object
to print
directly to a pdf file "myfile.pdf" (with no prompt to the user: just
print to file and make pdf) ?

Does anyone have a simple code snippet? Either VB or C# will be
perfect.

-Pam

Apr 12 '07 #2
On 12 Apr, 18:10, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Pam,

This is dependent on the print driver that you are using. Have you
tried setting the PrintFileName property on the PrinterSettings instance
used with your PrintDocument?
Hi Nicholas ,

thanks for you reply. I am afraid I do not get what you mean.

Let's make a simple example. Assume I simply want to send into a new
pdf file (MyFile.PDF) a string, for instance

Private Sub PrintDocument1_PrintPage1(ByVal sender As Object,
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
PrintDocument1.PrintPage
e.Graphics.DrawString("How are you?", New
Font(FontFamily.GenericSansSerif, 18, FontStyle.Bold,
GraphicsUnit.Pixel), Brushes.Green, Point.Empty)
End Sub

without prompting the user. What would your suggestion be in this
case ?

-P

>
Hope this helps.
- Mostra testo tra virgolette -

Apr 12 '07 #3
Pamela,

Are you tring to create a PDF by printing to it using the PrintDoc?

If so, no way. PrintDoc can draw on a canvas like a bitmap or printer
canvas, but it cannot create a PDF.

If you want to create a PDF you can check iTextSharp a free and very good
dll for creating PDF's.

Rick
"pamela fluente" <pa***********@libero.itwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
hi,

What is the cleanest and effective way to use the PrintDocument object
to print
directly to a pdf file "myfile.pdf" (with no prompt to the user: just
print to file and make pdf) ?

Does anyone have a simple code snippet? Either VB or C# will be
perfect.

-Pam

Apr 12 '07 #4
On 12 Apr, 23:30, "Rick" <R...@LakeValleySeed.comwrote:
Pamela,

Are you tring to create a PDF by printing to it using the PrintDoc?

If so, no way. PrintDoc can draw on a canvas like a bitmap or printer
canvas, but it cannot create a PDF.

If you want to create a PDF you can check iTextSharp a free and very good
dll for creating PDF's.
Thanks Rick,

I have downloaded it and tried the examples.
The documents I need to print are by far too complicated, I think, for
that library.
I have thousands of objects and a lot of overlapping pictures with
alpha transparency
an so on. And all the (complex) logic is already implemented as
drawing on a graphics.

Let's try another direction. Is there a product or some api which
allows me to print normally
to a file and then convert the print file to PDF. Similar to what
Adobe Distiller does?
Or, more specifically, is there a kind of DLL version of Distiller (or
similar program ) which allows
creating directly a PDF from a plain print output file, *without*
prompting the user ?

-P
Apr 12 '07 #5
You can check PDFCreator. If you know how to create what you want in some
other program, then you can use PDFCreator as the print driver to output to
PDF.

The problem is then that you have to have this installed as a print driver
on all client machines.

Yes, your project sounds complicated, however I think iTextSharp could do it
since I think it can do anything that PDF can implement. The problem is the
overhead in learning how. There is a very good book and very active ng, but
then YOU still need to learn it.

Sorry, I don't have other suggestions.

Rick
"pamela fluente" <pa***********@libero.itwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
On 12 Apr, 23:30, "Rick" <R...@LakeValleySeed.comwrote:
>Pamela,

Are you tring to create a PDF by printing to it using the PrintDoc?

If so, no way. PrintDoc can draw on a canvas like a bitmap or printer
canvas, but it cannot create a PDF.

If you want to create a PDF you can check iTextSharp a free and very good
dll for creating PDF's.
Thanks Rick,

I have downloaded it and tried the examples.
The documents I need to print are by far too complicated, I think, for
that library.
I have thousands of objects and a lot of overlapping pictures with
alpha transparency
an so on. And all the (complex) logic is already implemented as
drawing on a graphics.

Let's try another direction. Is there a product or some api which
allows me to print normally
to a file and then convert the print file to PDF. Similar to what
Adobe Distiller does?
Or, more specifically, is there a kind of DLL version of Distiller (or
similar program ) which allows
creating directly a PDF from a plain print output file, *without*
prompting the user ?

-P


Apr 13 '07 #6
On 13 Apr, 11:03, "Rick" <R...@LakeValleySeed.comwrote:
You can check PDFCreator. If you know how to create what you want in some
other program, then you can use PDFCreator as the print driver to output to
PDF.

The problem is then that you have to have this installed as a print driver
on all client machines.

Yes, your project sounds complicated, however I think iTextSharp could do it
since I think it can do anything that PDF can implement. The problem is the
overhead in learning how. There is a very good book and very active ng, but
then YOU still need to learn it.

Sorry, I don't have other suggestions.

Rick
thanks Rick,

I will try that.

Thank you for the advice.

-P
Apr 13 '07 #7
Hi Rick

Im using iTextSharp tool to create a PDF. My requirement is that I need to
print each page from the PDF to different trays in a printer. Im using
PrintDocument to switch betweeen trays. Now that, I need to send the PDF
content of a single page to print using Graphics.DrawImage. Is there any way
of doing this?

"Rick" wrote:
Pamela,

Are you tring to create a PDF by printing to it using the PrintDoc?

If so, no way. PrintDoc can draw on a canvas like a bitmap or printer
canvas, but it cannot create a PDF.

If you want to create a PDF you can check iTextSharp a free and very good
dll for creating PDF's.

Rick
"pamela fluente" <pa***********@libero.itwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
hi,

What is the cleanest and effective way to use the PrintDocument object
to print
directly to a pdf file "myfile.pdf" (with no prompt to the user: just
print to file and make pdf) ?

Does anyone have a simple code snippet? Either VB or C# will be
perfect.

-Pam


Jun 20 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tessa | last post by:
Is there any security reason why you cannot print to a network printer from ASP.NET under IIS6 on Windows 2003 server? I'm using ASP.NET code to print to a server print queue using...
0
by: melanieab | last post by:
Hi, I have a tabpage with a print button. This button tries to do a print screen, and it works fine the first time, but if I try to press print again, I get error: An unhandled exception of type...
5
by: Tony | last post by:
Every 10 seconds I need to search a SQL table for orders to print. The orders are created through WebForms on ASP.NET clients. The orders should not print until 10 minutes before they are due. ...
1
by: melanieab | last post by:
Hi, I have a form with tab pages on it, and I'd like to print each page whenever a button is pressed (all the tabpages share the same print button - I just give it a different parent when another...
7
by: Mark | last post by:
Hi, I am creating application in VB 2005. and when I print report it adds extra 0.45 cm margin on left and top, and the reason for this is physical margins of printer. Is it possible to change...
2
by: Brad Pears | last post by:
I have some sample code that uses the print dialog, print preview and a print direct options. If I select print preview and then click the printer icon from that, the document prints. If I...
7
by: pamela fluente | last post by:
hi, What is the cleanest and effective way to use the PrintDocument object to print directly to a pdf file "myfile.pdf" (with no prompt to the user: just print to file and make pdf) ? Does...
0
by: jigsmshah | last post by:
I need to print a text file .When i print it ,it is not printed exactly form 0,0 coordiante of the page. I mean the top most left corner.It is leaving some margin from top and from left.The code is...
16
by: raylopez99 | last post by:
I am running out of printing paper trying to debug this...it has to be trivial, but I cannot figure it out--can you? Why am I not printing text, but just the initial string "howdy"? On the...
9
by: Autostrad | last post by:
Hi everybody, I need your help. The code below is good if I want to print a sketch. The book did not show how to print a simple text file. Right now if I run this program (as is)it will show...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.