Exemple #1
0
        public bool ConvertToPDF(DocumentSettings settings, string outputFileName)
        {
            object ignorePrintAreas;
            bool   flag;

            try
            {
                string tempPath = Path.GetTempPath();
                Guid   guid     = Guid.NewGuid();
                string str      = Path.Combine(tempPath, string.Concat("aquaforest\\pdftoolkit\\", guid.ToString(), "\\", Path.GetFileName(this.filePath)));
                PDFHelper.CheckOutputFolder(Path.GetDirectoryName(str));
                System.IO.File.Copy(this.filePath, str);
                object      missing          = Type.Missing;
                object      obj              = this.password;
                object      obj1             = this.password;
                object      missing1         = Type.Missing;
                object      obj2             = this.password;
                object      obj3             = this.password;
                object      missing2         = Type.Missing;
                object      missing3         = Type.Missing;
                object      missing4         = Type.Missing;
                object      openAndRepair    = settings.OpenAndRepair;
                object      obj4             = Type.Missing;
                object      missing5         = Type.Missing;
                object      obj5             = Type.Missing;
                Application applicationClass = new ApplicationClass();
                Workbook    workbook         = applicationClass.Workbooks.Open(this.filePath, Type.Missing, Type.Missing, Type.Missing, obj, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                foreach (Worksheet worksheet in workbook.Worksheets)
                {
                    if (settings.orientatinIset)
                    {
                        worksheet.PageSetup.Orientation = (XlPageOrientation)settings.PageOrientation;
                    }
                    if (!settings.ConvertHyperLinks)
                    {
                        worksheet.Cells.ClearHyperlinks();
                    }
                    if (settings.paperSizeIset)
                    {
                        worksheet.PageSetup.PaperSize = (XlPaperSize)settings.PaperSize;
                    }
                    if (settings.MarginBottom > 0f)
                    {
                        worksheet.PageSetup.BottomMargin = (double)settings.MarginBottom;
                    }
                    if (settings.MarginLeft > 0f)
                    {
                        worksheet.PageSetup.LeftMargin = (double)settings.MarginLeft;
                    }
                    if (settings.MarginRight > 0f)
                    {
                        worksheet.PageSetup.RightMargin = (double)settings.MarginRight;
                    }
                    if (settings.MarginTop > 0f)
                    {
                        worksheet.PageSetup.TopMargin = (double)settings.MarginTop;
                    }
                    if (this.Zoom <= 0f)
                    {
                        worksheet.PageSetup.Zoom = false;
                        if (this.FitToPagesTall > 0f)
                        {
                            worksheet.PageSetup.FitToPagesTall = this.FitToPagesTall;
                        }
                        if (this.FitToPagesWide > 0f)
                        {
                            worksheet.PageSetup.FitToPagesWide = this.FitToPagesWide;
                        }
                    }
                    else
                    {
                        worksheet.PageSetup.Zoom = this.Zoom;
                    }
                }
                if ((settings.FromPage <= 0 ? true : settings.ToPage <= 0))
                {
                    object obj6 = XlFixedFormatQuality.xlQualityStandard;
                    ignorePrintAreas = this.IgnorePrintAreas;
                    workbook.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, outputFileName, obj6, settings.IncludeDocumentProperty, ignorePrintAreas, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                }
                else
                {
                    object obj7 = XlFixedFormatQuality.xlQualityStandard;
                    ignorePrintAreas = this.IgnorePrintAreas;
                    workbook.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, outputFileName, obj7, settings.IncludeDocumentProperty, ignorePrintAreas, settings.FromPage, settings.ToPage, settings.OpenAfterConverting, Type.Missing);
                }
                workbook.Saved = true;
                workbook.Close(false, Type.Missing, Type.Missing);
                applicationClass.Quit();
                if (System.IO.File.Exists(outputFileName))
                {
                    PDFHelper.DisplayTrialPopupIfNecessary();
                    PDDocument pDDocument = PDDocument.load(new java.io.File(outputFileName));
                    PDFHelper.AddTrialStampIfNecessary(pDDocument, false);
                    pDDocument.save(outputFileName);
                    pDDocument.close();
                }
                PDFHelper.EmptyDirectory(Path.GetDirectoryName(str));
                flag = true;
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                throw new AquaforestOfficeException(exception.Message, exception);
            }
            return(flag);
        }
Exemple #2
0
        public bool ConvertToPDF(DocumentSettings settings, string outputFileName)
        {
            WdExportItem            wdExportItem;
            WdExportCreateBookmarks bookmarkOption;
            bool docStructureTags;
            bool bitmapNonEmbeddableFonts;
            bool flag;

            try
            {
                string tempPath = Path.GetTempPath();
                Guid   guid     = Guid.NewGuid();
                string str      = Path.Combine(tempPath, string.Concat("aquaforest\\pdftoolkit\\", guid.ToString(), "\\", Path.GetFileName(this.filePath)));
                PDFHelper.CheckOutputFolder(Path.GetDirectoryName(str));
                System.IO.File.Copy(this.filePath, str);
                string      str1             = str;
                object      missing          = Type.Missing;
                object      obj              = Type.Missing;
                object      missing1         = Type.Missing;
                object      obj1             = this.password;
                object      obj2             = this.password;
                object      missing2         = Type.Missing;
                object      obj3             = this.password;
                object      obj4             = this.password;
                object      missing3         = Type.Missing;
                object      missing4         = Type.Missing;
                object      obj5             = false;
                object      missing5         = Type.Missing;
                object      missing6         = Type.Missing;
                object      obj6             = Type.Missing;
                object      missing7         = Type.Missing;
                Application applicationClass = new ApplicationClass();
                object      obj7             = str1;
                object      obj8             = missing;
                object      obj9             = obj;
                object      obj10            = missing1;
                object      obj11            = obj1;
                object      obj12            = obj2;
                object      obj13            = missing2;
                object      obj14            = obj3;
                object      obj15            = obj4;
                object      obj16            = missing3;
                object      obj17            = missing4;
                object      obj18            = obj5;
                object      obj19            = missing5;
                object      missing8         = missing6;
                object      missing9         = obj6;
                object      missing10        = missing7;
                Document    pageOrientation  = applicationClass.Documents.Open(ref obj7, ref obj8, ref obj9, ref obj10, ref obj11, ref obj12, ref obj13, ref obj14, ref obj15, ref obj16, ref obj17, ref obj18, ref obj19, ref missing8, ref missing9, ref missing10);
                if (settings.orientatinIset)
                {
                    pageOrientation.PageSetup.Orientation = (WdOrientation)settings.PageOrientation;
                }
                if ((settings.PageHeight <= 0f ? false : settings.PageWidth > 0f))
                {
                    pageOrientation.PageSetup.PageHeight = settings.PageHeight;
                    pageOrientation.PageSetup.PageWidth  = settings.PageWidth;
                }
                else if (settings.paperSizeIset)
                {
                    pageOrientation.PageSetup.PaperSize = (WdPaperSize)settings.PaperSize;
                }
                if (this.EmbedFonts > AquaforestFontEmbedding.EMBED_NONE)
                {
                    pageOrientation.EmbedTrueTypeFonts = true;
                    if (this.EmbedFonts == AquaforestFontEmbedding.EMBED_SUBSET)
                    {
                        pageOrientation.SaveSubsetFonts = true;
                    }
                }
                if (settings.revisionModeIset)
                {
                    pageOrientation.TrackRevisions = true;
                    pageOrientation.ActiveWindow.View.MarkupMode = (WdRevisionsMode)settings.RevisionMode;
                }
                if (settings.MarginBottom > 0f)
                {
                    pageOrientation.PageSetup.BottomMargin = settings.MarginBottom;
                }
                if (settings.MarginLeft > 0f)
                {
                    pageOrientation.PageSetup.LeftMargin = settings.MarginLeft;
                }
                if (settings.MarginRight > 0f)
                {
                    pageOrientation.PageSetup.RightMargin = settings.MarginRight;
                }
                if (settings.MarginTop > 0f)
                {
                    pageOrientation.PageSetup.TopMargin = settings.MarginTop;
                }
                if (!settings.ConvertHyperLinks)
                {
                    object obj20 = 1;
                    while (pageOrientation.Hyperlinks.Count > 0)
                    {
                        pageOrientation.Hyperlinks[ref obj20].Delete();
Exemple #3
0
        public bool ConvertToPDF(DocumentSettings settings, string outputFileName)
        {
            bool docStructureTags;
            bool bitmapNonEmbeddableFonts;
            bool flag;

            try
            {
                string tempPath = Path.GetTempPath();
                Guid   guid     = Guid.NewGuid();
                string str      = Path.Combine(tempPath, string.Concat("aquaforest\\pdftoolkit\\", guid.ToString(), "\\", Path.GetFileName(this.filePath)));
                PDFHelper.CheckOutputFolder(Path.GetDirectoryName(str));
                System.IO.File.Copy(this.filePath, str);
                string      str1             = str;
                object      missing          = Type.Missing;
                bool        flag1            = false;
                bool        flag2            = false;
                object      obj              = this.password;
                object      obj1             = this.password;
                object      missing1         = Type.Missing;
                object      obj2             = this.password;
                object      obj3             = this.password;
                object      missing2         = Type.Missing;
                object      missing3         = Type.Missing;
                object      missing4         = Type.Missing;
                object      openAndRepair    = settings.OpenAndRepair;
                object      obj4             = Type.Missing;
                object      missing5         = Type.Missing;
                object      obj5             = Type.Missing;
                Application applicationClass = new ApplicationClass();
                Document    marginLeft       = applicationClass.Open(str1, flag1, flag2, PbSaveOptions.pbDoNotSaveChanges);
                if (settings.MarginLeft > 0f)
                {
                    marginLeft.PageSetup.LeftMargin = settings.MarginLeft;
                }
                if (settings.MarginTop > 0f)
                {
                    marginLeft.PageSetup.TopMargin = settings.MarginTop;
                }
                if (!settings.ConvertHyperLinks)
                {
                    foreach (Page page in marginLeft.Pages)
                    {
                        foreach (Shape shape in page.Shapes)
                        {
                            shape.Hyperlink.Delete();
                        }
                    }
                }
                if ((settings.FromPage <= 0 ? true : settings.ToPage <= 0))
                {
                    bitmapNonEmbeddableFonts = this.BitmapNonEmbeddableFonts;
                    docStructureTags         = this.DocStructureTags;
                    marginLeft.ExportAsFixedFormat(PbFixedFormatType.pbFixedFormatTypePDF, outputFileName, PbFixedFormatIntent.pbIntentPrinting, settings.IncludeDocumentProperty, -1, -1, -1, -1, -1, -1, -1, true, PbPrintStyle.pbPrintStyleDefault, docStructureTags, bitmapNonEmbeddableFonts, settings.PDFA1a, Type.Missing);
                }
                else
                {
                    bool bitmapNonEmbeddableFonts1 = this.BitmapNonEmbeddableFonts;
                    docStructureTags = this.DocStructureTags;
                    bool includeDocumentProperty = settings.IncludeDocumentProperty;
                    bitmapNonEmbeddableFonts = settings.PDFA1a;
                    marginLeft.ExportAsFixedFormat(PbFixedFormatType.pbFixedFormatTypePDF, outputFileName, PbFixedFormatIntent.pbIntentPrinting, includeDocumentProperty, -1, -1, -1, -1, settings.FromPage, settings.ToPage, -1, true, PbPrintStyle.pbPrintStyleDefault, docStructureTags, bitmapNonEmbeddableFonts1, bitmapNonEmbeddableFonts, Type.Missing);
                }
                marginLeft.Close();
                applicationClass.Quit();
                if (System.IO.File.Exists(outputFileName))
                {
                    PDFHelper.DisplayTrialPopupIfNecessary();
                    PDDocument pDDocument = PDDocument.load(new java.io.File(outputFileName));
                    PDFHelper.AddTrialStampIfNecessary(pDDocument, false);
                    pDDocument.save(outputFileName);
                    pDDocument.close();
                }
                PDFHelper.EmptyDirectory(Path.GetDirectoryName(str1));
                flag = true;
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                throw new AquaforestOfficeException(exception.Message, exception);
            }
            return(flag);
        }
Exemple #4
0
        public bool ConvertToPDF(DocumentSettings settings, string outputFileName)
        {
            MsoTriState msoTriState;
            bool        flag;

            try
            {
                string tempPath = Path.GetTempPath();
                Guid   guid     = Guid.NewGuid();
                string str      = Path.Combine(tempPath, string.Concat("aquaforest\\pdftoolkit\\", guid.ToString(), "\\", Path.GetFileName(this.filePath)));
                PDFHelper.CheckOutputFolder(Path.GetDirectoryName(str));
                System.IO.File.Copy(this.filePath, str);
                string       str1             = str;
                object       missing          = Type.Missing;
                object       obj              = Type.Missing;
                object       missing1         = Type.Missing;
                object       obj1             = this.password;
                object       obj2             = this.password;
                object       missing2         = Type.Missing;
                object       obj3             = this.password;
                object       obj4             = this.password;
                object       missing3         = Type.Missing;
                object       missing4         = Type.Missing;
                object       missing5         = Type.Missing;
                object       openAndRepair    = settings.OpenAndRepair;
                object       obj5             = Type.Missing;
                object       missing6         = Type.Missing;
                object       obj6             = Type.Missing;
                Application  applicationClass = new ApplicationClass();
                Presentation pageOrientation  = applicationClass.Presentations.Open(str1, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
                msoTriState = (!this.FrameSlides ? MsoTriState.msoFalse : MsoTriState.msoTrue);
                if (settings.orientatinIset)
                {
                    pageOrientation.PageSetup.SlideOrientation = (MsoOrientation)settings.PageOrientation;
                }
                if ((settings.PageHeight <= 0f ? false : settings.PageWidth > 0f))
                {
                    pageOrientation.PageSetup.SlideHeight = settings.PageHeight;
                    pageOrientation.PageSetup.SlideWidth  = settings.PageWidth;
                }
                else if (this.slideSizeIsSet)
                {
                    pageOrientation.PageSetup.SlideSize = (PpSlideSizeType)this.SlideSize;
                }
                if (!settings.ConvertHyperLinks)
                {
                    object obj7 = 1;
                    foreach (Slide slide in pageOrientation.Slides)
                    {
                        while (slide.Hyperlinks.Count > 0)
                        {
                            foreach (Hyperlink hyperlink in slide.Hyperlinks)
                            {
                                hyperlink.Delete();
                            }
                        }
                    }
                }
                AquaforestPDFOptimizeFor    optimizeFor            = settings.OptimizeFor;
                AquaforestPrintHandoutOrder powerPointHandoutOrder = this.PowerPointHandoutOrder;
                bool bitmapNonEmbeddableFonts = this.BitmapNonEmbeddableFonts;
                pageOrientation.ExportAsFixedFormat(outputFileName, PpFixedFormatType.ppFixedFormatTypePDF, (PpFixedFormatIntent)optimizeFor, msoTriState, (PpPrintHandoutOrder)powerPointHandoutOrder, PpPrintOutputType.ppPrintOutputSlides, MsoTriState.msoFalse, null, PpPrintRangeType.ppPrintAll, "", settings.IncludeDocumentProperty, true, true, bitmapNonEmbeddableFonts, settings.PDFA1a, Type.Missing);
                pageOrientation.Close();
                applicationClass.Quit();
                if (System.IO.File.Exists(outputFileName))
                {
                    PDFHelper.DisplayTrialPopupIfNecessary();
                    PDDocument pDDocument = PDDocument.load(new java.io.File(outputFileName));
                    PDFHelper.AddTrialStampIfNecessary(pDDocument, false);
                    pDDocument.save(outputFileName);
                    pDDocument.close();
                }
                PDFHelper.EmptyDirectory(Path.GetDirectoryName(str));
                flag = true;
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                throw new AquaforestOfficeException(exception.Message, exception);
            }
            return(flag);
        }