cancel
Showing results for 
Search instead for 
Did you mean: 

PrintToPrinter, ExportToDisk Problem

Former Member
0 Kudos

Hello,

I am using Crystal Reports 2008 inside VS2005 and I wanna get the report in PDF format.

The first thing i tried was exporting the report using the ExportToDisk function. It works ok, but the fonts of the PDF generated werent the same as the fonts i was using in my report and the quality of the images wasnt as good as i expected, they were converted to 256 color images. The result was exactly the same when i was using the Export option from Crystal Interface.

Then i printed the report from Crystal interface using the Adobe PDF printer. I got the right fonts and quality for the images so i decided to implement that in code. Using the code below all the PDF files i got are damaged or at least Acrobat Reader tells me that when opening them and the size of the generated files are much larger than the one i got when directly printing from the Crystal interface (so another thing that makes me thought they are really damaged).

Does anyone could help me to get the PDF?

The code is shown below. I am doing the test with a report with one page with one of the images i am using in my final report.

Thanks very much in advance, Diego

ReportDocument inf = new ReportDocument();

inf.Load(@"C:\Novatia\Proyectos\QH\reports\Test.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault);

inf.SetDatabaseLogon("sa", "XXXXXXXX", @"localhost\SQLEXPRESS", "InformesUF");

//inf.ExportToDisk(ExportFormatType.PortableDocFormat, filename); //The PDF generated is with bad quality

PrinterSettings ps = new PrinterSettings();

PageSettings pg = new PageSettings();

pg.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

ps.PrinterName = "Adobe PDF";

ps.Copies = 1;

ps.PrintToFile = true;

ps.PrintFileName = "C:
test.pdf";

inf.PrintToPrinter(ps, pg, true);

//inf.PrintToPrinter(ps, ps.DefaultPageSettings, true);

Accepted Solutions (1)

Accepted Solutions (1)

former_member184995
Active Contributor
0 Kudos

The change in font is intentional as it keeps data from truncating.

You can change the ForceLargerFonts to true in the registry, but be aware that you may lose data via truncation if you do.

Former Member
0 Kudos

Hi Jason,

thanks very much do u know something about the change in the images?

former_member183750
Active Contributor
0 Kudos

Make sure you have SP 0 installed. SP 0 can be downloaded from here:

https://smpdl.sap-ag.de/~sapidp/012002523100007528552008E/cr2008_sp0.zip

Ludek

Former Member
0 Kudos

Yes I have it installed but the problem persist. I also tried the same code in VS2008 and again the same problem using PrintToPrinter. I have also tried a new Report adding just a Text Object. Sorry for not commenting this in my first post

Thanks, Diego

0 Kudos

Hi Diego,

It may be a Font access issue. Open Control Panel, Regional and Language Settings and click on the Language Tab and check on the option Install Files for complex Scripts.... Then click on the Advanced Tab and check on the option in Default User Account Settings to apply all access to all users.

If the Font was installed under a user account your app may be running under the local system account in which case it does not have access to the font you are using. Checking on the above options should give access to the PDF export dll so no Font substitution is done.

Alsobe aware that we do NOT distribute licensed fonts for the obvious reason. The work around is to Export the report to Editable Word Doc and using Word 2007 it has an optional plug in that allows you to export to PDF. Word will embed the licensed fonts.

Thank you

Don

Former Member
0 Kudos

Hello, i solved the fonts substitution with this. But still i cannot get the proper image quality. All the images are with 256 color depth. Any help?

Thanks very much to all of u for all the answers...

former_member183750
Active Contributor
0 Kudos

I believe you mentioned that the same issue occurs in the Crystal reports designer (256 color issue). If that is the case, I'd suggest posting the question to the Report Design forum and see if they can help. Typically, if the issue exists inthe designer, it will exist at runtime and runtime will not be able to fix it. The CR design forum is here:

Ludek

Former Member
0 Kudos

Hi Ludek,

thanks for pointing me to the other forum but in the designer the images are displayed fine. And also if i print them from the designer they are fine. The issue only appears when exporting the image, but not only to PDF the same thing happen if i try to export to Word, although when i export the report to RPT format the results are cool.

So my problem is at runtime with those formats... any ideas?

Thanks very much for the help...

Diego

former_member183750
Active Contributor
0 Kudos

Apologies Diego. I misunderstood. try this:

Open the report in the CR designer

Go to the 'File' menu and click 'Report Options'

Select 'Retain Original Image Color Depth'

Save the report and see how it does at runtime.

Ludek

Former Member
0 Kudos

Hi Ludek,

THANKS that was the answer i was looking for and if u misunderstood me it was because of my english. No the report is 4MB size and i have to send it by mail. What i have now is ok, but i would like to print my report using the Adobe PDF cause when printing using the Crystal interface is only 800KB size. Do u know the code i posted in the beginning is not working? Any help with that?

Thanks very much, Diego

former_member183750
Active Contributor
0 Kudos

Hello Diego:

Wish I could write in Spanish(?) my self. I can talk it OK, but writing is another issue <g>

Anyhow, I do need a bit more clarification as to where we are. On Sep 17, 2008 you wrote:

"...i solved the fonts substitution with this. But still i cannot get the proper image quality."

And I think using the suggestion I made in my last post the image quality is resolved also?

So, now I'm wondering where we have the problem. Other than the language issue :). So, just give me a bit more detail, K?

Ludek

Former Member
0 Kudos

Hello Ludek,

is it so obvious that i am espanish :P? hehehe. Ok, as u guessed i solved all my problems but one more pop up. Now the size of the PDF generated is too big (4MB). If i print the report from Crystal using the Adobe PDF the report is also ok and it is only 800KB so i would like to do that in my code.

Unfortunately the code i am using generates damaged PDFs. I tried only a report with a TextObject and still the PDF generated is damaged, in the sense that Acrobat Reader tells me it is damaged when i am trying to open it.

The code i am using is in the first message of this thread.

Hope its clearer now, i will try harder if u need further explanation

Thanks for everything, seriously

former_member183750
Active Contributor
0 Kudos

Well, we have a friend called Diego - he's from Argentina as is my wife, so that was a clue

Ok, now to the issue at hand. I'd like you to do the following as a test:

1) Run the report in the CR designer.

2) Go to the File menu and enable "Save Data with Report"

3) Save the report

4) Go to your .NET app and comment out any database logon code

5) Run the saved data report and export it to pdf

Do you see a better export now? This is just a test. Not exactly sure what we'll get out of it, but it will be a nice piece of info to have.

Next I'd like to compare the dlls that load with the CR designer as opposed to the CR runtime. To that end, I'd like you to download the modules utility from here:

https://smpdl.sap-ag.de/~sapidp/012002523100006252802008E/modules.zip

follow these steps:

1) Extract the above file

2) Run the report in the CR designer and export to pdf - leave CR running

3) Start modules

4) Go to the File menu and select New List -> Memory modules

5) Save the file as designer.mdl

6) Run your app and do the export to pdf - leave the app running

7) Go back to Modules

😎 Go to the File menu and select New List -> Memory modules

9) Save the file as app.mdl

In Modules, expand the "By Process" node. Find the app exe name. Click on it, the right pane will populate with the dlls loaded. Now, go to the View menu and select Details. This will show you the dlls and their versions and all kinds of other detail. Do the above with the other mdl. You can compare the results manually, or use Modules (Module menu, select Differences). See if the comparison gives you any clues. In particular look at exportmodeller.dll, crtslv.dll and crxf_pdf.dll.

Also, what version of Adobe are you using?

Ludek

Answers (0)