Ejemplo n.º 1
0
        public async Task <ActionResult> Post([FromBody] GraphQLQuery query)
        {
            var schema = new CustomSchema();
            var inputs = query.Variables != null ? new Inputs((System.Collections.Generic.IDictionary <string, object>)query.Variables) : null;

            var result = await new DocumentExecuter().ExecuteAsync(_ =>
            {
                _.Schema        = schema.GraphQLSchema;
                _.Query         = query.Query;
                _.OperationName = query.OperationName;
                _.Inputs        = inputs;
            });

            if (result.Errors?.Count > 0)
            {
                return(BadRequest());
            }

            return(Ok(result));
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            //Create a new PDF Document. The pdfDoc object represents the PDF document.
            //This document has one page by default and additional pages have to be added.
            PdfDocument pdfDoc = new PdfDocument();
            PdfPage     page   = pdfDoc.Pages.Add();

            // Get xmp object.
            XmpMetadata xmp = pdfDoc.DocumentInformation.XmpMetadata;


            // XMP Basic Schema.
            BasicSchema basic = xmp.BasicSchema;

            basic.Advisory.Add("advisory");
            basic.BaseURL     = new Uri("http://google.com");
            basic.CreateDate  = DateTime.Now;
            basic.CreatorTool = "creator tool";
            basic.Identifier.Add("identifier");
            basic.Label        = "label";
            basic.MetadataDate = DateTime.Now;
            basic.ModifyDate   = DateTime.Now;
            basic.Nickname     = "nickname";
            basic.Rating.Add(-25);

            //Setting various Document properties.
            pdfDoc.DocumentInformation.Title        = "Document Properties Information";
            pdfDoc.DocumentInformation.Author       = "Syncfusion";
            pdfDoc.DocumentInformation.Keywords     = "PDF";
            pdfDoc.DocumentInformation.Subject      = "PDF demo";
            pdfDoc.DocumentInformation.Producer     = "Syncfusion Software";
            pdfDoc.DocumentInformation.CreationDate = DateTime.Now;

            PdfFont  font     = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
            PdfFont  boldFont = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold);
            PdfBrush brush    = PdfBrushes.Black;

            PdfGraphics     g      = page.Graphics;
            PdfStringFormat format = new PdfStringFormat();

            format.LineSpacing = 10f;

            g.DrawString("Press Ctrl+D to see Document Properties", boldFont, brush, 10, 10);
            g.DrawString("Basic Schema Xml:", boldFont, brush, 10, 50);
            g.DrawString(basic.XmlData.OuterXml, font, brush, new RectangleF(10, 70, 500, 500), format);

            //Defines and set values for Custom metadata and add them to the Pdf document
            CustomSchema custom = new CustomSchema(xmp, "custom", "http://www.syncfusion.com/");

            custom["Company"] = "Syncfusion";
            custom["Website"] = "http://www.syncfusion.com/";
            custom["Product"] = "Essential PDF";


            //Save the PDF Document to disk.
            pdfDoc.Save("Sample.pdf");

            //Message box confirmation to view the created PDF document.
            if (MessageBox.Show("Do you want to view the PDF file?", "PDF File Created",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Information)
                == DialogResult.Yes)
            {
                //Launching the PDF file using the default Application.[Acrobat Reader]
#if NETCORE
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.pdf")
                {
                    UseShellExecute = true
                };
                process.Start();
#else
                System.Diagnostics.Process.Start("Sample.pdf");
#endif
                this.Close();
            }
            else
            {
                // Exit
                this.Close();
            }
        }
        public ActionResult DocumentSettings(string InsideBrowser)
        {
            //Create a new PDF Document. The pdfDoc object represents the PDF document.
            //This document has one page by default and additional pages have to be added.
            PdfDocument pdfDoc = new PdfDocument();
            PdfPage     page   = pdfDoc.Pages.Add();

            // Get xmp object.
            XmpMetadata xmp = pdfDoc.DocumentInformation.XmpMetadata;

            // XMP Basic Schema.
            BasicSchema basic = xmp.BasicSchema;

            basic.Advisory.Add("advisory");
            basic.BaseURL     = new Uri("http://google.com");
            basic.CreateDate  = DateTime.Now;
            basic.CreatorTool = "creator tool";
            basic.Identifier.Add("identifier");
            basic.Label        = "label";
            basic.MetadataDate = DateTime.Now;
            basic.ModifyDate   = DateTime.Now;
            basic.Nickname     = "nickname";
            basic.Rating.Add(-25);

            //Setting various Document properties.
            pdfDoc.DocumentInformation.Title        = "Document Properties Information";
            pdfDoc.DocumentInformation.Author       = "Syncfusion";
            pdfDoc.DocumentInformation.Keywords     = "PDF";
            pdfDoc.DocumentInformation.Subject      = "PDF demo";
            pdfDoc.DocumentInformation.Producer     = "Syncfusion Software";
            pdfDoc.DocumentInformation.CreationDate = DateTime.Now;

            PdfFont  font     = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
            PdfFont  boldFont = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold);
            PdfBrush brush    = PdfBrushes.Black;

            PdfGraphics     g      = page.Graphics;
            PdfStringFormat format = new PdfStringFormat();

            format.LineSpacing = 10f;

            g.DrawString("Press Ctrl+D to see Document Properties", boldFont, brush, 10, 10);
            g.DrawString("Basic Schema Xml:", boldFont, brush, 10, 50);
            g.DrawString(basic.XmlData.OuterXml, font, brush, new RectangleF(10, 70, 500, 500), format);

            //Defines and set values for Custom metadata and add them to the Pdf document
            CustomSchema custom = new CustomSchema(xmp, "custom", "//www.syncfusion.com/");

            custom["Company"] = "Syncfusion";
            custom["Website"] = "//www.syncfusion.com/";
            custom["Product"] = "Essential PDF";

            //Stream the output to the browser.
            if (InsideBrowser == "Browser")
            {
                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Open));
            }
            else
            {
                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
        }
Ejemplo n.º 4
0
        public ActionResult DocumentSettings(string InsideBrowser)
        {
            //Create a new PDF Document. The pdfDoc object represents the PDF document.
            //This document has one page by default and additional pages have to be added.
            PdfDocument pdfDoc = new PdfDocument();
            PdfPage     page   = pdfDoc.Pages.Add();

            // Get xmp object.
            XmpMetadata xmp = pdfDoc.DocumentInformation.XmpMetadata;

            // XMP Basic Schema.
            BasicSchema basic = xmp.BasicSchema;

            basic.Advisory.Add("advisory");
            basic.BaseURL     = new Uri("http://google.com");
            basic.CreateDate  = DateTime.Now;
            basic.CreatorTool = "creator tool";
            basic.Identifier.Add("identifier");
            basic.Label        = "label";
            basic.MetadataDate = DateTime.Now;
            basic.ModifyDate   = DateTime.Now;
            basic.Nickname     = "nickname";
            basic.Rating.Add(-25);

            //Setting various Document properties.
            pdfDoc.DocumentInformation.Title        = "Document Properties Information";
            pdfDoc.DocumentInformation.Author       = "Syncfusion";
            pdfDoc.DocumentInformation.Keywords     = "PDF";
            pdfDoc.DocumentInformation.Subject      = "PDF demo";
            pdfDoc.DocumentInformation.Producer     = "Syncfusion Software";
            pdfDoc.DocumentInformation.CreationDate = DateTime.Now;

            PdfFont  font     = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
            PdfFont  boldFont = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold);
            PdfBrush brush    = PdfBrushes.Black;

            PdfGraphics     g      = page.Graphics;
            PdfStringFormat format = new PdfStringFormat();

            format.LineSpacing = 10f;

            g.DrawString("Press Ctrl+D to see Document Properties", boldFont, brush, 10, 10);
            g.DrawString("Basic Schema Xml:", boldFont, brush, 10, 50);
            g.DrawString(basic.XmlData.ToString(), font, brush, new RectangleF(10, 70, 500, 500), format);

            //Defines and set values for Custom metadata and add them to the Pdf document
            CustomSchema custom = new CustomSchema(xmp, "custom", "http://www.syncfusion.com/");

            custom["Company"] = "Syncfusion";
            custom["Website"] = "http://www.syncfusion.com/";
            custom["Product"] = "Essential PDF";

            //Save the PDF to the MemoryStream
            MemoryStream ms = new MemoryStream();

            pdfDoc.Save(ms);

            //If the position is not set to '0' then the PDF will be empty.
            ms.Position = 0;

            //Close the PDF document.
            pdfDoc.Close(true);

            //Download the PDF document in the browser.
            FileStreamResult fileStreamResult = new FileStreamResult(ms, "application/pdf");

            fileStreamResult.FileDownloadName = "DocumentSettings.pdf";
            return(fileStreamResult);
        }