Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 687105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:05:34+00:00 2026-05-14T02:05:34+00:00

I have an excel workbook vsto solution that needs to generate a pdf copy

  • 0

I have an excel workbook vsto solution that needs to generate a pdf copy of one of its sheets as output.

I have a license for abcdpdf .net and tried outputting to html, then using abcpdf to convert the html to pdf, but the excel html markup tries to emulate excel with all 4 worksheets with horrible markup. It also messes up the colors (silver background across entire workbook).

Any suggestions?

Here is the code I’m currently using to generate the html file:

FileInfo excelDoc = new FileInfo(Globals.ThisWorkbook.Path + @"\Document.html");

Globals.Sheet2.SaveAs(excelDoc.FullName,
    Excel.XlFileFormat.xlHtml, missing, missing, false, false,
    Excel.XlSaveAsAccessMode.xlNoChange,
    missing, missing, missing);

If I hack away some of the html header tags manually, I can get abcdpf to accept it, but the formatting is a bit off and this solution seems sub optimal.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:05:35+00:00Added an answer on May 14, 2026 at 2:05 am

    Solution found: store excel sheet as XPS print out. Import XPS printout into pdf document.

    MyImportOperation code adapted from abcpdf XPS sample source code.

        public void SaveSheetToPdf(FileInfo outputPDF)
        {
            FileInfo documentFile = new FileInfo(Globals.ThisWorkbook.Path + @"\tempDoc.xps");
            if (documentFile.Exists)
                documentFile.Delete();
    
            Globals.Sheet2.PrintOut(1, missing, 1, false, "Microsoft XPS Document Writer", true, false, documentFile.FullName);
    
            Doc theDoc = new Doc();                
    
            try
            {
                MyImportOperation importOp = new MyImportOperation(theDoc);
                importOp.Import(documentFile);            
            }
            catch (Exception ex)
            {
                throw new Exception("Error rendering pdf. PDF Source XPS Path: " + investmentPlanXPSPath, ex);
            }
    
            theDoc.Save(outputPDF.FullName);
        }
    
        public class MyImportOperation
        {
           private Doc _doc = null;
           private double _margin = 10;
           private int _pagesAdded = 0;
    
           public MyImportOperation(Doc doc)
           {
               _doc = doc;
           }
    
        public void Import(string inPath)
        {
            using (XpsImportOperation op = new XpsImportOperation())
            {
                op.ProcessingObject += Processing;
                op.ProcessedObject += Processed;
                op.Import(_doc, inPath);
            }
        }
    
        public void Processing(object sender, ProcessingObjectEventArgs e)
        {
    
            if (e.Info.SourceType == ProcessingSourceType.PageContent)
            {       
                _doc.Page = _doc.AddPage();     
                e.Info.Handled = true;
                _pagesAdded++;
            }
        }
    
        public void Processed(object sender, ProcessedObjectEventArgs e)
        {
            if (e.Successful)
            {
                PixMap pixmap = e.Object as PixMap;
                if (pixmap != null)
                    pixmap.Compress();      
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel 2003 workbook that contains a macro to copy certain of
I have a VSTO Excel workbook that functions correctly in test. I can deploy
I have an excel 2003 vsto workbook that I would like to make available
I have a program that spits out an Excel workbook in Excel 2003 XML
I have an Excel 2003 add-in deployed in one of our departments that occasionally
I have an Excel 2007 workbook that contains an ODBC data connection (to FoxPro,
I have some data that's currently stored in an Excel workbook. It makes sense
I have a need to copy a worksheet from one workbook into another and
We have an Excel workbook which has c# VSTO code in it and two
I have a Vsto Excel workbook (created in Visual Studio) which also contains a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.