小编Arm*_*nce的帖子

iTextSharp生成PDF:如何将pdf发送到客户端并添加提示?

我使用iTextSharp生成了一个pdf,当它创建时,它会自动保存在我的代码中提供的位置,而不是在客户端的服务器上,当然也没有告诉用户任何东西.

我需要将它发送给客户端,我需要提示一个对话框询问用户他想要保存他的pdf的位置.

我该怎么办?

这是我的pdf代码:

using (MemoryStream myMemoryStream = new MemoryStream())
{
    Document document = new Document();
    PdfWriter PDFWriter = PdfWriter.GetInstance(document, myMemoryStream);

    document.AddHeader("header1", "HEADER1");


    document.Open();

      //..........

    document.Close();

    byte[] content = myMemoryStream.ToArray();

    // Write out PDF from memory stream.
    using (FileStream fs =      File.Create(HttpContext.Current.Server.MapPath("~\\report.pdf")))
    {
        fs.Write(content, 0, (int)content.Length);
    }
Run Code Online (Sandbox Code Playgroud)

编辑

这是我想要http://examples.extjs.eu/?ex=download的结果示例

感谢您的回复,我修改了我的代码:

HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AppendHeader( "Content-Disposition", "attachment; filename=test.pdf");


using (MemoryStream myMemoryStream = new MemoryStream())
{    
Document document = new Document();    
PdfWriter PDFWriter = PdfWriter.GetInstance(document, myMemoryStream);

document.AddHeader("Content-Disposition", "attachment; filename=wissalReport.pdf");

document.Open(); …
Run Code Online (Sandbox Code Playgroud)

c# pdf extjs prompt itextsharp

6
推荐指数
2
解决办法
3万
查看次数

REST API命名约定

鉴于此URI:

/myapp/books/status/{status}
Run Code Online (Sandbox Code Playgroud)

例如 :

/myapp/books/status/new 
Run Code Online (Sandbox Code Playgroud)

这将返回标有此状态的所有书籍.

返回所有未标记特定状态的书籍的正确URI是什么?

/myapp/books/notstatus/new
Run Code Online (Sandbox Code Playgroud)

我想归还所有书籍的集合,除了具有一定地位的书籍.

请指教...

api rest naming

4
推荐指数
1
解决办法
1568
查看次数

无法自定义 django ckeditor 工具栏

我在django1.6上安装了django-ckeditor==4.4.8

但我在工具栏中得到了最少的按钮,我尝试更改工具栏以获得更多选项,特别是能够添加图片

这就是我得到的:

在此输入图像描述

这些是我的设置:

#ckeditor settings
CKEDITOR_UPLOAD_PATH = "images/"
CKEDITOR_IMAGE_BACKEND = 'pillow'
CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'

AWS_QUERYSTRING_AUTH = False
CKEDITOR_CONFIGS = {
'default': {
    'toolbar':'Full',
},
Run Code Online (Sandbox Code Playgroud)

}


顺便说一句,我想知道当您添加图片然后从文本编辑器删除该图片链接时会发生什么,该图片是否会被删除?

django toolbar ckeditor django-ckeditor django-1.6

4
推荐指数
1
解决办法
6192
查看次数

iTextSharp错误:无限表循环:行内容大于页面

我试图将数据库中的内容添加到使用iTextSharp创建的表中,但出现此错误:

>infinite table loop : row content is larger than page 
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

foreach (string n in Data)
                {
                    PdfPCell cella = new PdfPCell(new Phrase(n.id.ToString()));
                    table.AddCell(cella);
                    PdfPCell cellb = new PdfPCell(new Paragraph(n.Valeur));
                    table.AddCell(cellb);
                    PdfPCell cellc = new PdfPCell(new Phrase(n.Titre));
                    table.AddCell(cellc);
                }

            table.SpacingAfter = 40f;
            document.Add(table);
Run Code Online (Sandbox Code Playgroud)

n.Valeur是造成问题的原因,虽然其含量并不大,主要是一个段落。

row itext infinite-loop

3
推荐指数
1
解决办法
5627
查看次数

如何计算椭圆周长上的点?

我想在J2ME中用椭圆曲线绘制一个点

我有X,Y,宽度,高度和t的值.

XY是椭圆(根据J2ME)相对于Canvas的位置, t是相对于椭圆中心的角度(我有一个问题的图像表示,但不幸的博客不允许插入讨论: ))

int ePX = (X + width)+ (int) (width * Math.cos(Math.toRadians(t)));
int ePY = (Y + height)+ (int) (height * -Math.sin(Math.toRadians(t)));
Run Code Online (Sandbox Code Playgroud)

这个等式是否正确?或者对于椭圆,我们还需要进行更多的计算吗?

math geometry ellipse java-me

3
推荐指数
1
解决办法
5733
查看次数

图像翻转,使用libjpeg将OpenGL输出为JPEG

下面的代码帮助我使用libjpg将OpenGL输出转换为JPEG图像,但生成的图像垂直翻转...

代码工作完美,但最终图像翻转我不知道为什么?!

unsigned char *pdata = new unsigned char[width*height*3];
    glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pdata);

    FILE *outfile;
    if ((outfile = fopen("sample.jpeg", "wb")) == NULL) {
        printf("can't open %s");
        exit(1);
      }

    struct jpeg_compress_struct cinfo;
    struct jpeg_error_mgr       jerr;

    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_compress(&cinfo);
    jpeg_stdio_dest(&cinfo, outfile);

    cinfo.image_width      = width;
    cinfo.image_height     = height;
    cinfo.input_components = 3;
    cinfo.in_color_space   = JCS_RGB;

    jpeg_set_defaults(&cinfo);
    /*set the quality [0..100]  */
    jpeg_set_quality (&cinfo, 100, true);
    jpeg_start_compress(&cinfo, true);

    JSAMPROW row_pointer;
    int row_stride = width * 3;

    while (cinfo.next_scanline < cinfo.image_height) { …
Run Code Online (Sandbox Code Playgroud)

opengl reverse jpeg image libjpeg

3
推荐指数
1
解决办法
1676
查看次数

未捕获的TypeError:无法调用未定义的方法'insert'

我对extjs很新,并且遇到麻烦

我正在为我的应用程序使用浏览器布局示例

我试图添加一个表单网格,我定义了一个新的类,但当我调用我的表单网格时,我得到了这个错误

未捕获的TypeError:无法调用未定义的方法'insert'

这是我的代码:

Ext.define('Ext.app.myFormGrid', {

extend: 'Ext.grid.Panel',
alias: 'widget.formgrid ',
myData: [
    ['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'],
    ['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'],
    ['Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'],
    ['American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'],
    ['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'],
    ['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'],
    ['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'],
    ['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'],
    ['United Technologies …
Run Code Online (Sandbox Code Playgroud)

forms grid extjs class extjs4

2
推荐指数
1
解决办法
7323
查看次数

在网格上的selectionchange上显示不同的项目

我有一个网格和一个表单,每次我们在该网格上选择一行时,我需要在表单上显示不同的项目

我一直在寻找如何做到这一点,并找到了

    Ext.getCmp('myform').hide() // or  .show()
Run Code Online (Sandbox Code Playgroud)

    listeners: { selectionchange: function () {...}
Run Code Online (Sandbox Code Playgroud)

现在我不知道选择了哪一行,所以我可以指定要显示的项目

谢谢

grid selectionchanged extjs4

2
推荐指数
1
解决办法
1万
查看次数

分析器错误消息:无法创建类型'xxx'

我收到这个错误

Parser Error Message: Could not create type 'charts.lineChartData'.

Source Error: 

Line 1:  <%@ WebHandler Language="C#" CodeBehind="lineChartData.ashx.cs" Class="charts.lineChartData" %>

Source File: /WebSiteNetPas/lineChartData.ashx    Line: 1 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 
Run Code Online (Sandbox Code Playgroud)

事实上我在使用fiddler时遇到此错误,我的原始错误是:

Uncaught ReferenceError: lineChartData is not defined                   lineChart.js:20
http://localhost/WebSiteNetPas/lineChartData.ashx?proxy 500 (Internal Server Error)
Run Code Online (Sandbox Code Playgroud)

这是我的lineChartData.ashx.cs:

using System;
using System.Web;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Web.Script.Serialization;

namespace charts
{
    public class lineChartData : IHttpHandler
    {

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Write("Hello World"); …
Run Code Online (Sandbox Code Playgroud)

.net c# iis extjs

2
推荐指数
2
解决办法
2万
查看次数

LINQ to JSON:如何获得正确的格式?

我试图使用json.net将我的结果从linq查询转换为json

这是我做的:

JObject o = JObject.FromObject(new
{
    UserID = from u in model.USER
             select new
             {
                 UserID = u.UserID
             }
});
Run Code Online (Sandbox Code Playgroud)

这是我得到的:

JSON
  id=1
  result={"UserID":[{"UserID":121},"UserID":121},{"UserID":122},{"UserID":123},{"UserID":124}]}
Run Code Online (Sandbox Code Playgroud)

这是我需要的:

JSON
  id=1
  result={[{UserID:'121'},{UserID:'121'},{UserID:'122'},{UserID:'123'},{UserID:'124'}]}  
Run Code Online (Sandbox Code Playgroud)

我怎么做到这一点?谢谢

.net c# linq linq-to-entities json

2
推荐指数
1
解决办法
5424
查看次数

无法调用undefined的方法'substring'

这是我的代码:

Ext.define('Ext.app.Portal', {
    extend: 'Ext.container.Viewport',

    uses: ['Ext.app.PortalPanel', 'Ext.app.PortalColumn', 'Ext.app.GridPortlet', 'Ext.app.ChartPortlet'],

    getTools: function () {
        return [{
            xtype: 'tool',
            type: 'gear',
            handler: function (e, target, panelHeader, tool) {
                var portlet = panelHeader.ownerCt;
                portlet.setLoading('Working...');
                Ext.defer(function () {
                    portlet.setLoading(false);
                }, 2000);
            }
        }];
    },

    initComponent: function () {
        var content = '<div class="portlet-content">' + Ext.example.shortBogusMarkup + '</div>';

        Ext.apply(this, {
            id: 'app-viewport',
            layout: {
                type: 'border',
                padding: '0 5 5 5'
            }, //eo layout
            items: [{ //app-header : item 1 of app-viewport
                id: 'app-header', …
Run Code Online (Sandbox Code Playgroud)

tabs portal extjs extjs4

1
推荐指数
1
解决办法
2万
查看次数

ExtJS4文件上传 - 如何获取我的文件内容而不仅仅是位置

我知道如何创建一个浏览和选择文件的表单,这不是我的问题.我需要的是获取所选文件的内容,将其发送到服务器并进行处理.现在我只能获取文件位置.

我认为如果我在客户端(extjs)获取文件然后将其发送到服务器会更好,但我不知道如何做到这一点.

{
    xtype: 'fileuploadfield',
    hideLabel: true,
    emptyText: 'Select a file to upload...',
    id: 'upfile',
    //name:'file',
    width: 220
},
buttons:
[
    {
        text: 'Upload',
        handler: function () {
            obj.Import(Ext.getCmp('upfile').getValue())
        }
    }
]
Run Code Online (Sandbox Code Playgroud)

Import(...)是我的服务器功能.我需要给它的文件不仅仅是它的路径!!

提前谢谢您的时间

c# extjs file-upload extjs4

0
推荐指数
1
解决办法
5197
查看次数