Export the current view in BMP, JPG, PDF, and other formats

Source: Internet
Author: User

Export the current view in BMP, JPG, PDF, and other formats

Public void pageexport ()
{
Savefiledialog psavedlg = new savefiledialog ();
Psavedlg. Title = "export image ";
Psavedlg. defaultext = "pdf ";
Psavedlg. filter = "pdf (*. PDF) | *. PDF | tiff (*. TIF) | *. TIF | BMP (*. BMP) | *. BMP | JPEG (*. JPG) | *. JPG | GIF (*. GIF) | *. GIF | EMF (*. EMF) | *. EMF | SVG (*. SVG) | *. SVG | ai (*. AI) | *. AI ";
Psavedlg. filterindex = 1;
Psavedlg. restoredirectory = true;
Psavedlg. overwriteprompt = true;

If (psavedlg. showdialog () = dialogresult. OK)
{
String pfilepath = psavedlg. filename;

Iactiveview pactiveview = axpagelayoutcontrol1.activeview;
Iexport pexport;
Tagrect exportframe;
Ienvelope penv;
Int HDC;
Int DPI;

Exportframe = pactiveview. exportframe;
Penv = new envelopeclass ();
Penv. putcoords (exportframe. Left, exportframe. Top, exportframe. Right, exportframe. Bottom );

Switch (psavedlg. filterindex)
{
Case 1: // PDF
Pexport = new export;class ();
DPI = (INT) pexport. Resolution;
Pexport. pixelbounds = penv;
Pexport. exportfilename = psavedlg. filename;
Pexport. Resolution = (short) DPI;

HDC = pexport. startexporting ();
Pactiveview. Output (HDC, DPI, ref exportframe, null, null );
Pexport. finishexporting ();
Break;
Case 2: // TIF
Pexport = new export;class ();
DPI = (INT) pexport. Resolution;
Pexport. pixelbounds = penv;
Pexport. exportfilename = psavedlg. filename;
Pexport. Resolution = (short) DPI;

HDC = pexport. startexporting ();
Pactiveview. Output (HDC, DPI, ref exportframe, null, null );
Pexport. finishexporting ();
Break;
Case 3: // BMP
Pexport = new exportbmpclass ();
DPI = (INT) pexport. Resolution;
Pexport. pixelbounds = penv;
Pexport. exportfilename = psavedlg. filename;
Pexport. Resolution = (short) DPI;

HDC = pexport. startexporting ();
Pactiveview. Output (HDC, DPI, ref exportframe, null, null );
Pexport. finishexporting ();
Break;
Case 4: // JPG
Pexport = new export;class ();
DPI = (INT) pexport. Resolution;
Pexport. pixelbounds = penv;
Pexport. exportfilename = psavedlg. filename;
Pexport. Resolution = (short) DPI;

HDC = pexport. startexporting ();
Pactiveview. Output (HDC, DPI, ref exportframe, null, null );
Pexport. finishexporting ();
Break;
Case 5: // GIF
Pexport = new exportgifclass ();
DPI = (INT) pexport. Resolution;
Pexport. pixelbounds = penv;
Pexport. exportfilename = psavedlg. filename;
Pexport. Resolution = (short) DPI;

HDC = pexport. startexporting ();
Pactiveview. Output (HDC, DPI, ref exportframe, null, null );
Pexport. finishexporting ();
Break;
Case 6: // EMF
Pexport = new exportemfclass ();
DPI = (INT) pexport. Resolution;
Pexport. pixelbounds = penv;
Pexport. exportfilename = psavedlg. filename;
Pexport. Resolution = (short) DPI;

HDC = pexport. startexporting ();
Pactiveview. Output (HDC, DPI, ref exportframe, null, null );
Pexport. finishexporting ();
Break;
Case 7: // SVG
Pexport = new exportsvgclass ();
DPI = (INT) pexport. Resolution;
Pexport. pixelbounds = penv;
Pexport. exportfilename = psavedlg. filename;
Pexport. Resolution = (short) DPI;

HDC = pexport. startexporting ();
Pactiveview. Output (HDC, DPI, ref exportframe, null, null );
Pexport. finishexporting ();
Break;
Case 8: // AI
Pexport = new exportaiclass ();
DPI = (INT) pexport. Resolution;
Pexport. pixelbounds = penv;
Pexport. exportfilename = psavedlg. filename;
Pexport. Resolution = (short) DPI;

HDC = pexport. startexporting ();
Pactiveview. Output (HDC, DPI, ref exportframe, null, null );
Pexport. finishexporting ();
Break;
Default:
Break;
}
MessageBox. Show ("exported! ");
}

View export mainly uses the iexport interface. In the old version, iexporter interface is used, and ae9 is replaced with iexport, and the export type is also increased.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.