protected void lnkDownloadPDF_Click(object sender, EventArgs e)
 {
     Page.Validate();
     if (Page.IsValid)
     {
         SuppressFooter = true;
         OverrideRender = true;
         PageOptions    = new PDFOptions()
         {
             PaperSize   = (PDFOptions.PageSize)Enum.Parse(typeof(PDFOptions.PageSize), cmbPageSize.SelectedValue),
             PageHeight  = decCustHeight.IntValue,
             PageWidth   = decCustWidth.IntValue,
             Orientation = rbLandscape.Checked ? PDFOptions.PageOrientation.Landscape : PDFOptions.PageOrientation.Portrait,
             FooterUri   = (VirtualPathUtility.ToAbsolute("~/Public/PrintFooter.aspx") + (ckIncludeCoverSheet.Checked ? "/Cover" : string.Empty)).ToAbsoluteURL(Request),
             // FooterLeft = Resources.LogbookEntry.LogbookCertification,
             // FooterRight = PDFOptions.FooterPageCountArg,
             LeftMargin   = decLeftMargin.IntValue,
             RightMargin  = decRightMargin.IntValue,
             TopMargin    = decTopMargin.IntValue,
             BottomMargin = decBottomMargin.IntValue
         };
         PrintOptions = PrintOptions1.Options;
     }
     RefreshLogbookData();
 }
Beispiel #2
0
        private void 输出PDFToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            //设置PDF文件输出项

            PDFOptions pdfOptions = new PDFOptions();

            pdfOptions.IsEntire = true;

            pdfOptions.IsLineStyleRetained = true;

            pdfOptions.IsPointStyleRetained = true;

            pdfOptions.IsRegionStyleRetained = true;

            pdfOptions.IsVector = true;

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "导出为PDF(*.pdf)|*.pdf";

            saveFileDialog.Title = "保存";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string pdfName = saveFileDialog.FileName;

                mapLayoutControl1.MapLayout.OutputLayoutToPDF(pdfName, pdfOptions);
            }
        }
Beispiel #3
0
        /// <summary>
        /// This method specifies a HTML file that should be converted into a PDF.
        /// </summary>
        /// <param name="path">The file path of a HTML file to convert into a PDF.</param>
        /// <param name="options">A instance of the PDFOptions class that defines any special options to use when creating the PDF.</param>
        public void FileToPDF(string path, PDFOptions options)
        {
            lock (thisLock)
            {
                if (!File.Exists(path))
                {
                    throw new GrabzItException(string.Concat("File: ", path, " does not exist"), ErrorCode.FileNonExistantPath);
                }

                HTMLToPDF(File.ReadAllText(path), options);
            }
        }
Beispiel #4
0
        /// <summary>
        /// This method specifies the HTML that should be converted into a PDF.
        /// </summary>
        /// <param name="html">The HTML to convert into a PDF.</param>
        /// <param name="options">A instance of the PDFOptions class that defines any special options to use when creating the PDF.</param>
        public void HTMLToPDF(string html, PDFOptions options)
        {
            lock (thisLock)
            {
                if (options == null)
                {
                    options = new PDFOptions();
                }

                request.Store(BaseURLPost + TakePDF, true, options, html);
            }
        }
Beispiel #5
0
        /// <summary>
        /// This method specifies the URL that should be converted into a PDF.
        /// </summary>
        /// <param name="url">The URL that the should be converted into a pdf</param>
        /// <param name="options">A instance of the PDFOptions class that defines any special options to use when creating the PDF.</param>
        public void URLToPDF(string url, PDFOptions options)
        {
            lock (thisLock)
            {
                if (options == null)
                {
                    options = new PDFOptions();
                }

                request.Store(BaseURLGet + TakePDF, false, options, url);
            }
        }
Beispiel #6
0
        public async Task CreatePDF()
        {
            var options = new PDFOptions();

            options.DocumentHTML = "<html>This is a test from C# API client</html>";

            var buf = await Api.PDF.CreateAsync(options);

            Assert.IsNotNull(buf);

            File.WriteAllBytes("/tmp/pdf-sharp.pdf", buf);
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int page      = util.GetIntParam(Request, "page", 1);
            int pageCount = util.GetIntParam(Request, "topage", 1);

            string szOptions = Request.PathInfo.Length > 1 ? Request.PathInfo.Substring(1) : string.Empty;
            bool   fHasCover = PDFOptions.CoverFromEncodedOptions(szOptions);
            bool   fHasTotal = PDFOptions.TotalPagesFromEncodedOptions(szOptions);

            // If we have a cover page, start numbering on the page AFTER the cover.
            if (fHasCover)
            {
                page--;
                pageCount--;
            }

            lblPage.Text      = fHasTotal ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.PrintedFooterPageCountWithTotals, page, pageCount) : String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.PrintedFooterPageCount, page);
            tblFooter.Visible = page > 0; // don't show the footer on the cover page.
        }