printing the AxVisio within a C# form

  • Thread starter genc_ ymeri at hotmail dot com
  • Start date
G

genc_ ymeri at hotmail dot com

Hi,
I'm trying to print a AxVisio embedded in a C# form and while the shapes
print fine, their texts show amazing charchteres, like being encrypted....

I used AxVisio.Document.Print() or the method which MSVisio SDK provides but
we (as a team) have the same problem with two diff printers.

Any idea ???

Thank you very much in advance,
Genc Ymeri
( while in the PS is the code I'm using).

P.S. :

public class PrintingDocument {

/// <summary>This method is the class constructor.</summary>
public PrintingDocument() {

// No initialization
}

/// <summary>This method prints the same document in three different
/// ways: the entire document using one command, all the odd pages with
/// one orientation and all the even pages with another orientation, and
/// the odd pages as portrait and the even pages on 2x2 printer pages
/// by increasing the print margins.</summary>
/// <param name="printedDocument">Document to be printed</param>
public void PrintDocument(
Microsoft.Office.Interop.Visio.Document printedDocument) {

bool isLandscape;
bool isFitOnPages;
short printPagesAcross;
short printPagesDown;

try {

// Begin the first example: Print the entire document.
printedDocument.Print();

// Begin the second example: Use even/odd orientation
// differences.
// Save the existing orientation.
isLandscape = printedDocument.PrintLandscape;

for (int pageIndex = 1;
pageIndex <= printedDocument.Pages.Count;
pageIndex++) {

// Print one page.
PrintPage(printedDocument, pageIndex);

// Change the orientation.
if (printedDocument.PrintLandscape == true) {
printedDocument.PrintLandscape = false;
}
else {
printedDocument.PrintLandscape = true;
}
}

// Set the orientation back to the initial orientation.
printedDocument.PrintLandscape = isLandscape;

// Begin the third example: Increase print margins.
// Save the existing settings.
isFitOnPages = printedDocument.PrintFitOnPages;
printPagesAcross = printedDocument.PrintPagesAcross;
printPagesDown = printedDocument.PrintPagesDown;

// To set printPageAcross and printPageDown, the
// PrintFitOnPages property should be set to True.
printedDocument.PrintFitOnPages = true;

// Set the orientation to portrait.
printedDocument.PrintLandscape = false;

for (int pageIndex = 1;
pageIndex <= printedDocument.Pages.Count;
pageIndex++) {

if ((pageIndex % 2) == 0) {

// For even pages, print on 2x2 printer pages.
printedDocument.PrintPagesAcross = 2;
printedDocument.PrintPagesDown = 2;
}
else {

// For odd pages, print on one printer page.
printedDocument.PrintPagesAcross = 1;
printedDocument.PrintPagesDown = 1;
}

PrintPage(printedDocument, pageIndex);
}

// Set the printedDocument back to the initial settings.
printedDocument.PrintFitOnPages = isFitOnPages;
printedDocument.PrintPagesAcross = printPagesAcross;
printedDocument.PrintPagesDown = printPagesDown;
printedDocument.PrintLandscape = isLandscape;
}
catch (Exception err) {
System.Diagnostics.Debug.WriteLine(err.Message);
}
}

/// <summary>This method prints one page from the document using a
/// specified page index.</summary>
/// <param name="printedDocument">Document from which the page is to
/// be printed</param>
/// <param name="pageIndex">Index of the page to be printed</param>
public void PrintPage(
Microsoft.Office.Interop.Visio.Document printedDocument,
int pageIndex) {

try {

// Print the page.
if (pageIndex <= printedDocument.Pages.Count) {

printedDocument.Pages[pageIndex].Print();
}
}
catch (Exception err) {
System.Diagnostics.Debug.WriteLine(err.Message);
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top