PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

pdfsharp save to stream Delphi
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4884
Page 1 of 1

Author:  cpri [ Thu Sep 25, 2025 12:10 pm ]
Post subject:  pdfsharp save to stream Delphi

Hi all,

I'm new to this pdfsharp library and I want to use it to create my own pdf's in Delphi
For storing pdf's in my database I want to save the pdf as a stream.
For Delphi there is a function in the document object to store the pdf to a _stream. (document.save_2(astream,false))
However the stream for this function must be of the type _stream.

How can a convert this _stream to a "normal" TMemorystream.

Thanks in advance

Here is some code I tried
Code:
  FFont.Name:='Arial' ;
  FFont.Size:=12;
 
  AppDomainManager := GetAppDomainManager as _CustomAppDomainManager;

  Document := AppDomainManager.CreatePdfDocument;
  Page := Document.AddPage;
  Page.size:=PageSize_A4;
  Page.Orientation:=PageOrientation_Portrait;

  TempFontStyle:=0;
  XFont:= AppDomainManager.CreateXFontClass.XFont_2(FFont.Name, FFont.Size, TempFontStyle);
  XBrush := AppDomainManager.CreateXBrushesClass.Black.XBrush;
  Graphics := AppDomainManager.CreateXGraphicsClass.FromPdfPage(Page);
  Point._x:=0;
  Point._y:=0;
  Graphics.DrawString(text,XFont,XBrush,Point);

  Document.Save_2(astream,true);


Author:  TH-Soft [ Mon Sep 29, 2025 8:24 am ]
Post subject:  Re: pdfsharp save to stream Delphi

Hi!

I never used Delphi with .NET.

Under C#, you create a MemoryStream instance and pass that to the call of document.Save().
This work because class MemoryStream is derived from class Stream.

Does TMemoryStream give you access to a MemoryStream object?

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/