PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Mon Oct 20, 2025 1:04 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Sep 25, 2025 12:10 pm 
Offline

Joined: Thu Sep 25, 2025 11:55 am
Posts: 1
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);



Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 29, 2025 8:24 am 
Offline
PDFsharp Guru
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 1062
Location: CCAA
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?

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider] and 110 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group