Guest - pec - Postado Fevereiro 1, 2006 Denunciar Share Postado Fevereiro 1, 2006 Estou tentando transformar um codigo V.S.(asp.net) em delphi(asp.net), e estou encontrando essa dificuldade nesta linha:&Array.Copy(pdfimage, pdfbuffer, size); erro:[Error] WebForm1.pas(58): E2010 Incompatible types: 'Array' and 'Object'esta declarada assim:pdfimage:System.&Array;também tentei assim:pdfimage:System.Object;mas também dá erro.ps. já tentei sem o &. (pdfimage:System.Array;) dá o mesmo erro.Estou trabalhando como add references, eu carrego a dll.exemplo original em V.B Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim PDF ' PDF object Dim Size As Long Dim PDFImage As System.Array ' create pdf library object PDF = CreateObject("PDFCreatorPilot2.piPDFDocument") ' initialize PDF Engine PDF.StartEngine("demo@demo", "demo") ' set GenerateInMemoryFile generation flag to TRUE so keep PDF ' only in the memory PDF.GenerateInMemoryFile = True ' start document generation PDF.BeginDoc() ' draw "HELLO, PDF" message on the current PDF page PDF.PDFPAGE_SetActiveFont("Verdana", True, False, False, False, 14, 0) PDF.PDFPAGE_TextOut(10, 20, 0, "HELLO, PDF!") ' finalize document generation PDF.EndDoc() ' clear the output stream ' get size of generated in-memory pdf file Size = PDF.MemoryFileSize ' create new buffer with size equal to generated pdf file Dim PDFBuffer(CInt(Size)) As Byte ' get in-memory pdf file as byte stream PDFImage = PDF.BinaryImage ' copy byte stream into buffer Array.Copy(PDFImage, PDFBuffer, Size) ' clear http output Response.Clear() ' set the content type to PDF Response.ContentType = "application/pdf" ' add content type header Response.AddHeader("Content-Type", "application/pdf") ' set the content disposition Response.AddHeader("Content-Disposition", "inline;filename=form.pdf") ' write the buffer with pdf file to the output Response.BinaryWrite(PDFBuffer) Response.End() ' disconnect from library PDF = Nothing End Sub ----------------------------------------------------------------------------e com as alterações em delphiprocedure TWebForm1.Page_Load(sender: System.Object; e: System.EventArgs);var pdf:PDFCreatorPilot2.IpiPDFDocument2; size:integer; pdfbuffer:byte; pdfimage:System.&Array;begin // TODO: Put user code to initialize the page here pdf:= PDFCreatorPilot2.piPDFDocumentClass.Create; pdf.StartEngine('demo@demo', 'demo'); pdf.GenerateInMemoryFile:= true; pdf.BeginDoc; //pdf.PDFPAGE_SetActiveFont('times new roman', true, false, false, false, 14, 0); pdf.PDFPAGE_TextOut(10, 20, 0, 'HELLO, PDF!'); pdf.EndDoc; size:= pdf.MemoryFileSize; pdfbuffer:= size; pdfimage:= pdf.BinaryImage; &Array.Copy(pdfimage, pdfbuffer, size); response.Clear; response.ContentType:= 'application/PDF'; Response.AddHeader('Content-Type', 'application/pdf'); Response.AddHeader('Content-Disposition', 'inline;filename=form.pdf'); response.BinaryWrite(pdfbuffer); Response.&End;end;obrigado pela atenção de todos. Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 Graymalkin Postado Fevereiro 2, 2006 Denunciar Share Postado Fevereiro 2, 2006 Coloque uma resposta sobre isso no fórum de .NET: http://scriptbrasil.com.br/forum/index.php?showtopic=71772Abraços,Graymalkin Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
Guest - pec -
Estou tentando transformar um codigo V.S.(asp.net) em delphi(asp.net), e estou encontrando essa dificuldade nesta linha:
&Array.Copy(pdfimage, pdfbuffer, size);
erro:[Error] WebForm1.pas(58): E2010 Incompatible types: 'Array' and 'Object'
esta declarada assim:
pdfimage:System.&Array;
também tentei assim:
pdfimage:System.Object;
mas também dá erro.
ps. já tentei sem o &. (pdfimage:System.Array;) dá o mesmo erro.
Estou trabalhando como add references, eu carrego a dll.
exemplo original em V.B
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim PDF ' PDF object
Dim Size As Long
Dim PDFImage As System.Array
' create pdf library object
PDF = CreateObject("PDFCreatorPilot2.piPDFDocument")
' initialize PDF Engine
PDF.StartEngine("demo@demo", "demo")
' set GenerateInMemoryFile generation flag to TRUE so keep PDF ' only in the memory
PDF.GenerateInMemoryFile = True
' start document generation
PDF.BeginDoc()
' draw "HELLO, PDF" message on the current PDF page
PDF.PDFPAGE_SetActiveFont("Verdana", True, False, False, False, 14, 0)
PDF.PDFPAGE_TextOut(10, 20, 0, "HELLO, PDF!")
' finalize document generation
PDF.EndDoc() ' clear the output stream
' get size of generated in-memory pdf file
Size = PDF.MemoryFileSize
' create new buffer with size equal to generated pdf file
Dim PDFBuffer(CInt(Size)) As Byte
' get in-memory pdf file as byte stream
PDFImage = PDF.BinaryImage
' copy byte stream into buffer
Array.Copy(PDFImage, PDFBuffer, Size)
' clear http output
Response.Clear()
' set the content type to PDF
Response.ContentType = "application/pdf"
' add content type header
Response.AddHeader("Content-Type", "application/pdf")
' set the content disposition
Response.AddHeader("Content-Disposition", "inline;filename=form.pdf")
' write the buffer with pdf file to the output
Response.BinaryWrite(PDFBuffer)
Response.End()
' disconnect from library
PDF = Nothing
End Sub
----------------------------------------------------------------------------
e com as alterações em delphi
procedure TWebForm1.Page_Load(sender: System.Object; e: System.EventArgs);
var
pdf:PDFCreatorPilot2.IpiPDFDocument2;
size:integer;
pdfbuffer:byte;
pdfimage:System.&Array;
begin
// TODO: Put user code to initialize the page here
pdf:= PDFCreatorPilot2.piPDFDocumentClass.Create;
pdf.StartEngine('demo@demo', 'demo');
pdf.GenerateInMemoryFile:= true;
pdf.BeginDoc;
//pdf.PDFPAGE_SetActiveFont('times new roman', true, false, false, false, 14, 0);
pdf.PDFPAGE_TextOut(10, 20, 0, 'HELLO, PDF!');
pdf.EndDoc;
size:= pdf.MemoryFileSize;
pdfbuffer:= size;
pdfimage:= pdf.BinaryImage;
&Array.Copy(pdfimage, pdfbuffer, size);
response.Clear;
response.ContentType:= 'application/PDF';
Response.AddHeader('Content-Type', 'application/pdf');
Response.AddHeader('Content-Disposition', 'inline;filename=form.pdf');
response.BinaryWrite(pdfbuffer);
Response.&End;
end;
obrigado pela atenção de todos.
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.